Thomas G. Lopes commited on
Commit
af52a96
·
1 Parent(s): 3a971ea

fix model picker quirks

Browse files
src/routes/canvas/chat-node.svelte CHANGED
@@ -159,8 +159,8 @@
159
 
160
  <!-- Add node button -->
161
  <button
162
- class="abs-x-center absolute -bottom-4 flex items-center gap-1.5 rounded-full
163
- bg-black px-4 py-2 text-xs font-medium
164
  text-white shadow-sm transition-all hover:scale-[1.02]
165
  hover:bg-gray-900 focus:ring-2 focus:ring-gray-900/20 focus:outline-none active:scale-[0.98]"
166
  onclick={() => {
@@ -201,8 +201,6 @@
201
 
202
  <Handle type="target" position={Position.Top} class="h-3 w-3 border-2 border-white bg-gray-500 shadow-sm" />
203
  <Handle type="source" position={Position.Bottom} class="h-3 w-3 border-2 border-white bg-gray-500 shadow-sm" />
204
- <Handle type="source" position={Position.Left} class="h-3 w-3 border-2 border-white bg-gray-500 shadow-sm" />
205
- <Handle type="source" position={Position.Right} class="h-3 w-3 border-2 border-white bg-gray-500 shadow-sm" />
206
 
207
  <!-- <NodeResizeControl minWidth={200} minHeight={150}> -->
208
  <!-- <IconResize class="absolute right-2 bottom-2" /> -->
 
159
 
160
  <!-- Add node button -->
161
  <button
162
+ class="abs-x-center absolute -bottom-4 z-10 flex items-center gap-1.5
163
+ rounded-full bg-black px-4 py-2 text-xs font-medium
164
  text-white shadow-sm transition-all hover:scale-[1.02]
165
  hover:bg-gray-900 focus:ring-2 focus:ring-gray-900/20 focus:outline-none active:scale-[0.98]"
166
  onclick={() => {
 
201
 
202
  <Handle type="target" position={Position.Top} class="h-3 w-3 border-2 border-white bg-gray-500 shadow-sm" />
203
  <Handle type="source" position={Position.Bottom} class="h-3 w-3 border-2 border-white bg-gray-500 shadow-sm" />
 
 
204
 
205
  <!-- <NodeResizeControl minWidth={200} minHeight={150}> -->
206
  <!-- <IconResize class="absolute right-2 bottom-2" /> -->
src/routes/canvas/model-picker.svelte CHANGED
@@ -112,6 +112,10 @@
112
  // Return the content for highlighting
113
  return typeof nextItem.content === "object" ? nextItem.content.id : null;
114
  },
 
 
 
 
115
  });
116
 
117
  $effect(() => {
@@ -122,91 +126,96 @@
122
  </script>
123
 
124
  <div class="relative w-full">
125
- <label class="mb-1.5 block text-xs font-medium text-gray-600">Model</label>
 
126
 
127
- <!-- Combobox input -->
128
- <input
129
- class="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm
130
  text-gray-900 placeholder-gray-500 transition-colors focus:border-gray-900 focus:ring-2
131
  focus:ring-gray-900/10 focus:outline-none"
132
- placeholder="Search and select a model..."
133
- bind:value={query}
134
- {...combobox.input}
135
- />
 
136
 
137
  <!-- Combobox content -->
138
  <div
139
- class="absolute z-50 mt-1 hidden max-h-80 w-full overflow-hidden rounded-lg border
140
- border-gray-200 bg-white shadow-lg data-[open]:block"
141
  {...combobox.content}
142
- popover={undefined}
 
 
 
 
 
143
  >
144
  <!-- Virtualized model list -->
145
- <div class="max-h-80 overflow-y-auto" {...virtualScroll.container}>
146
- {#snippet modelEntry(model: Model | CustomModel, trending?: boolean)}
147
- {@const [nameSpace, modelName] = model.id.split("/")}
148
- <div
149
- class="flex w-full cursor-pointer items-center px-3 py-2 text-sm
150
  hover:bg-gray-50 data-[highlighted]:bg-gray-100"
151
- {...combobox.getOption(model.id)}
152
- >
153
- {#if trending}
154
- <div class="mr-1.5 size-4 text-yellow-400">
155
- <IconStar />
156
- </div>
157
- {/if}
158
-
159
- {#if modelName}
160
- <span class="inline-flex items-center">
161
- <span class="text-gray-500">{nameSpace}</span>
162
- <span class="mx-1 text-gray-300">/</span>
163
- <span class="text-black">{modelName}</span>
164
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  {:else}
166
- <span class="text-black">{nameSpace}</span>
167
- {/if}
168
-
169
- {#if "pipeline_tag" in model && model.pipeline_tag === "image-text-to-text"}
170
- <Tooltip openDelay={100}>
171
- {#snippet trigger(tooltip)}
172
- <div
173
- class="ml-2 grid size-5 place-items-center rounded bg-gray-500/10 text-gray-500"
174
- {...tooltip.trigger}
175
- >
176
- <IconEye class="size-3.5" />
177
- </div>
178
- {/snippet}
179
- Image text-to-text
180
- </Tooltip>
181
- {/if}
182
-
183
- {#if isCustom(model)}
184
- <Tooltip openDelay={100}>
185
- {#snippet trigger(tooltip)}
186
- <div
187
- class="ml-2 grid size-5 place-items-center rounded bg-gray-500/10 text-gray-500"
188
- {...tooltip.trigger}
189
- >
190
- <IconCube class="size-3.5" />
191
- </div>
192
- {/snippet}
193
- Custom Model
194
- </Tooltip>
195
  {/if}
196
- </div>
197
- {/snippet}
198
-
199
- <!-- Virtual scroll container -->
200
- <div style="height: {virtualScroll.totalHeight}px; position: relative;">
201
- <div style="transform: translateY({virtualScroll.offsetY}px);">
202
- {#each virtualScroll.getVisibleItems(allFilteredModels) as { item }}
203
- {#if item.type === "header"}
204
- <div class="bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-500">{item.content}</div>
205
- {:else}
206
- {@render modelEntry(item.content, item.trending)}
207
- {/if}
208
- {/each}
209
- </div>
210
  </div>
211
  </div>
212
  </div>
 
112
  // Return the content for highlighting
113
  return typeof nextItem.content === "object" ? nextItem.content.id : null;
114
  },
115
+ onOpenChange: o => {
116
+ if (o || !modelId) return;
117
+ combobox.inputValue = modelId;
118
+ },
119
  });
120
 
121
  $effect(() => {
 
126
  </script>
127
 
128
  <div class="relative w-full">
129
+ <label class="block space-y-1.5 text-xs font-medium text-gray-600">
130
+ <p>Model</p>
131
 
132
+ <!-- Combobox input -->
133
+ <input
134
+ class="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm
135
  text-gray-900 placeholder-gray-500 transition-colors focus:border-gray-900 focus:ring-2
136
  focus:ring-gray-900/10 focus:outline-none"
137
+ placeholder="Search and select a model..."
138
+ bind:value={query}
139
+ {...combobox.input}
140
+ />
141
+ </label>
142
 
143
  <!-- Combobox content -->
144
  <div
145
+ class="absolute z-50 mt-1 hidden max-h-80 w-full !min-w-[400px] overflow-hidden overflow-y-auto
146
+ rounded-lg border border-gray-200 bg-white shadow-lg data-[open]:block"
147
  {...combobox.content}
148
+ {...virtualScroll.container}
149
+ onscroll={e => {
150
+ e.stopPropagation();
151
+ e.preventDefault();
152
+ virtualScroll.container.onscroll(e);
153
+ }}
154
  >
155
  <!-- Virtualized model list -->
156
+ {#snippet modelEntry(model: Model | CustomModel, trending?: boolean)}
157
+ {@const [nameSpace, modelName] = model.id.split("/")}
158
+ <div
159
+ class="flex w-full cursor-pointer items-center px-3 py-2 text-sm
 
160
  hover:bg-gray-50 data-[highlighted]:bg-gray-100"
161
+ {...combobox.getOption(model.id)}
162
+ >
163
+ {#if trending}
164
+ <div class="mr-1.5 size-4 text-yellow-400">
165
+ <IconStar />
166
+ </div>
167
+ {/if}
168
+
169
+ {#if modelName}
170
+ <span class="inline-flex items-center">
171
+ <span class="text-gray-500">{nameSpace}</span>
172
+ <span class="mx-1 text-gray-300">/</span>
173
+ <span class="text-black">{modelName}</span>
174
+ </span>
175
+ {:else}
176
+ <span class="text-black">{nameSpace}</span>
177
+ {/if}
178
+
179
+ {#if "pipeline_tag" in model && model.pipeline_tag === "image-text-to-text"}
180
+ <Tooltip openDelay={100}>
181
+ {#snippet trigger(tooltip)}
182
+ <div
183
+ class="ml-2 grid size-5 place-items-center rounded bg-gray-500/10 text-gray-500"
184
+ {...tooltip.trigger}
185
+ >
186
+ <IconEye class="size-3.5" />
187
+ </div>
188
+ {/snippet}
189
+ Image text-to-text
190
+ </Tooltip>
191
+ {/if}
192
+
193
+ {#if isCustom(model)}
194
+ <Tooltip openDelay={100}>
195
+ {#snippet trigger(tooltip)}
196
+ <div
197
+ class="ml-2 grid size-5 place-items-center rounded bg-gray-500/10 text-gray-500"
198
+ {...tooltip.trigger}
199
+ >
200
+ <IconCube class="size-3.5" />
201
+ </div>
202
+ {/snippet}
203
+ Custom Model
204
+ </Tooltip>
205
+ {/if}
206
+ </div>
207
+ {/snippet}
208
+
209
+ <!-- Virtual scroll container -->
210
+ <div style="height: {virtualScroll.totalHeight}px; position: relative;">
211
+ <div style="transform: translateY({virtualScroll.offsetY}px);">
212
+ {#each virtualScroll.getVisibleItems(allFilteredModels) as { item }}
213
+ {#if item.type === "header"}
214
+ <div class="bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-500">{item.content}</div>
215
  {:else}
216
+ {@render modelEntry(item.content, item.trending)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  {/if}
218
+ {/each}
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  </div>
220
  </div>
221
  </div>