@opencode/ui 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/components/document-surface.d.ts +3 -0
  2. package/dist/components/preview-controls.d.ts +9 -0
  3. package/dist/context/helper.d.ts +1 -0
  4. package/dist/data-display/keybind/keybind.d.ts +1 -1
  5. package/dist/data-display/line-comment/line-comment.d.ts +4 -2
  6. package/dist/forms/typeahead/typeahead.d.ts +5 -0
  7. package/dist/i18n/am.d.ts +246 -1
  8. package/dist/i18n/ar.d.ts +0 -3
  9. package/dist/i18n/az.d.ts +246 -1
  10. package/dist/i18n/bg.d.ts +0 -3
  11. package/dist/i18n/bn.d.ts +246 -1
  12. package/dist/i18n/br.d.ts +0 -3
  13. package/dist/i18n/bs.d.ts +0 -3
  14. package/dist/i18n/ca.d.ts +260 -1
  15. package/dist/i18n/cs.d.ts +274 -1
  16. package/dist/i18n/da.d.ts +0 -3
  17. package/dist/i18n/de.d.ts +0 -3
  18. package/dist/i18n/dv.d.ts +246 -1
  19. package/dist/i18n/dz.d.ts +246 -1
  20. package/dist/i18n/el.d.ts +246 -1
  21. package/dist/i18n/en.d.ts +11 -4
  22. package/dist/i18n/es.d.ts +0 -3
  23. package/dist/i18n/et.d.ts +246 -1
  24. package/dist/i18n/fa.d.ts +246 -1
  25. package/dist/i18n/fi.d.ts +246 -1
  26. package/dist/i18n/fo.d.ts +246 -1
  27. package/dist/i18n/fr.d.ts +0 -3
  28. package/dist/i18n/he.d.ts +0 -3
  29. package/dist/i18n/hi.d.ts +246 -1
  30. package/dist/i18n/hr.d.ts +260 -1
  31. package/dist/i18n/hu.d.ts +246 -1
  32. package/dist/i18n/hy.d.ts +246 -1
  33. package/dist/i18n/id.d.ts +246 -1
  34. package/dist/i18n/is.d.ts +246 -1
  35. package/dist/i18n/it.d.ts +260 -1
  36. package/dist/i18n/ja.d.ts +0 -3
  37. package/dist/i18n/ka.d.ts +246 -1
  38. package/dist/i18n/km.d.ts +0 -3
  39. package/dist/i18n/ko.d.ts +0 -3
  40. package/dist/i18n/lo.d.ts +0 -3
  41. package/dist/i18n/lt.d.ts +274 -1
  42. package/dist/i18n/lv.d.ts +260 -1
  43. package/dist/i18n/mk.d.ts +0 -3
  44. package/dist/i18n/mn.d.ts +0 -3
  45. package/dist/i18n/ms.d.ts +246 -1
  46. package/dist/i18n/my.d.ts +0 -3
  47. package/dist/i18n/ne.d.ts +246 -1
  48. package/dist/i18n/nl.d.ts +246 -1
  49. package/dist/i18n/pa.d.ts +246 -1
  50. package/dist/i18n/pl.d.ts +0 -3
  51. package/dist/i18n/ro.d.ts +260 -1
  52. package/dist/i18n/ru.d.ts +0 -3
  53. package/dist/i18n/si.d.ts +246 -1
  54. package/dist/i18n/sk.d.ts +274 -1
  55. package/dist/i18n/sl.d.ts +274 -1
  56. package/dist/i18n/sq.d.ts +246 -1
  57. package/dist/i18n/sr.d.ts +0 -3
  58. package/dist/i18n/sv.d.ts +246 -1
  59. package/dist/i18n/tg.d.ts +0 -3
  60. package/dist/i18n/th.d.ts +0 -3
  61. package/dist/i18n/tk.d.ts +246 -1
  62. package/dist/i18n/tr.d.ts +0 -3
  63. package/dist/i18n/uk.d.ts +274 -1
  64. package/dist/i18n/ur.d.ts +246 -1
  65. package/dist/i18n/uz.d.ts +246 -1
  66. package/dist/i18n/vi.d.ts +246 -1
  67. package/dist/i18n/zh.d.ts +0 -3
  68. package/dist/i18n/zht.d.ts +0 -3
  69. package/dist/icons/catalog.d.ts +16 -0
  70. package/dist/theme/context.d.ts +16 -0
  71. package/package.json +7 -5
  72. package/src/components/document-surface.css +37 -0
  73. package/src/components/document-surface.tsx +6 -0
  74. package/src/components/popover.css +0 -32
  75. package/src/components/preview-controls.css +28 -0
  76. package/src/components/preview-controls.tsx +53 -0
  77. package/src/components/text-field.tsx +1 -1
  78. package/src/context/helper.tsx +4 -3
  79. package/src/context/marked-base.tsx +5 -1
  80. package/src/data-display/keybind/keybind.css +11 -3
  81. package/src/data-display/keybind/keybind.tsx +1 -1
  82. package/src/data-display/line-comment/line-comment.css +91 -0
  83. package/src/data-display/line-comment/line-comment.tsx +199 -95
  84. package/src/data-display/line-comment/quote-check.svg +3 -0
  85. package/src/forms/typeahead/typeahead.tsx +41 -27
  86. package/src/i18n/am.ts +1 -5
  87. package/src/i18n/ar.ts +0 -4
  88. package/src/i18n/az.ts +1 -5
  89. package/src/i18n/bg.ts +0 -4
  90. package/src/i18n/bn.ts +1 -5
  91. package/src/i18n/br.ts +0 -4
  92. package/src/i18n/bs.ts +0 -4
  93. package/src/i18n/ca.ts +1 -5
  94. package/src/i18n/cs.ts +1 -5
  95. package/src/i18n/da.ts +0 -4
  96. package/src/i18n/de.ts +0 -4
  97. package/src/i18n/dv.ts +1 -5
  98. package/src/i18n/dz.ts +1 -5
  99. package/src/i18n/el.ts +1 -5
  100. package/src/i18n/en.ts +11 -5
  101. package/src/i18n/es.ts +0 -4
  102. package/src/i18n/et.ts +1 -5
  103. package/src/i18n/fa.ts +1 -5
  104. package/src/i18n/fi.ts +1 -5
  105. package/src/i18n/fo.ts +1 -5
  106. package/src/i18n/fr.ts +0 -4
  107. package/src/i18n/he.ts +0 -4
  108. package/src/i18n/hi.ts +1 -5
  109. package/src/i18n/hr.ts +1 -5
  110. package/src/i18n/hu.ts +1 -5
  111. package/src/i18n/hy.ts +1 -5
  112. package/src/i18n/id.ts +1 -5
  113. package/src/i18n/is.ts +1 -5
  114. package/src/i18n/it.ts +1 -5
  115. package/src/i18n/ja.ts +0 -4
  116. package/src/i18n/ka.ts +1 -5
  117. package/src/i18n/km.ts +0 -4
  118. package/src/i18n/ko.ts +0 -4
  119. package/src/i18n/lo.ts +0 -4
  120. package/src/i18n/lt.ts +1 -5
  121. package/src/i18n/lv.ts +1 -5
  122. package/src/i18n/mk.ts +0 -4
  123. package/src/i18n/mn.ts +0 -4
  124. package/src/i18n/ms.ts +1 -5
  125. package/src/i18n/my.ts +0 -4
  126. package/src/i18n/ne.ts +1 -5
  127. package/src/i18n/nl.ts +1 -5
  128. package/src/i18n/no.ts +0 -4
  129. package/src/i18n/pa.ts +1 -5
  130. package/src/i18n/pl.ts +0 -4
  131. package/src/i18n/ro.ts +1 -5
  132. package/src/i18n/ru.ts +0 -4
  133. package/src/i18n/si.ts +1 -5
  134. package/src/i18n/sk.ts +1 -5
  135. package/src/i18n/sl.ts +1 -5
  136. package/src/i18n/sq.ts +1 -5
  137. package/src/i18n/sr.ts +0 -4
  138. package/src/i18n/sv.ts +1 -5
  139. package/src/i18n/tg.ts +0 -4
  140. package/src/i18n/th.ts +0 -4
  141. package/src/i18n/tk.ts +1 -5
  142. package/src/i18n/tr.ts +0 -4
  143. package/src/i18n/uk.ts +1 -5
  144. package/src/i18n/ur.ts +1 -5
  145. package/src/i18n/uz.ts +1 -5
  146. package/src/i18n/vi.ts +1 -5
  147. package/src/i18n/zh.ts +0 -3
  148. package/src/i18n/zht.ts +0 -3
  149. package/src/icons/catalog.ts +16 -0
  150. package/src/navigation/menu/menu.css +0 -30
  151. package/src/navigation/tabs/tabs.css +19 -0
  152. package/src/overlays/tooltip/tooltip.tsx +6 -2
@@ -125,6 +125,10 @@
125
125
  }
126
126
 
127
127
  /* --- Editor --- */
128
+ [data-component="line-comment-v2"] [data-slot="line-comment-v2-input"] {
129
+ display: contents;
130
+ }
131
+
128
132
  [data-component="line-comment-v2"][data-variant="editor"] [data-slot="line-comment-v2-shell"] {
129
133
  display: flex;
130
134
  flex-direction: column;
@@ -196,6 +200,93 @@
196
200
  margin-inline-start: auto;
197
201
  }
198
202
 
203
+ [data-component="line-comment-v2"][data-layout="compact"] {
204
+ display: flex;
205
+ max-height: var(--line-comment-max-height, none);
206
+
207
+ [data-slot="line-comment-v2-shell"] {
208
+ flex: 1 1 auto;
209
+ min-width: 0;
210
+ max-height: inherit;
211
+ padding: 12px;
212
+ gap: 10px;
213
+ border-radius: 8px;
214
+ box-shadow: none;
215
+ }
216
+
217
+ [data-slot="line-comment-v2-preview"] {
218
+ width: 100%;
219
+ min-width: 0;
220
+ flex-shrink: 0;
221
+ border-inline-start: 2px solid var(--v2-background-bg-layer-03);
222
+ padding-inline-start: 12px;
223
+ color: var(--v2-text-text-muted);
224
+ font-size: 13px;
225
+ font-weight: 440;
226
+ line-height: var(--line-height-base);
227
+ letter-spacing: -0.04px;
228
+
229
+ > span {
230
+ display: -webkit-box;
231
+ overflow: hidden;
232
+ -webkit-box-orient: vertical;
233
+ -webkit-line-clamp: var(--line-comment-preview-lines, 2);
234
+ overflow-wrap: anywhere;
235
+ }
236
+ }
237
+
238
+ [data-slot="line-comment-v2-input"] {
239
+ display: flex;
240
+ align-items: flex-end;
241
+ gap: 12px;
242
+ width: 100%;
243
+ min-width: 0;
244
+ min-height: var(--line-height-base);
245
+ flex: 1 1 auto;
246
+ }
247
+
248
+ [data-slot="line-comment-v2-field"] {
249
+ flex: 1 1 auto;
250
+ width: auto;
251
+ min-height: 0;
252
+ align-self: stretch;
253
+ }
254
+
255
+ [data-slot="line-comment-v2-textarea"] {
256
+ field-sizing: content;
257
+ height: auto;
258
+ flex: 1 1 auto;
259
+ min-height: var(--line-height-base);
260
+ max-height: 160px;
261
+ overflow-y: auto;
262
+ scrollbar-gutter: stable;
263
+ line-height: var(--line-height-base);
264
+
265
+ &::placeholder {
266
+ color: var(--v2-text-text-faint);
267
+ }
268
+ }
269
+
270
+ [data-slot="line-comment-v2-submit"] {
271
+ position: relative;
272
+ flex-shrink: 0;
273
+
274
+ @media (hover: none) {
275
+ &::after {
276
+ content: "";
277
+ position: absolute;
278
+ inset: -12px;
279
+ }
280
+ }
281
+ }
282
+
283
+ [data-slot="line-comment-v2-submit-icon"] {
284
+ width: 16px;
285
+ height: 16px;
286
+ background: currentColor;
287
+ }
288
+ }
289
+
199
290
  [data-component="line-comment-v2"][data-variant="editor"] [data-slot="line-comment-v2-mention-list"] {
200
291
  display: flex;
201
292
  flex-direction: column;
@@ -1,8 +1,24 @@
1
- import { For, Show, createSignal, onMount, splitProps, type ComponentProps, type JSX } from "solid-js"
1
+ import {
2
+ For,
3
+ Show,
4
+ createEffect,
5
+ createSignal,
6
+ on,
7
+ onCleanup,
8
+ onMount,
9
+ splitProps,
10
+ type ComponentProps,
11
+ type JSX,
12
+ } from "solid-js"
2
13
  import { FileIcon } from "@opencode/ui/file-icon"
3
14
  import { useI18n } from "../../context/i18n"
4
15
  import { useFilteredList } from "../../hooks"
5
16
  import { Button } from "@opencode/ui/button"
17
+ import { Icon } from "@opencode/ui/icon"
18
+ import { IconButton } from "@opencode/ui/icon-button"
19
+ import { Keybind } from "@opencode/ui/keybind"
20
+ import { Tooltip } from "@opencode/ui/tooltip"
21
+ import check from "./quote-check.svg"
6
22
  import "./line-comment.css"
7
23
 
8
24
  /** Horizontal “more” glyph for the display-card overflow control (Figma outline-dots). */
@@ -72,14 +88,16 @@ export interface LineCommentEditorProps extends Omit<ComponentProps<"div">, "chi
72
88
  onInput: (value: string) => void
73
89
  onCancel: () => void
74
90
  onSubmit: (value: string) => void
75
- /** Optional context in the footer, e.g. the page or element being commented on. */
91
+ /** Optional context in the footer, or above the input in the compact variant. */
76
92
  selection?: JSX.Element
93
+ /** Compact layout with a growing input and inline action. */
94
+ variant?: "default" | "compact"
77
95
  placeholder?: string
78
96
  rows?: number
79
97
  cancelLabel?: string
80
98
  submitLabel?: string
81
99
  autofocus?: boolean
82
- /** Submit an empty value too, such as to clear a comment that exists (default: false). */
100
+ /** Submit an empty value too, such as to clear a comment that exists (default: false). Compact empty actions otherwise cancel. */
83
101
  allowEmpty?: boolean
84
102
  mention?: LineCommentEditorMention
85
103
  }
@@ -108,6 +126,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
108
126
  "onCancel",
109
127
  "onSubmit",
110
128
  "selection",
129
+ "variant",
111
130
  "placeholder",
112
131
  "rows",
113
132
  "cancelLabel",
@@ -120,6 +139,12 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
120
139
  ])
121
140
 
122
141
  const canSubmit = () => !!local.allowEmpty || local.value.trim().length > 0
142
+ const compactCancel = () => !canSubmit()
143
+
144
+ const compactLabel = () =>
145
+ compactCancel()
146
+ ? (local.cancelLabel ?? i18n.t("ui.lineComment.cancel"))
147
+ : (local.submitLabel ?? i18n.t("ui.lineComment.submit"))
123
148
 
124
149
  const closeMention = () => {
125
150
  setMentionOpen(false)
@@ -215,124 +240,203 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
215
240
  requestAnimationFrame(() => textareaRef?.focus())
216
241
  })
217
242
 
243
+ onMount(() => {
244
+ if (CSS.supports("field-sizing", "content")) return
245
+
246
+ createEffect(() => {
247
+ const textarea = textareaRef
248
+
249
+ if (local.variant !== "compact" || !textarea) return
250
+
251
+ const resize = () => {
252
+ // Reset before measuring so the field can shrink as well as grow.
253
+ textarea.style.height = "0px"
254
+ textarea.style.height = `${textarea.scrollHeight}px`
255
+ }
256
+
257
+ createEffect(on(() => local.value, resize))
258
+
259
+ let width = 0
260
+
261
+ const observer = new ResizeObserver(([entry]) => {
262
+ if (!entry || entry.contentRect.width === width) return
263
+ width = entry.contentRect.width
264
+ resize()
265
+ })
266
+
267
+ observer.observe(textarea)
268
+ onCleanup(() => {
269
+ observer.disconnect()
270
+ textarea.style.removeProperty("height")
271
+ })
272
+ })
273
+ })
274
+
218
275
  return (
219
276
  <div
220
277
  {...rest}
221
278
  data-component="line-comment-v2"
222
279
  data-variant="editor"
280
+ data-layout={local.variant ?? "default"}
223
281
  classList={{
224
282
  ...local.classList,
225
283
  [local.class ?? ""]: !!local.class,
226
284
  }}
227
285
  >
228
286
  <div data-slot="line-comment-v2-shell">
229
- <div data-slot="line-comment-v2-field">
230
- <textarea
231
- ref={(el) => {
232
- textareaRef = el
233
- }}
234
- data-slot="line-comment-v2-textarea"
235
- aria-label={local.label ?? i18n.t("ui.lineComment.submit")}
236
- dir="auto"
237
- rows={local.rows ?? 4}
238
- placeholder={local.placeholder ?? i18n.t("ui.lineComment.contextPlaceholder")}
239
- value={local.value}
240
- style={{ "unicode-bidi": "plaintext", "text-align": "start" }}
241
- onInput={(e) => {
242
- local.onInput(e.currentTarget.value)
243
- syncMention()
244
- }}
245
- onClick={() => syncMention()}
246
- onSelect={() => syncMention()}
247
- onKeyDown={(e) => {
248
- e.stopPropagation()
249
-
250
- if (e.isComposing || e.keyCode === 229) return
251
-
252
- if (mentionOpen()) {
253
- if (e.key === "Escape") {
254
- e.preventDefault()
255
- closeMention()
256
-
257
- return
287
+ <Show when={local.variant === "compact" && local.selection}>
288
+ {(selection) => <div data-slot="line-comment-v2-preview">{selection()}</div>}
289
+ </Show>
290
+ <div data-slot="line-comment-v2-input">
291
+ <div data-slot="line-comment-v2-field">
292
+ <textarea
293
+ ref={(el) => {
294
+ textareaRef = el
295
+ }}
296
+ data-slot="line-comment-v2-textarea"
297
+ data-scrollable
298
+ aria-label={local.label ?? i18n.t("ui.lineComment.submit")}
299
+ dir="auto"
300
+ rows={local.rows ?? (local.variant === "compact" ? 1 : 4)}
301
+ placeholder={local.placeholder ?? i18n.t("ui.lineComment.contextPlaceholder")}
302
+ value={local.value}
303
+ style={{ "unicode-bidi": "plaintext", "text-align": "start" }}
304
+ onInput={(e) => {
305
+ local.onInput(e.currentTarget.value)
306
+ syncMention()
307
+ }}
308
+ onClick={() => syncMention()}
309
+ onSelect={() => syncMention()}
310
+ onKeyDown={(e) => {
311
+ e.stopPropagation()
312
+
313
+ if (e.isComposing || e.keyCode === 229) return
314
+
315
+ if (mentionOpen()) {
316
+ if (e.key === "Escape") {
317
+ e.preventDefault()
318
+ closeMention()
319
+
320
+ return
321
+ }
322
+
323
+ if (e.key === "Tab") {
324
+ if (mention.flat().length === 0) return
325
+ e.preventDefault()
326
+ selectActiveMention()
327
+
328
+ return
329
+ }
330
+
331
+ const nav = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Enter"
332
+
333
+ const ctrlNav =
334
+ e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && (e.key === "n" || e.key === "p")
335
+
336
+ if ((nav || ctrlNav) && mention.flat().length > 0) {
337
+ mention.onKeyDown(e)
338
+ e.preventDefault()
339
+
340
+ return
341
+ }
258
342
  }
259
343
 
260
- if (e.key === "Tab") {
261
- if (mention.flat().length === 0) return
344
+ if (e.key === "Escape") {
262
345
  e.preventDefault()
263
- selectActiveMention()
346
+ e.currentTarget.blur()
347
+ local.onCancel()
264
348
 
265
349
  return
266
350
  }
267
351
 
268
- const nav = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Enter"
269
- const ctrlNav = e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && (e.key === "n" || e.key === "p")
270
-
271
- if ((nav || ctrlNav) && mention.flat().length > 0) {
272
- mention.onKeyDown(e)
352
+ if (e.key === "Enter" && !e.shiftKey) {
273
353
  e.preventDefault()
274
-
275
- return
354
+ submit()
276
355
  }
356
+ }}
357
+ />
358
+ <Show when={mentionOpen() && mention.flat().length > 0}>
359
+ <div data-slot="line-comment-v2-mention-list">
360
+ <For each={mention.flat().slice(0, 10)}>
361
+ {(item) => {
362
+ const directory = item.path.endsWith("/") ? item.path : pathDirectory(item.path)
363
+ const name = item.path.endsWith("/") ? "" : pathFilename(item.path)
364
+
365
+ return (
366
+ <button
367
+ type="button"
368
+ data-slot="line-comment-v2-mention-item"
369
+ data-active={mention.active() === item.path ? "" : undefined}
370
+ onMouseDown={(event) => event.preventDefault()}
371
+ onMouseEnter={() => mention.setActive(item.path)}
372
+ onClick={() => selectMention(item)}
373
+ >
374
+ <FileIcon node={{ path: item.path, type: "file" }} class="shrink-0 size-4" />
375
+ <div data-slot="line-comment-v2-mention-path">
376
+ <span data-slot="line-comment-v2-mention-dir">{directory}</span>
377
+ <Show when={name}>
378
+ <span data-slot="line-comment-v2-mention-file">{name}</span>
379
+ </Show>
380
+ </div>
381
+ </button>
382
+ )
383
+ }}
384
+ </For>
385
+ </div>
386
+ </Show>
387
+ </div>
388
+ <Show when={local.variant === "compact"}>
389
+ <Tooltip
390
+ value={
391
+ <>
392
+ {compactLabel()} <Keybind keys={[compactCancel() ? "Esc" : "⏎"]} variant="neutral" />
393
+ </>
277
394
  }
278
-
279
- if (e.key === "Escape") {
280
- e.preventDefault()
281
- e.currentTarget.blur()
282
- local.onCancel()
283
-
284
- return
285
- }
286
-
287
- if (e.key === "Enter" && !e.shiftKey) {
288
- e.preventDefault()
289
- submit()
290
- }
291
- }}
292
- />
293
- <Show when={mentionOpen() && mention.flat().length > 0}>
294
- <div data-slot="line-comment-v2-mention-list">
295
- <For each={mention.flat().slice(0, 10)}>
296
- {(item) => {
297
- const directory = item.path.endsWith("/") ? item.path : pathDirectory(item.path)
298
- const name = item.path.endsWith("/") ? "" : pathFilename(item.path)
299
-
300
- return (
301
- <button
302
- type="button"
303
- data-slot="line-comment-v2-mention-item"
304
- data-active={mention.active() === item.path ? "" : undefined}
305
- onMouseDown={(event) => event.preventDefault()}
306
- onMouseEnter={() => mention.setActive(item.path)}
307
- onClick={() => selectMention(item)}
308
- >
309
- <FileIcon node={{ path: item.path, type: "file" }} class="shrink-0 size-4" />
310
- <div data-slot="line-comment-v2-mention-path">
311
- <span data-slot="line-comment-v2-mention-dir">{directory}</span>
312
- <Show when={name}>
313
- <span data-slot="line-comment-v2-mention-file">{name}</span>
314
- </Show>
315
- </div>
316
- </button>
395
+ placement="top"
396
+ >
397
+ <IconButton
398
+ data-slot="line-comment-v2-submit"
399
+ type="button"
400
+ size="small"
401
+ variant={local.value.trim() ? "neutral" : "ghost-muted"}
402
+ icon={
403
+ compactCancel() ? (
404
+ <Icon name="close" />
405
+ ) : (
406
+ <span
407
+ aria-hidden="true"
408
+ data-slot="line-comment-v2-submit-icon"
409
+ style={{ mask: `url("${check}") center / contain no-repeat` }}
410
+ />
317
411
  )
412
+ }
413
+ aria-label={compactLabel()}
414
+ onClick={() => (compactCancel() ? local.onCancel() : submit())}
415
+ onKeyDown={(event) => {
416
+ if (event.key !== "Escape" || event.isComposing) return
417
+ event.preventDefault()
418
+ event.stopPropagation()
419
+ local.onCancel()
318
420
  }}
319
- </For>
320
- </div>
421
+ />
422
+ </Tooltip>
321
423
  </Show>
322
424
  </div>
323
- <div data-slot="line-comment-v2-footer">
324
- <Show when={local.selection}>
325
- {(selection) => <div data-slot="line-comment-v2-footer-meta">{selection()}</div>}
326
- </Show>
327
- <div data-slot="line-comment-v2-footer-actions">
328
- <Button type="button" size="small" variant="ghost" onClick={() => local.onCancel()}>
329
- {local.cancelLabel ?? i18n.t("ui.lineComment.cancel")}
330
- </Button>
331
- <Button type="button" size="small" variant="contrast" disabled={!canSubmit()} onClick={submit}>
332
- {local.submitLabel ?? i18n.t("ui.lineComment.submit")}
333
- </Button>
425
+ <Show when={local.variant !== "compact"}>
426
+ <div data-slot="line-comment-v2-footer">
427
+ <Show when={local.selection}>
428
+ {(selection) => <div data-slot="line-comment-v2-footer-meta">{selection()}</div>}
429
+ </Show>
430
+ <div data-slot="line-comment-v2-footer-actions">
431
+ <Button type="button" size="small" variant="ghost" onClick={() => local.onCancel()}>
432
+ {local.cancelLabel ?? i18n.t("ui.lineComment.cancel")}
433
+ </Button>
434
+ <Button type="button" size="small" variant="contrast" disabled={!canSubmit()} onClick={submit}>
435
+ {local.submitLabel ?? i18n.t("ui.lineComment.submit")}
436
+ </Button>
437
+ </div>
334
438
  </div>
335
- </div>
439
+ </Show>
336
440
  </div>
337
441
  </div>
338
442
  )
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M2.44444 8.22222L6 12.6667L13.5556 3.33333" stroke-linecap="square" stroke="currentColor"/>
3
+ </svg>
@@ -1,5 +1,5 @@
1
1
  import { createResizeObserver } from "@solid-primitives/resize-observer"
2
- import { createEffect, createMemo, For, type JSX, onCleanup, Show } from "solid-js"
2
+ import { createEffect, createMemo, For, type JSX, on, onCleanup, Show } from "solid-js"
3
3
  import { createStore } from "solid-js/store"
4
4
  import { Icon } from "@opencode/ui/icon"
5
5
  import { abort } from "@opencode/util/abort"
@@ -12,6 +12,8 @@ export { createTypeahead } from "./controller"
12
12
  /** A search field over results from `source` that keeps rows on screen while a query is pending. */
13
13
  export function Typeahead<T>(props: {
14
14
  source: (query: string, signal: AbortSignal) => Promise<T[]>
15
+ /** Preloaded opening results, including a failed request that the user can retry. */
16
+ initial?: { items: T[]; failed?: boolean }
15
17
  /** Narrows earlier results while the request for the current query is pending. */
16
18
  match: (item: T, query: string) => boolean
17
19
  key: (item: T) => string
@@ -27,17 +29,23 @@ export function Typeahead<T>(props: {
27
29
  }) {
28
30
  const i18n = useI18n()
29
31
 
30
- const [store, setStore] = createStore<{ query: string; answered?: string; failed?: boolean; loading?: boolean }>({
31
- query: "",
32
- })
32
+ const [store, setStore] = createStore<{
33
+ query: string
34
+ searched: boolean
35
+ answered?: string
36
+ failed?: boolean
37
+ loading?: boolean
38
+ }>({ query: "", searched: false, answered: props.initial ? "" : undefined })
33
39
 
34
40
  const cache = new Map<string, T[]>()
35
- let seen: T[] = []
36
41
  let request: AbortController | undefined
37
42
  let input: HTMLInputElement | undefined
38
43
  onCleanup(() => abort(request))
39
44
 
40
45
  const query = () => store.query.trim()
46
+ // The parent owns the opening list, so a refresh reaches an open panel without remounting the input.
47
+ const opening = () => (query() ? undefined : props.initial)
48
+ const failed = () => (opening() ? opening()?.failed : store.failed)
41
49
  const pending = () => store.loading || store.answered !== query()
42
50
 
43
51
  const search = (query: string) => {
@@ -49,9 +57,7 @@ export function Typeahead<T>(props: {
49
57
  props.source(query, current.signal).then(
50
58
  (items) => {
51
59
  if (current.signal.aborted) return
52
- const keys = new Set(items.map(props.key))
53
60
  cache.set(query, items)
54
- seen = [...items, ...seen.filter((item) => !keys.has(props.key(item)))].slice(0, 500)
55
61
  setStore({ answered: query, failed: false, loading: false })
56
62
  },
57
63
  () => !current.signal.aborted && setStore({ answered: query, failed: true, loading: false }),
@@ -59,27 +65,36 @@ export function Typeahead<T>(props: {
59
65
  }
60
66
 
61
67
  // A cached or empty query answers at once; a typed one waits, and the request it supersedes is aborted.
62
- createEffect(() => {
63
- const next = query()
64
-
65
- if (!next || cache.has(next)) return search(next)
66
- abort(request)
67
- const timer = setTimeout(() => search(next), props.delay)
68
- onCleanup(() => clearTimeout(timer))
69
- })
68
+ createEffect(
69
+ on(
70
+ query,
71
+ (next) => {
72
+ if (!next || cache.has(next)) return search(next)
73
+ abort(request)
74
+ const timer = setTimeout(() => search(next), props.delay)
75
+ onCleanup(() => clearTimeout(timer))
76
+ },
77
+ { defer: !!props.initial },
78
+ ),
79
+ )
70
80
 
71
- // While a query is pending: its cached answer, else earlier rows that match it, else the rows on screen, marked stale.
81
+ // Narrow visible rows while pending; broadening waits for a cached or server answer, avoiding speculative rows flashing.
72
82
  const results = createMemo<{ items: T[]; stale: boolean }>((previous) => {
73
83
  const next = query()
84
+ const preloaded = opening()
85
+
86
+ if (preloaded) return { items: preloaded.failed ? [] : preloaded.items, stale: false }
74
87
 
75
88
  if (store.answered === next && store.failed) return { items: [], stale: false }
76
- const cached = cache.get(next) ?? seen.filter((item) => props.match(item, next))
89
+ const cached = cache.get(next) ?? previous?.items.filter((item) => props.match(item, next)) ?? []
77
90
 
78
91
  if (cache.has(next) || cached.length > 0) return { items: cached, stale: false }
79
92
 
80
93
  return { items: previous?.items ?? [], stale: !!previous?.items.length }
81
94
  })
82
95
 
96
+ const animateHeight = () => store.searched && results().items.length > 0
97
+
83
98
  const typeahead = createTypeahead<T>({
84
99
  items: () => results().items,
85
100
  key: (item) => props.key(item),
@@ -119,7 +134,7 @@ export function Typeahead<T>(props: {
119
134
  autocomplete="off"
120
135
  spellcheck={false}
121
136
  class="h-8 min-w-0 flex-1 outline-none placeholder:text-v2-text-text-faint"
122
- onInput={(event) => setStore("query", event.currentTarget.value)}
137
+ onInput={(event) => setStore({ query: event.currentTarget.value, searched: true })}
123
138
  onKeyDown={typeahead.onKeyDown}
124
139
  />
125
140
  <Show when={store.query}>
@@ -137,8 +152,11 @@ export function Typeahead<T>(props: {
137
152
  </button>
138
153
  </Show>
139
154
  </div>
140
- {/* Height follows the results on a critically damped spring (0.3 s, bounce 0); the first measurement snaps. */}
141
- <div class="overflow-hidden transition-[height] duration-[350ms] ease-[linear(0,0.097,0.282,0.466,0.619,0.736,0.821,0.881,0.921,0.949,0.967,0.979,0.986,0.991,1)] motion-reduce:transition-none">
155
+ {/* Initial results and the empty state snap into place; other search resizing animates. */}
156
+ <div
157
+ class="overflow-hidden duration-[200ms] ease-[cubic-bezier(0.645,0.045,0.355,1)] motion-reduce:transition-none"
158
+ classList={{ "transition-[height]": animateHeight(), "transition-none": !animateHeight() }}
159
+ >
142
160
  <div
143
161
  ref={(element) =>
144
162
  createResizeObserver(element, (rect) =>
@@ -146,11 +164,7 @@ export function Typeahead<T>(props: {
146
164
  )
147
165
  }
148
166
  >
149
- <div
150
- id={typeahead.listID}
151
- role="listbox"
152
- class="max-h-56 overflow-y-auto px-1 pb-1 empty:hidden"
153
- >
167
+ <div id={typeahead.listID} role="listbox" class="max-h-56 overflow-y-auto px-1 pb-1 empty:hidden">
154
168
  <For each={results().items}>
155
169
  {(item) => (
156
170
  <div
@@ -178,10 +192,10 @@ export function Typeahead<T>(props: {
178
192
  {/* Stays mounted while a retry or a newer query is pending, so the list never collapses to nothing. */}
179
193
  <Show when={results().items.length === 0}>
180
194
  <div
181
- class="mx-1 mb-1 flex h-7 items-center px-2 text-v2-text-text-faint"
195
+ class="mx-1 flex h-8 items-center px-2 pb-1 text-v2-text-text-faint"
182
196
  classList={{ invisible: store.answered === undefined }}
183
197
  >
184
- <Show when={store.failed} fallback={props.emptyLabel}>
198
+ <Show when={failed()} fallback={props.emptyLabel}>
185
199
  <button
186
200
  type="button"
187
201
  class="-mx-2 flex h-7 flex-1 items-center rounded-sm px-2 text-start text-v2-text-text-base outline-none hover:bg-v2-overlay-simple-overlay-hover focus-visible:bg-v2-overlay-simple-overlay-hover"
package/src/i18n/am.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const dict: Record<string, string> = {
1
+ export const dict = {
2
2
  "ui.sessionReview.title": "የክፍለ ጊዜ ለውጦች",
3
3
  "ui.sessionReview.title.git": "Gitይለውጣል",
4
4
  "ui.sessionReview.title.branch": "ቅርንጫፍ ለውጦች",
@@ -70,10 +70,6 @@ export const dict: Record<string, string> = {
70
70
  "dialog.usageExceeded.freeTier.title": "ነፃ ገደብ ላይ ደርሷል",
71
71
  "dialog.usageExceeded.freeTier.description": "ለምርጥ ክፍት ምንጭ ሞዴሎች ታማኝ መዳረሻ ለማግኘት በወር $10 ለOpenCode Go ይመዝገቡ።",
72
72
  "dialog.usageExceeded.freeTier.actionLabel": "ለደንበኝነት ይመዝገቡ",
73
- "dialog.usageExceeded.accountRateLimit.title": "የሂድ ገደብ ላይ ደርሷል",
74
- "dialog.usageExceeded.accountRateLimit.description":
75
- "የአጠቃቀም ገደብ ላይ ደርሷል። ይህን ሞዴል አሁን መጠቀሙን ለመቀጠል ካለው ቀሪ ሒሳብ መጠቀምን ያንቁ",
76
- "dialog.usageExceeded.accountRateLimit.actionLabel": "ክፍት ቅንብሮች",
77
73
  "ui.sessionTurn.status.delegating": "ሥራን በውክልና መስጠት",
78
74
  "ui.sessionTurn.status.planning": "ቀጣዮቹን ደረጃዎች ማቀድ",
79
75
  "ui.sessionTurn.status.gatheringContext": "ማሰስ",
package/src/i18n/ar.ts CHANGED
@@ -79,10 +79,6 @@ export const dict = {
79
79
  "dialog.usageExceeded.freeTier.description":
80
80
  "اشترك في OpenCode Go مقابل $10/شهر للحصول على وصول موثوق إلى أفضل النماذج مفتوحة المصدر.",
81
81
  "dialog.usageExceeded.freeTier.actionLabel": "اشترك",
82
- "dialog.usageExceeded.accountRateLimit.title": "تم الوصول إلى حد Go",
83
- "dialog.usageExceeded.accountRateLimit.description":
84
- "تم الوصول إلى حد الاستخدام. لمتابعة استخدام هذا النموذج الآن، قم بتفعيل الاستخدام من رصيدك المتاح",
85
- "dialog.usageExceeded.accountRateLimit.actionLabel": "فتح الإعدادات",
86
82
 
87
83
  "ui.sessionTurn.status.delegating": "جارٍ تفويض العمل",
88
84
  "ui.sessionTurn.status.planning": "تخطيط الخطوات التالية",
package/src/i18n/az.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const dict: Record<string, string> = {
1
+ export const dict = {
2
2
  "ui.sessionReview.title": "Sessiya dəyişiklikləri",
3
3
  "ui.sessionReview.title.git": "Git dəyişiklikləri",
4
4
  "ui.sessionReview.title.branch": "Branch dəyişiklikləri",
@@ -71,10 +71,6 @@ export const dict: Record<string, string> = {
71
71
  "dialog.usageExceeded.freeTier.description":
72
72
  "Ayda $10 olan OpenCode Go abunəliyi ilə ən yaxşı açıq mənbəli modellərə etibarlı giriş əldə edin.",
73
73
  "dialog.usageExceeded.freeTier.actionLabel": "Abunə ol",
74
- "dialog.usageExceeded.accountRateLimit.title": "Go limitinə çatdınız",
75
- "dialog.usageExceeded.accountRateLimit.description":
76
- "İstifadə limitinə çatdınız. Bu modeldən indi istifadə etməyə davam etmək üçün mövcud balansınızdan istifadəni aktivləşdirin",
77
- "dialog.usageExceeded.accountRateLimit.actionLabel": "Tənzimləmələri aç",
78
74
  "ui.sessionTurn.status.delegating": "İş həvalə edilir",
79
75
  "ui.sessionTurn.status.planning": "Növbəti addımlar planlanır",
80
76
  "ui.sessionTurn.status.gatheringContext": "Araşdırılır",