nsarrazin HF Staff commited on
Commit
0890bdd
·
unverified ·
1 Parent(s): 3bd3541

feat(assistants): better distinction between my own assistants and other people's assistants (#1437)

Browse files
src/routes/settings/(nav)/+layout.svelte CHANGED
@@ -75,30 +75,66 @@
75
  {/each}
76
  <!-- if its huggingchat, the number of assistants owned by the user must be non-zero to show the UI -->
77
  {#if data.enableAssistants}
78
- <h3 bind:this={assistantsSection} class="pb-3 pl-3 pt-5 text-[.8rem] text-gray-800 sm:pl-1">
79
  Assistants
80
  </h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  {#if !data.loginEnabled || (data.loginEnabled && !!data.user)}
82
  <a
83
  href="{base}/settings/assistants/new"
84
  class="group flex h-10 flex-none items-center gap-2 pl-3 pr-2 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl
85
- {$page.url.pathname === `${base}/settings/assistants/new` ? '!bg-gray-100 !text-gray-800' : ''}"
86
  >
87
  <CarbonAdd />
88
  <div class="truncate">Create new assistant</div>
89
  </a>
90
  {/if}
91
- {#each data.assistants as assistant}
 
 
 
 
92
  <a
93
  href="{base}/settings/assistants/{assistant._id.toString()}"
94
  class="group flex h-10 flex-none items-center gap-2 pl-2 pr-2 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl
95
- {assistant._id.toString() === $page.params.assistantId ? '!bg-gray-100 !text-gray-800' : ''}"
96
  >
97
  {#if assistant.avatar}
98
  <img
99
  src="{base}/settings/assistants/{assistant._id.toString()}/avatar.jpg?hash={assistant.avatar}"
100
  alt="Avatar"
101
- class="h-6 w-6 rounded-full object-cover"
102
  />
103
  {:else}
104
  <div
@@ -125,9 +161,10 @@
125
  </a>
126
  {/if}
127
 
 
128
  <a
129
  href="{base}/settings"
130
- class="group mt-auto flex h-10 flex-none items-center gap-2 pl-3 pr-2 text-sm text-gray-500 hover:bg-gray-100 max-md:order-first md:rounded-xl
131
  {$page.url.pathname === `${base}/settings` ? '!bg-gray-100 !text-gray-800' : ''}"
132
  >
133
  <UserIcon class="text-sm" />
 
75
  {/each}
76
  <!-- if its huggingchat, the number of assistants owned by the user must be non-zero to show the UI -->
77
  {#if data.enableAssistants}
78
+ <h3 bind:this={assistantsSection} class="pl-3 pt-5 text-[.8rem] text-gray-800 sm:pl-1">
79
  Assistants
80
  </h3>
81
+ <!-- My Assistants -->
82
+ <h4 class="py-2 pl-5 text-[.7rem] text-gray-600 sm:pl-1">My Assistants</h4>
83
+
84
+ {#each data.assistants.filter((assistant) => assistant.createdByMe) as assistant}
85
+ <a
86
+ href="{base}/settings/assistants/{assistant._id.toString()}"
87
+ class="group flex h-10 flex-none items-center gap-2 pl-2 pr-2 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl
88
+ {assistant._id.toString() === $page.params.assistantId ? '!bg-gray-100 !text-gray-800' : ''}"
89
+ >
90
+ {#if assistant.avatar}
91
+ <img
92
+ src="{base}/settings/assistants/{assistant._id.toString()}/avatar.jpg?hash={assistant.avatar}"
93
+ alt="Avatar"
94
+ class="h-6 w-6 rounded-full"
95
+ />
96
+ {:else}
97
+ <div
98
+ class="flex size-6 items-center justify-center rounded-full bg-gray-300 font-bold uppercase text-gray-500"
99
+ >
100
+ {assistant.name[0]}
101
+ </div>
102
+ {/if}
103
+ <div class="truncate text-gray-900">{assistant.name}</div>
104
+ {#if assistant._id.toString() === $settings.activeModel}
105
+ <div
106
+ class="ml-auto rounded-lg bg-black px-2 py-1.5 text-xs font-semibold leading-none text-white"
107
+ >
108
+ Active
109
+ </div>
110
+ {/if}
111
+ </a>
112
+ {/each}
113
  {#if !data.loginEnabled || (data.loginEnabled && !!data.user)}
114
  <a
115
  href="{base}/settings/assistants/new"
116
  class="group flex h-10 flex-none items-center gap-2 pl-3 pr-2 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl
117
+ {$page.url.pathname === `${base}/settings/assistants/new` ? '!bg-gray-100 !text-gray-800' : ''}"
118
  >
119
  <CarbonAdd />
120
  <div class="truncate">Create new assistant</div>
121
  </a>
122
  {/if}
123
+
124
+ <!-- Other Assistants -->
125
+ <h4 class="pl-3 pt-3 text-[.7rem] text-gray-600 sm:pl-1">Other Assistants</h4>
126
+
127
+ {#each data.assistants.filter((assistant) => !assistant.createdByMe) as assistant}
128
  <a
129
  href="{base}/settings/assistants/{assistant._id.toString()}"
130
  class="group flex h-10 flex-none items-center gap-2 pl-2 pr-2 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl
131
+ {assistant._id.toString() === $page.params.assistantId ? '!bg-gray-100 !text-gray-800' : ''}"
132
  >
133
  {#if assistant.avatar}
134
  <img
135
  src="{base}/settings/assistants/{assistant._id.toString()}/avatar.jpg?hash={assistant.avatar}"
136
  alt="Avatar"
137
+ class="h-6 w-6 rounded-full"
138
  />
139
  {:else}
140
  <div
 
161
  </a>
162
  {/if}
163
 
164
+ <div class="my-2 mt-auto w-full border-b border-gray-200" />
165
  <a
166
  href="{base}/settings"
167
+ class="group flex h-10 flex-none items-center gap-2 pl-3 pr-2 text-sm text-gray-500 hover:bg-gray-100 max-md:order-first md:rounded-xl
168
  {$page.url.pathname === `${base}/settings` ? '!bg-gray-100 !text-gray-800' : ''}"
169
  >
170
  <UserIcon class="text-sm" />