@deepseek-ai/dsh-experimental-client-ui-forge 0.2.3-alpha.3 → 0.2.3-alpha.4
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.
- package/README.i18n.yaml +10 -10
- package/README.md +16 -15
- package/README.zh.md +16 -15
- package/lib/client.js +18 -18
- package/lib/client.js.map +1 -1
- package/lib/index.js +67 -18
- package/lib/typert.host.js +89 -45
- package/lib/typert.remote-client.d.ts +7 -7
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +48 -36
- package/lib/types/client/BranchPicker.d.ts.map +1 -1
- package/lib/types/client/BranchPicker.js.map +1 -1
- package/lib/types/client/ChangeRequestCard.d.ts +10 -1
- package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestCard.js.map +1 -1
- package/lib/types/client/ChangeRequestOverview.d.ts +16 -0
- package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestOverview.js.map +1 -1
- package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestsSection.js.map +1 -1
- package/lib/types/client/ChangeStatus.d.ts +41 -0
- package/lib/types/client/ChangeStatus.d.ts.map +1 -0
- package/lib/types/client/ChangeStatus.js.map +1 -0
- package/lib/types/client/ChangedFiles.d.ts.map +1 -1
- package/lib/types/client/ChangedFiles.js.map +1 -1
- package/lib/types/client/ChangesTab.d.ts +23 -8
- package/lib/types/client/ChangesTab.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.js.map +1 -1
- package/lib/types/client/CommitMenu.d.ts +8 -5
- package/lib/types/client/CommitMenu.d.ts.map +1 -1
- package/lib/types/client/CommitMenu.js.map +1 -1
- package/lib/types/client/CopyCommandButton.d.ts +19 -0
- package/lib/types/client/CopyCommandButton.d.ts.map +1 -0
- package/lib/types/client/CopyCommandButton.js.map +1 -0
- package/lib/types/client/DiffFile.d.ts +20 -3
- package/lib/types/client/DiffFile.d.ts.map +1 -1
- package/lib/types/client/DiffFile.js.map +1 -1
- package/lib/types/client/EnvironmentRows.d.ts.map +1 -1
- package/lib/types/client/EnvironmentRows.js.map +1 -1
- package/lib/types/client/FileLabel.d.ts +5 -5
- package/lib/types/client/FileLabel.d.ts.map +1 -1
- package/lib/types/client/FileLabel.js.map +1 -1
- package/lib/types/client/HostSettings.d.ts.map +1 -1
- package/lib/types/client/HostSettings.js.map +1 -1
- package/lib/types/client/LensFilter.d.ts.map +1 -1
- package/lib/types/client/LensFilter.js.map +1 -1
- package/lib/types/client/ReviewComposer.d.ts.map +1 -1
- package/lib/types/client/ReviewComposer.js.map +1 -1
- package/lib/types/client/ReviewControls.d.ts.map +1 -1
- package/lib/types/client/ReviewControls.js.map +1 -1
- package/lib/types/client/ReviewThread.d.ts.map +1 -1
- package/lib/types/client/ReviewThread.js.map +1 -1
- package/lib/types/client/ReviewThreads.d.ts +17 -2
- package/lib/types/client/ReviewThreads.d.ts.map +1 -1
- package/lib/types/client/ReviewThreads.js.map +1 -1
- package/lib/types/client/SubmitReview.d.ts.map +1 -1
- package/lib/types/client/SubmitReview.js.map +1 -1
- package/lib/types/client/ThreadList.d.ts.map +1 -1
- package/lib/types/client/ThreadList.js.map +1 -1
- package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
- package/lib/types/client/ViewOptionsMenu.js.map +1 -1
- package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -1
- package/lib/types/client/WorktreeNameDialog.js.map +1 -1
- package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
- package/lib/types/client/WorktreeProgress.js.map +1 -1
- package/lib/types/client/WorktreeSettings.d.ts.map +1 -1
- package/lib/types/client/WorktreeSettings.js.map +1 -1
- package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
- package/lib/types/client/WorktreeToggle.js.map +1 -1
- package/lib/types/client/changes-store.d.ts +7 -4
- package/lib/types/client/changes-store.d.ts.map +1 -1
- package/lib/types/client/changes-store.js.map +1 -1
- package/lib/types/client/glyphs.d.ts +14 -1
- package/lib/types/client/glyphs.d.ts.map +1 -1
- package/lib/types/client/glyphs.js.map +1 -1
- package/lib/types/client/index.d.ts +1 -2
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/locales.d.ts +5 -4
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js.map +1 -1
- package/lib/types/client/minute-clock.d.ts +7 -0
- package/lib/types/client/minute-clock.d.ts.map +1 -0
- package/lib/types/client/minute-clock.js.map +1 -0
- package/lib/types/client/mount.d.ts.map +1 -1
- package/lib/types/client/mount.js.map +1 -1
- package/lib/types/client/review-page/ReviewActivity.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewActivity.js.map +1 -1
- package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewChat.js.map +1 -1
- package/lib/types/client/review-page/ReviewDetail.d.ts +4 -1
- package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewDetail.js.map +1 -1
- package/lib/types/client/review-page/ReviewList.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewList.js.map +1 -1
- package/lib/types/client/review-page/ReviewPage.d.ts +2 -2
- package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewPage.js.map +1 -1
- package/lib/types/client/review-page/ReviewStatus.d.ts +17 -13
- package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewStatus.js.map +1 -1
- package/lib/types/client/review-page/review-store.d.ts +1 -1
- package/lib/types/client/review-threads.d.ts +14 -7
- package/lib/types/client/review-threads.d.ts.map +1 -1
- package/lib/types/client/review-threads.js.map +1 -1
- package/lib/types/client/status.d.ts +0 -6
- package/lib/types/client/status.d.ts.map +1 -1
- package/lib/types/client/status.js.map +1 -1
- package/lib/types/client/thread-state.d.ts +2 -2
- package/lib/types/client/thread-state.d.ts.map +1 -1
- package/lib/types/client/thread-state.js.map +1 -1
- package/lib/types/client/toolbar-fold.d.ts +16 -6
- package/lib/types/client/toolbar-fold.d.ts.map +1 -1
- package/lib/types/client/toolbar-fold.js.map +1 -1
- package/lib/types/index.d.ts +25 -12
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/panel.js.map +1 -1
- package/lib/types/types.d.ts +22 -5
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/worktree.js.map +1 -1
- package/package.json +60 -58
- package/src/client/BaseMenu.module.css +6 -3
- package/src/client/BranchPicker.tsx +28 -19
- package/src/client/ChangeRequestCard.tsx +71 -41
- package/src/client/ChangeRequestOverview.tsx +174 -74
- package/src/client/ChangeRequestsSection.tsx +33 -8
- package/src/client/ChangeStatus.module.css +70 -0
- package/src/client/ChangeStatus.tsx +104 -0
- package/src/client/ChangedFiles.tsx +20 -7
- package/src/client/ChangesTab.module.css +89 -20
- package/src/client/ChangesTab.tsx +332 -134
- package/src/client/CommitMenu.tsx +77 -38
- package/src/client/CopyCommandButton.tsx +25 -0
- package/src/client/DiffFile.tsx +83 -21
- package/src/client/EnvironmentRows.tsx +13 -11
- package/src/client/FileLabel.module.css +16 -18
- package/src/client/FileLabel.tsx +15 -31
- package/src/client/Forge.module.css +3 -10
- package/src/client/HostSettings.tsx +10 -8
- package/src/client/LensFilter.tsx +11 -9
- package/src/client/ReviewComposer.tsx +29 -17
- package/src/client/ReviewControls.tsx +8 -6
- package/src/client/ReviewThread.tsx +63 -21
- package/src/client/ReviewThreads.tsx +126 -34
- package/src/client/SubmitReview.tsx +5 -3
- package/src/client/ThreadList.module.css +4 -3
- package/src/client/ThreadList.tsx +5 -5
- package/src/client/ViewOptionsMenu.tsx +10 -8
- package/src/client/WorktreeNameDialog.tsx +15 -11
- package/src/client/WorktreeProgress.tsx +11 -9
- package/src/client/WorktreeSettings.tsx +4 -3
- package/src/client/WorktreeToggle.tsx +65 -35
- package/src/client/changes-store.ts +8 -5
- package/src/client/glyphs.tsx +23 -1
- package/src/client/index.ts +1 -2
- package/src/client/locales.ts +40 -32
- package/src/client/minute-clock.ts +19 -0
- package/src/client/mount.ts +66 -51
- package/src/client/review-page/ReviewActivity.tsx +5 -4
- package/src/client/review-page/ReviewChat.tsx +46 -17
- package/src/client/review-page/ReviewDetail.tsx +62 -31
- package/src/client/review-page/ReviewList.tsx +23 -18
- package/src/client/review-page/ReviewPage.module.css +81 -10
- package/src/client/review-page/ReviewPage.tsx +43 -35
- package/src/client/review-page/ReviewStatus.tsx +64 -39
- package/src/client/review-threads.ts +23 -11
- package/src/client/status.ts +0 -9
- package/src/client/thread-state.ts +8 -7
- package/src/client/toolbar-fold.ts +59 -14
- package/src/index.ts +78 -20
- package/src/panel.ts +1 -1
- package/src/types.ts +24 -5
- package/src/worktree.ts +1 -1
- package/lib/types/client/AttentionIndicator.d.ts +0 -22
- package/lib/types/client/AttentionIndicator.d.ts.map +0 -1
- package/lib/types/client/AttentionIndicator.js.map +0 -1
- package/src/client/AttentionIndicator.tsx +0 -37
|
@@ -75,6 +75,12 @@ export interface LineThread {
|
|
|
75
75
|
readonly place: Extract<ThreadPlace, { readonly kind: 'line' }>
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/** A host thread shown in its file's outdated section. */
|
|
79
|
+
export interface OutdatedThread {
|
|
80
|
+
readonly thread: ForgeReviewThread
|
|
81
|
+
readonly place: Extract<ThreadPlace, { readonly kind: 'outdated' }>
|
|
82
|
+
}
|
|
83
|
+
|
|
78
84
|
/** Host threads of one file and the actions their cards share. */
|
|
79
85
|
export interface FileThreads {
|
|
80
86
|
/** Threads on lines, which follow the row of their last line. */
|
|
@@ -82,18 +88,27 @@ export interface FileThreads {
|
|
|
82
88
|
/** Threads on the whole file, shown above its lines. */
|
|
83
89
|
readonly file: readonly ForgeReviewThread[]
|
|
84
90
|
/** Threads no longer on the head's lines, shown after them. */
|
|
85
|
-
readonly outdated: readonly
|
|
91
|
+
readonly outdated: readonly OutdatedThread[]
|
|
86
92
|
/** Unresolved threads of the file in every place, including threads the chosen commits do not show. */
|
|
87
93
|
readonly unresolved: number
|
|
88
94
|
/** Reads, actions, and identities shared by the cards. */
|
|
89
95
|
readonly actions: ThreadActions
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
/** The commit a thread was written on, abbreviated, or null
|
|
98
|
+
/** The commit a thread was written on, abbreviated, or null when the code host recorded none. */
|
|
93
99
|
function writtenOn(thread: ForgeReviewThread): string | null {
|
|
94
100
|
return thread.original === null ? null : thread.original.commit.slice(0, 7)
|
|
95
101
|
}
|
|
96
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Render the tag of an outdated thread: lost when no view can show the lines it was written on, else outdated.
|
|
105
|
+
* @param props - whether the thread is lost, and copy.
|
|
106
|
+
* @returns the tag.
|
|
107
|
+
*/
|
|
108
|
+
export function OutdatedTag({ lost, t }: PropsLocale<typeof NS> & { readonly lost: boolean }): ReactNode {
|
|
109
|
+
return <Tag tone={lost ? 'neutral' : 'warning'}>{t(lost ? 'thread.lostTag' : 'thread.outdatedTag')}</Tag>
|
|
110
|
+
}
|
|
111
|
+
|
|
97
112
|
/**
|
|
98
113
|
* Build the Markdown chrome copy of comment bodies.
|
|
99
114
|
* @param t - forge panel copy.
|
|
@@ -185,8 +200,13 @@ export function CardMenu({ label, items, select, disabled = false }: {
|
|
|
185
200
|
readonly disabled?: boolean
|
|
186
201
|
}): ReactNode {
|
|
187
202
|
const [open, setOpen] = useState(false)
|
|
188
|
-
|
|
189
|
-
|
|
203
|
+
const close = useCallback((): void => { setOpen(false) }, [])
|
|
204
|
+
const choose = useCallback((id: string): void => {
|
|
205
|
+
setOpen(false)
|
|
206
|
+
select(id)
|
|
207
|
+
}, [select])
|
|
208
|
+
return <Menu open={open && !disabled} portal dense align="end" autoFocus onClose={close} items={items}
|
|
209
|
+
onSelect={choose}
|
|
190
210
|
anchor={<span className={css.menuAnchor}><Tooltip label={label} side="bottom" delayMs={500}>
|
|
191
211
|
<button type="button" className={css.icon} disabled={disabled} aria-label={label} aria-haspopup="menu" aria-expanded={open && !disabled}
|
|
192
212
|
onClick={() => { setOpen(value => !value) }}><IconEllipsisOutlineRegular size={14} /></button>
|
|
@@ -217,6 +237,20 @@ export function DeleteConfirm({ question, confirmLabel, disabled, error, cancel,
|
|
|
217
237
|
/** Tells the card which of its forms hold text the reader is writing, so it does not fold them away. */
|
|
218
238
|
type Drafting = (form: string, active: boolean) => void
|
|
219
239
|
|
|
240
|
+
/** The button that saves the text of a comment being edited, disabled until it differs from the stored one. */
|
|
241
|
+
function SaveEdit({ text, blank, busy, stored, save, t }: PropsLocale<typeof NS> & {
|
|
242
|
+
readonly text: string
|
|
243
|
+
readonly blank: boolean
|
|
244
|
+
readonly busy: boolean
|
|
245
|
+
readonly stored: string
|
|
246
|
+
readonly save: (text: string) => void
|
|
247
|
+
}) {
|
|
248
|
+
const submit = useCallback((): void => { save(text) }, [save, text])
|
|
249
|
+
return <Button size="sm" variant="primary" disabled={busy || blank || text === stored} onClick={submit}>
|
|
250
|
+
{t(busy ? 'thread.saving' : 'thread.save')}
|
|
251
|
+
</Button>
|
|
252
|
+
}
|
|
253
|
+
|
|
220
254
|
function Comment({ comment, last, actions, labels, now, drafting, t }: {
|
|
221
255
|
readonly comment: ForgeReviewComment
|
|
222
256
|
readonly drafting: Drafting
|
|
@@ -238,9 +272,15 @@ function Comment({ comment, last, actions, labels, now, drafting, t }: {
|
|
|
238
272
|
const editable = writes !== null && comment.viewerCanEdit
|
|
239
273
|
const deletable = writes !== null && comment.viewerCanDelete
|
|
240
274
|
const menuLabel = t('thread.commentActions', { author: login ?? t('thread.deletedAuthor') })
|
|
241
|
-
const send = async (write: ThreadWrite): Promise<void> => {
|
|
275
|
+
const send = useCallback(async (write: ThreadWrite): Promise<void> => {
|
|
242
276
|
if (writes !== null && await writing.run(() => writes.write(write))) setMode('view')
|
|
243
|
-
}
|
|
277
|
+
}, [writes, writing])
|
|
278
|
+
const selectMode = useCallback((id: string): void => { setMode(id === 'edit' ? 'edit' : 'delete') }, [])
|
|
279
|
+
const cancelDelete = useCallback((): void => { setMode('view') }, [])
|
|
280
|
+
const confirmDelete = useCallback((): void => { void send({ kind: 'delete-comment', comment: comment.id }) }, [comment.id, send])
|
|
281
|
+
const saveEdit = useCallback((text: string): void => {
|
|
282
|
+
void send({ kind: 'edit-comment', comment: comment.id, body: text })
|
|
283
|
+
}, [comment.id, send])
|
|
244
284
|
return <div className={css.comment} data-forge-thread-comment={comment.id}>
|
|
245
285
|
<Avatar author={comment.author} />
|
|
246
286
|
<div className={css.commentMain}>
|
|
@@ -254,27 +294,70 @@ function Comment({ comment, last, actions, labels, now, drafting, t }: {
|
|
|
254
294
|
{comment.pending && <Tag tone="warning">{t('review.pending')}</Tag>}
|
|
255
295
|
{(editable || deletable) && mode === 'view' && <>
|
|
256
296
|
<span className={css.spacer} />
|
|
257
|
-
<CardMenu label={menuLabel} select={
|
|
297
|
+
<CardMenu label={menuLabel} select={selectMode}
|
|
258
298
|
items={[...editable ? [{ id: 'edit', label: t('review.edit') }] : [], ...deletable ? [{ id: 'delete', label: t('review.remove') }] : []]} />
|
|
259
299
|
</>}
|
|
260
300
|
</div>
|
|
261
301
|
{mode === 'edit'
|
|
262
302
|
? <TextForm label={t('thread.editAria')} initial={comment.body} busy={writing.busy} error={writing.error}
|
|
263
303
|
cancel={{ label: t('review.cancel'), run: () => { setMode('view') } }}>
|
|
264
|
-
{(text, blank) => <
|
|
265
|
-
onClick={() => { void send({ kind: 'edit-comment', comment: comment.id, body: text }) }}>
|
|
266
|
-
{t(writing.busy ? 'thread.saving' : 'thread.save')}
|
|
267
|
-
</Button>}
|
|
304
|
+
{(text, blank) => <SaveEdit text={text} blank={blank} busy={writing.busy} stored={comment.body} save={saveEdit} t={t} />}
|
|
268
305
|
</TextForm>
|
|
269
306
|
// Raw HTML renders nothing, as GitHub hides comments and unknown tags, and never enters the DOM.
|
|
270
307
|
: <div className={css.body}><MarkdownText text={comment.body} labels={labels} variant="body" omitHtml /></div>}
|
|
271
308
|
{mode === 'delete' && <DeleteConfirm question={t(last ? 'thread.deleteLast' : 'thread.deleteConfirm')}
|
|
272
309
|
confirmLabel={t(writing.busy ? 'thread.deleting' : 'review.remove')} disabled={writing.busy} error={writing.error}
|
|
273
|
-
cancel={
|
|
310
|
+
cancel={cancelDelete} confirm={confirmDelete} t={t} />}
|
|
274
311
|
</div>
|
|
275
312
|
</div>
|
|
276
313
|
}
|
|
277
314
|
|
|
315
|
+
/** The reply action while a review is pending: it adds the reply to that review. */
|
|
316
|
+
function QueueReply({ busy, blank, queue, t }: {
|
|
317
|
+
readonly busy: boolean
|
|
318
|
+
readonly blank: boolean
|
|
319
|
+
readonly queue: () => void
|
|
320
|
+
readonly t: Translate
|
|
321
|
+
}) {
|
|
322
|
+
return (
|
|
323
|
+
<Button size="sm" variant="primary" disabled={busy || blank} onClick={queue}>
|
|
324
|
+
{t(busy ? 'review.publishing' : 'review.queue')}
|
|
325
|
+
</Button>
|
|
326
|
+
)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** The reply action without a pending review: it replies at once, and its menu starts a review with the reply. */
|
|
330
|
+
function ReplyNow({ busy, blank, canReview, reply, queue, t }: {
|
|
331
|
+
readonly busy: boolean
|
|
332
|
+
readonly blank: boolean
|
|
333
|
+
readonly canReview: boolean
|
|
334
|
+
readonly reply: () => void
|
|
335
|
+
readonly queue: () => void
|
|
336
|
+
readonly t: Translate
|
|
337
|
+
}) {
|
|
338
|
+
return (
|
|
339
|
+
<SplitAction disabled={busy || blank} label={t(busy ? 'review.publishing' : 'thread.reply')}
|
|
340
|
+
run={reply} menuLabel={t('thread.replyActions')}
|
|
341
|
+
other={canReview ? t('review.startReview') : undefined} menu={queue} />
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** The sending actions of a reply: queue it into the pending review, or reply at once with an option to start one. */
|
|
346
|
+
function ReplyActions({ text, blank, busy, reviewStarted, canReview, send, t }: PropsLocale<typeof NS> & {
|
|
347
|
+
readonly text: string
|
|
348
|
+
readonly blank: boolean
|
|
349
|
+
readonly busy: boolean
|
|
350
|
+
readonly reviewStarted: boolean
|
|
351
|
+
readonly canReview: boolean
|
|
352
|
+
readonly send: (text: string, pending: boolean) => Promise<void>
|
|
353
|
+
}) {
|
|
354
|
+
const queue = useCallback((): void => { void send(text, true) }, [send, text])
|
|
355
|
+
const reply = useCallback((): void => { void send(text, false) }, [send, text])
|
|
356
|
+
return reviewStarted
|
|
357
|
+
? <QueueReply busy={busy} blank={blank} queue={queue} t={t} />
|
|
358
|
+
: <ReplyNow busy={busy} blank={blank} canReview={canReview} reply={reply} queue={queue} t={t} />
|
|
359
|
+
}
|
|
360
|
+
|
|
278
361
|
/**
|
|
279
362
|
* The reply field of a thread. Without a pending review it replies at once, and its menu starts one with the reply; with
|
|
280
363
|
* one, it adds the reply to it, since GitHub adds every reply of the user to the pending review.
|
|
@@ -290,21 +373,16 @@ function Reply({ thread, writes, drafting, t }: PropsLocale<typeof NS> & {
|
|
|
290
373
|
return () => { drafting('reply', false) }
|
|
291
374
|
}, [drafting, open])
|
|
292
375
|
const writing = useWriting(t)
|
|
376
|
+
const send = useCallback(async (text: string, pending: boolean): Promise<void> => {
|
|
377
|
+
if (await writing.run(() => writes.write({ kind: 'reply', thread: thread.id, body: text, pending }))) setOpen(false)
|
|
378
|
+
}, [thread.id, writes, writing])
|
|
293
379
|
if (!open) {
|
|
294
380
|
return <button type="button" className={css.replyPrompt} onClick={() => { setOpen(true) }}>{t('thread.replyPlaceholder')}</button>
|
|
295
381
|
}
|
|
296
|
-
const send = async (text: string, pending: boolean): Promise<void> => {
|
|
297
|
-
if (await writing.run(() => writes.write({ kind: 'reply', thread: thread.id, body: text, pending }))) setOpen(false)
|
|
298
|
-
}
|
|
299
382
|
return <TextForm label={t('thread.replyPlaceholder')} initial="" busy={writing.busy} error={writing.error}
|
|
300
383
|
cancel={{ label: t('review.cancel'), run: () => { setOpen(false) } }}>
|
|
301
|
-
{(text, blank) => writes.reviewStarted
|
|
302
|
-
|
|
303
|
-
{t(writing.busy ? 'review.publishing' : 'review.queue')}
|
|
304
|
-
</Button>
|
|
305
|
-
: <SplitAction disabled={writing.busy || blank} label={t(writing.busy ? 'review.publishing' : 'thread.reply')}
|
|
306
|
-
run={() => { void send(text, false) }} menuLabel={t('thread.replyActions')}
|
|
307
|
-
other={writes.canReview ? t('review.startReview') : undefined} menu={() => { void send(text, true) }} />}
|
|
384
|
+
{(text, blank) => <ReplyActions text={text} blank={blank} busy={writing.busy} reviewStarted={writes.reviewStarted}
|
|
385
|
+
canReview={writes.canReview} send={send} t={t} />}
|
|
308
386
|
</TextForm>
|
|
309
387
|
}
|
|
310
388
|
|
|
@@ -314,9 +392,12 @@ function Resolution({ thread, writes, t }: PropsLocale<typeof NS> & {
|
|
|
314
392
|
readonly writes: ThreadWrites
|
|
315
393
|
}): ReactNode {
|
|
316
394
|
const writing = useWriting(t)
|
|
395
|
+
const resolve = useCallback((): void => {
|
|
396
|
+
void writing.run(() => writes.write({ kind: 'resolve', thread: thread.id, resolved: !thread.resolved }))
|
|
397
|
+
}, [thread.id, thread.resolved, writes, writing])
|
|
317
398
|
return <>
|
|
318
399
|
<Button size="sm" disabled={writing.busy}
|
|
319
|
-
onClick={
|
|
400
|
+
onClick={resolve}>
|
|
320
401
|
{t(thread.resolved ? 'thread.unresolve' : 'thread.resolve')}
|
|
321
402
|
</Button>
|
|
322
403
|
{writing.error !== null && <div className={clsx(composerCss.error, css.actionError)} role="alert">{writing.error}</div>}
|
|
@@ -354,12 +435,21 @@ export function ThreadCard({ thread, place, actions, t }: PropsLocale<typeof NS>
|
|
|
354
435
|
const unfolded = open || !thread.resolved || focused || drafts.size > 0
|
|
355
436
|
const side = place.kind === 'line' ? place.side : thread.side
|
|
356
437
|
const original = place.kind === 'outdated' && thread.original !== null ? thread.original : null
|
|
438
|
+
// The file at a commit the code host no longer has cannot be read.
|
|
439
|
+
const lost = place.kind === 'outdated' && place.lost
|
|
357
440
|
// The composer names an outdated thread by the lines it was written on, as its label does.
|
|
358
441
|
const range = place.kind === 'line' ? anchorRange(place.side, place) : original !== null ? anchorRange(thread.side, original) : null
|
|
359
442
|
const commit = writtenOn(thread)
|
|
360
443
|
const first = thread.comments[0]
|
|
361
444
|
const url = first?.url ?? null
|
|
362
445
|
const writes = actions.writes
|
|
446
|
+
const quoteThread = useCallback((): void => {
|
|
447
|
+
settleQuote(actions.addToInput(thread, range), (accepted) => { if (!accepted) actions.inputFailed() })
|
|
448
|
+
}, [actions, range, thread])
|
|
449
|
+
const openOnHost = useCallback((): void => {
|
|
450
|
+
/* v8 ignore next -- the control renders only once the thread has a link */
|
|
451
|
+
if (url !== null) actions.openLink(url)
|
|
452
|
+
}, [actions, url])
|
|
363
453
|
if (!unfolded) {
|
|
364
454
|
return <div className={css.folded} data-forge-thread={thread.id} data-side={side}>
|
|
365
455
|
<IconCheckOutlineRegular size={14} />
|
|
@@ -367,22 +457,24 @@ export function ThreadCard({ thread, place, actions, t }: PropsLocale<typeof NS>
|
|
|
367
457
|
<button type="button" className={css.link} aria-expanded={false} onClick={() => { setOpen(true) }}>{t('thread.expand')}</button>
|
|
368
458
|
</div>
|
|
369
459
|
}
|
|
370
|
-
|
|
460
|
+
// A line thread the code host recorded no commit for has no lines to name; its tag alone heads the card.
|
|
461
|
+
const unplaced = thread.subject === 'file' ? t('thread.fileLevel') : null
|
|
462
|
+
const label = original !== null ? t('thread.originally', { range: anchorRange(thread.side, original) }) : range ?? unplaced
|
|
371
463
|
return <section className={css.card} data-forge-thread={thread.id} data-side={side}
|
|
372
|
-
data-resolved={thread.resolved ? '' : undefined} aria-label={label} tabIndex={-1}>
|
|
464
|
+
data-resolved={thread.resolved ? '' : undefined} aria-label={label ?? t('thread.lostTag')} tabIndex={-1}>
|
|
373
465
|
<div className={css.header}>
|
|
374
|
-
<span className={css.place}>
|
|
466
|
+
{label !== null && <span className={css.place}>
|
|
375
467
|
{label}
|
|
376
468
|
{commit !== null && <> · {t('thread.onCommit', { commit })}</>}
|
|
377
|
-
</span>
|
|
378
|
-
{place.kind === 'outdated' && <
|
|
469
|
+
</span>}
|
|
470
|
+
{place.kind === 'outdated' && <OutdatedTag lost={place.lost} t={t} />}
|
|
379
471
|
{thread.resolved && <Tag tone="success">{t('thread.filter.resolved')}</Tag>}
|
|
380
472
|
<span className={css.spacer} />
|
|
381
473
|
{thread.resolved && <button type="button" className={css.link} aria-expanded onClick={() => {
|
|
382
474
|
setOpen(false)
|
|
383
475
|
setFoldedAt(actions.focused?.revision ?? null)
|
|
384
476
|
}}>{t('thread.collapse')}</button>}
|
|
385
|
-
{original !== null && thread.side === 'R' && <OriginalFile thread={thread} commit={original.commit} actions={actions} t={t} />}
|
|
477
|
+
{original !== null && thread.side === 'R' && !lost && <OriginalFile thread={thread} commit={original.commit} actions={actions} t={t} />}
|
|
386
478
|
</div>
|
|
387
479
|
{place.kind === 'outdated' && thread.diffHunk !== null && original !== null
|
|
388
480
|
&& <Excerpt hunk={thread.diffHunk} side={thread.side} lines={original.endLine - original.startLine + 1} />}
|
|
@@ -392,10 +484,10 @@ export function ThreadCard({ thread, place, actions, t }: PropsLocale<typeof NS>
|
|
|
392
484
|
</div>
|
|
393
485
|
{writes !== null && thread.viewerCanReply && <Reply thread={thread} writes={writes} drafting={drafting} t={t} />}
|
|
394
486
|
<div className={css.actions}>
|
|
395
|
-
<Button size="sm" onClick={
|
|
487
|
+
<Button size="sm" onClick={quoteThread}>
|
|
396
488
|
{t((actions.quoteCopy ?? INPUT_QUOTE_COPY).add)}
|
|
397
489
|
</Button>
|
|
398
|
-
{url !== null && <Button size="sm" onClick={
|
|
490
|
+
{url !== null && <Button size="sm" onClick={openOnHost}>
|
|
399
491
|
<ForgeGlyph forge={actions.forge} />{t('thread.openOnHost')}
|
|
400
492
|
</Button>}
|
|
401
493
|
{writes !== null && thread.viewerCanResolve && <Resolution thread={thread} writes={writes} t={t} />}
|
|
@@ -459,14 +551,14 @@ function OriginalFile({ thread, commit, actions, t }: PropsLocale<typeof NS> & {
|
|
|
459
551
|
* @returns the section, or nothing without outdated threads.
|
|
460
552
|
*/
|
|
461
553
|
export function OutdatedThreads({ threads, actions, t }: PropsLocale<typeof NS> & {
|
|
462
|
-
readonly threads: readonly
|
|
554
|
+
readonly threads: readonly OutdatedThread[]
|
|
463
555
|
readonly actions: ThreadActions
|
|
464
556
|
}): ReactNode {
|
|
465
557
|
// The section is folded after the jump with this revision, or -1 before any jump, or null while unfolded.
|
|
466
558
|
const [folded, setFolded] = useState<number | null>(null)
|
|
467
559
|
if (threads.length === 0) return null
|
|
468
560
|
const jump = actions.focused
|
|
469
|
-
const open = folded === null || (jump !== null && jump.revision !== folded && threads.some(thread => thread.id === jump.id))
|
|
561
|
+
const open = folded === null || (jump !== null && jump.revision !== folded && threads.some(({ thread }) => thread.id === jump.id))
|
|
470
562
|
return <section className={css.outdated} data-forge-outdated-threads="">
|
|
471
563
|
<div className={css.outdatedHeader}>
|
|
472
564
|
<span>{t('thread.outdatedSection', { count: threads.length })}</span>
|
|
@@ -476,6 +568,6 @@ export function OutdatedThreads({ threads, actions, t }: PropsLocale<typeof NS>
|
|
|
476
568
|
<IconChevronDownOutlineRegular size={12} className={clsx(!open && css.turned)} />
|
|
477
569
|
</button>
|
|
478
570
|
</div>
|
|
479
|
-
{open && threads.map(thread => <ThreadCard key={thread.id} thread={thread} place={
|
|
571
|
+
{open && threads.map(({ thread, place }) => <ThreadCard key={thread.id} thread={thread} place={place} actions={actions} t={t} />)}
|
|
480
572
|
</section>
|
|
481
573
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Centered review submission with a summary, decision, and pending-comment count, and the discarding of a pending review. */
|
|
2
2
|
|
|
3
|
-
import { useId, useState, useSyncExternalStore, type ReactNode } from 'react'
|
|
3
|
+
import { useCallback, useId, useState, useSyncExternalStore, type ReactNode } from 'react'
|
|
4
4
|
import clsx from 'clsx'
|
|
5
5
|
import { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
6
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
@@ -56,11 +56,13 @@ export function SubmitReview({
|
|
|
56
56
|
|| (state.event === 'comment' && state.body.trim() === '' && count === 0)
|
|
57
57
|
const notice = state.error !== null ? t(state.error === 'load' ? 'review.loadFailed' : 'review.saveFailed')
|
|
58
58
|
: blocked ? t('review.browserDrafts', { count: state.comments.length }) : stale ? t('review.stale') : error
|
|
59
|
+
const startDiscard = useCallback((): void => { setConfirming(true) }, [])
|
|
60
|
+
const cancelDiscard = useCallback((): void => { setConfirming(false) }, [])
|
|
59
61
|
return <Modal open onClose={close} title={t('review.submit')} closeLabel={t('review.close')}
|
|
60
62
|
className={clsx(css.modal)} contentClassName={clsx(css.content)}
|
|
61
63
|
footer={<>
|
|
62
64
|
{discard !== undefined && <Button variant="outline" className={clsx(css.discard)} disabled={locked || confirming}
|
|
63
|
-
onClick={
|
|
65
|
+
onClick={startDiscard}>{t('review.discard')}</Button>}
|
|
64
66
|
<Button variant="outline" onClick={close}>{t('review.cancel')}</Button>
|
|
65
67
|
<Button variant="primary" disabled={locked || confirming || blocked || stale || empty || refused || state.error !== null} onClick={submit}>
|
|
66
68
|
{t(busy && !confirming ? 'review.submitting' : 'review.submit')}
|
|
@@ -70,7 +72,7 @@ export function SubmitReview({
|
|
|
70
72
|
<div className={css.count}>{t('review.drafts', { count })}</div>
|
|
71
73
|
{discard !== undefined && confirming && <div className={css.confirm} role="group" aria-label={t('review.discard')}>
|
|
72
74
|
<span className={css.confirmText}>{t('review.discardConfirm', { count })}</span>
|
|
73
|
-
<Button size="sm" variant="outline" disabled={busy} onClick={
|
|
75
|
+
<Button size="sm" variant="outline" disabled={busy} onClick={cancelDiscard}>{t('review.cancel')}</Button>
|
|
74
76
|
<Button size="sm" variant="primary" disabled={busy} onClick={discard}>{t(busy ? 'review.discarding' : 'review.discard')}</Button>
|
|
75
77
|
</div>}
|
|
76
78
|
<div className={css.summary}>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* The thread list docks at the end of the changes body in a view at least 1040px wide, which leaves the code about
|
|
2
2
|
480px beside the file tree and the list; it floats over the files with a scrim behind it in a narrower view, and
|
|
3
|
-
takes the files' whole width below
|
|
4
|
-
|
|
3
|
+
takes the files' whole width below 760px, where the view shows no file tree and the floating list would cover half
|
|
4
|
+
of the code. The queries name no container, since CSS Modules rename a container name per file; the nearest
|
|
5
|
+
inline-size container is the changes view. */
|
|
5
6
|
.scrim { display: none; }
|
|
6
7
|
|
|
7
8
|
.pane {
|
|
@@ -199,7 +200,7 @@
|
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
@container (max-width:
|
|
203
|
+
@container (max-width: 759px) {
|
|
203
204
|
.scrim { display: none; }
|
|
204
205
|
|
|
205
206
|
.pane {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* a narrower one floats it over them, and the narrowest gives it their whole width.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useLayoutEffect, useMemo, useRef, type KeyboardEvent, type ReactNode } from 'react'
|
|
7
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, type KeyboardEvent, type ReactNode } from 'react'
|
|
8
8
|
import { IconChevronLeftOutlineRegular, IconCloseOutlineRegular, Tag, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
9
9
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
10
10
|
import type { ForgeReviewThread } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
@@ -12,7 +12,7 @@ import type { ForgeDiffFile } from '../types.ts'
|
|
|
12
12
|
import { FileLabel } from './FileLabel.tsx'
|
|
13
13
|
import { ForgeGlyph } from './glyphs.tsx'
|
|
14
14
|
import { SegmentedChoice } from './ReviewControls.tsx'
|
|
15
|
-
import { Avatar } from './ReviewThreads.tsx'
|
|
15
|
+
import { Avatar, OutdatedTag } from './ReviewThreads.tsx'
|
|
16
16
|
import { anchorRange, inFileOrder, passesFilter, THREAD_FILTERS, type ThreadFilter, type ThreadPlace } from './review-threads.ts'
|
|
17
17
|
import type { NS } from './locales.ts'
|
|
18
18
|
import type { PlacedThread } from './thread-state.ts'
|
|
@@ -87,7 +87,7 @@ function Item({ entry, open, t }: {
|
|
|
87
87
|
<span className={css.meta}>{meta(thread, place, t)}</span>
|
|
88
88
|
<span className={css.excerpt}>{plainExcerpt(first?.body ?? '')}</span>
|
|
89
89
|
<span className={css.tags}>
|
|
90
|
-
{place.kind === 'outdated' && <
|
|
90
|
+
{place.kind === 'outdated' && <OutdatedTag lost={place.lost} t={t} />}
|
|
91
91
|
{place.kind === 'elsewhere' && <Tag tone="neutral">{t('thread.elsewhereTag')}</Tag>}
|
|
92
92
|
{thread.resolved && <Tag tone="success">{t('thread.filter.resolved')}</Tag>}
|
|
93
93
|
{first?.author?.bot === true && <Tag tone="outline">{t('thread.bot')}</Tag>}
|
|
@@ -102,7 +102,7 @@ function Item({ entry, open, t }: {
|
|
|
102
102
|
* @returns the list pane and the scrim behind it where it floats over the files.
|
|
103
103
|
*/
|
|
104
104
|
export function ThreadList(props: ThreadListProps): ReactNode {
|
|
105
|
-
const { entries, files, filter, t } = props
|
|
105
|
+
const { entries, files, filter, open: openThread, t } = props
|
|
106
106
|
const threads = useMemo(() => entries.map(entry => entry.thread), [entries])
|
|
107
107
|
const counts = useMemo(() => Object.fromEntries(THREAD_FILTERS.map(item => [item,
|
|
108
108
|
threads.filter(thread => passesFilter(thread, item)).length])) as Record<ThreadFilter, number>, [threads])
|
|
@@ -131,7 +131,7 @@ export function ThreadList(props: ThreadListProps): ReactNode {
|
|
|
131
131
|
event.stopPropagation()
|
|
132
132
|
props.close()
|
|
133
133
|
}
|
|
134
|
-
const open = (entry: PlacedThread): void => {
|
|
134
|
+
const open = useCallback((entry: PlacedThread): void => { openThread(entry, covers(pane.current)) }, [openThread])
|
|
135
135
|
return <>
|
|
136
136
|
<div className={css.scrim} aria-hidden="true" onClick={props.close} />
|
|
137
137
|
<aside ref={pane} className={css.pane} tabIndex={-1} aria-label={t('thread.listAria', { count: threads.length })} data-forge-thread-list=""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The changes toolbar's More menu, which holds the view controls a narrow toolbar folds out of its row. */
|
|
2
2
|
|
|
3
|
-
import { useState, type ReactNode } from 'react'
|
|
3
|
+
import { useCallback, useState, type ReactNode } from 'react'
|
|
4
4
|
import clsx from 'clsx'
|
|
5
5
|
import { IconEllipsisOutlineRegular, Menu, Tooltip, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
6
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
@@ -56,7 +56,7 @@ export function ViewOptionsMenu({ options, visible, t }: PropsLocale<typeof NS>
|
|
|
56
56
|
}
|
|
57
57
|
const selected = [options.split && 'split', options.wrap && 'wrap', options.hideTests === true && 'tests', options.lenses.length > 0 && NO_LENS]
|
|
58
58
|
.filter(item => item !== false)
|
|
59
|
-
const run = (id: string): void => {
|
|
59
|
+
const run = useCallback((id: string): void => {
|
|
60
60
|
const lens = lensOfRow(id)
|
|
61
61
|
if (lens !== undefined) {
|
|
62
62
|
options.chooseLens(lens)
|
|
@@ -71,14 +71,16 @@ export function ViewOptionsMenu({ options, visible, t }: PropsLocale<typeof NS>
|
|
|
71
71
|
/* v8 ignore next -- the menu offers only the rows above */
|
|
72
72
|
default: break
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}, [options])
|
|
75
|
+
const close = useCallback((): void => { setFold(null) }, [])
|
|
76
|
+
const select = useCallback((id: string): void => {
|
|
77
|
+
setFold(null)
|
|
78
|
+
run(id)
|
|
79
|
+
}, [run])
|
|
75
80
|
return (
|
|
76
81
|
<Menu open={open} portal dense align="end" autoFocus items={entries} selectedIds={selected}
|
|
77
|
-
onClose={
|
|
78
|
-
onSelect={
|
|
79
|
-
setFold(null)
|
|
80
|
-
run(id)
|
|
81
|
-
}}
|
|
82
|
+
onClose={close}
|
|
83
|
+
onSelect={select}
|
|
82
84
|
anchor={(
|
|
83
85
|
<Tooltip label={t('diff.moreOptions')} side="bottom" delayMs={500}>
|
|
84
86
|
<button type="button" className={clsx(css.tool, css.more)} aria-label={t('diff.moreOptions')}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Dialog that names the new branch of a requested worktree, from the New Session option or after a failed attempt. */
|
|
2
2
|
|
|
3
|
-
import { useId, useState, type ReactNode } from 'react'
|
|
3
|
+
import { useCallback, useId, useState, type ChangeEvent, type KeyboardEvent, type ReactNode } from 'react'
|
|
4
4
|
import clsx from 'clsx'
|
|
5
5
|
import { Button, Input, Modal } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
6
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
@@ -53,7 +53,7 @@ export function WorktreeNameDialog({ mode, initial, prefix, from, named, submit,
|
|
|
53
53
|
const problem = blank ? null : branchNameProblem(value)
|
|
54
54
|
const error = problem !== null ? t(`branchName.${problem}`) : refusal?.name === value ? refusal.text : null
|
|
55
55
|
const retry = mode === 'retry'
|
|
56
|
-
const send = (name: string | null): void => {
|
|
56
|
+
const send = useCallback((name: string | null): void => {
|
|
57
57
|
setBusy(true)
|
|
58
58
|
void submit(name).then((result) => {
|
|
59
59
|
setBusy(false)
|
|
@@ -61,18 +61,26 @@ export function WorktreeNameDialog({ mode, initial, prefix, from, named, submit,
|
|
|
61
61
|
else if (name !== null && result === 'branch-exists') setRefusal({ name, text: t('branchName.exists', { name }) })
|
|
62
62
|
else if (name !== null && result === 'invalid-name') setRefusal({ name, text: t('branchName.invalid') })
|
|
63
63
|
})
|
|
64
|
-
}
|
|
64
|
+
}, [close, submit, t])
|
|
65
65
|
const confirmable = !busy && error === null && !blank
|
|
66
66
|
const base = from === null ? null : branchLabel(from)
|
|
67
67
|
const hint = blank && prefix !== '' ? t('nameDialog.prefixOnly') : base === null ? t('nameDialog.hintHead') : t('nameDialog.hint', { branch: base })
|
|
68
|
+
const sendGenerated = useCallback((): void => { send(null) }, [send])
|
|
69
|
+
const sendValue = useCallback((): void => { send(value) }, [send, value])
|
|
70
|
+
const changeValue = useCallback((event: ChangeEvent<HTMLInputElement>): void => { setValue(event.target.value) }, [])
|
|
71
|
+
const pressEnter = useCallback((event: KeyboardEvent<HTMLInputElement>): void => {
|
|
72
|
+
if (event.key !== 'Enter' || event.nativeEvent.isComposing) return
|
|
73
|
+
event.preventDefault()
|
|
74
|
+
if (confirmable) send(value)
|
|
75
|
+
}, [confirmable, send, value])
|
|
68
76
|
return (
|
|
69
77
|
<Modal open onClose={close} title={t(retry ? 'nameDialog.retryTitle' : 'nameDialog.title')} closeLabel={t('nameDialog.close')}
|
|
70
78
|
footer={<>
|
|
71
79
|
{named && !retry && (
|
|
72
|
-
<Button variant="outline" className={css.auto} disabled={busy} onClick={
|
|
80
|
+
<Button variant="outline" className={css.auto} disabled={busy} onClick={sendGenerated}>{t('nameDialog.auto')}</Button>
|
|
73
81
|
)}
|
|
74
82
|
<Button variant="outline" onClick={close}>{t('nameDialog.cancel')}</Button>
|
|
75
|
-
<Button variant="primary" disabled={!confirmable} onClick={
|
|
83
|
+
<Button variant="primary" disabled={!confirmable} onClick={sendValue}>
|
|
76
84
|
{t(retry ? 'nameDialog.retry' : 'nameDialog.confirm')}
|
|
77
85
|
</Button>
|
|
78
86
|
</>}>
|
|
@@ -80,12 +88,8 @@ export function WorktreeNameDialog({ mode, initial, prefix, from, named, submit,
|
|
|
80
88
|
<label className={css.label} htmlFor={fieldId}>{t('nameDialog.field')}</label>
|
|
81
89
|
<Input id={fieldId} data-modal-autofocus className={clsx(css.field, error !== null && css.invalid)} value={value}
|
|
82
90
|
spellCheck={false} autoCapitalize="off" autoComplete="off" aria-invalid={error !== null} aria-describedby={messageId}
|
|
83
|
-
onChange={
|
|
84
|
-
onKeyDown={
|
|
85
|
-
if (event.key !== 'Enter' || event.nativeEvent.isComposing) return
|
|
86
|
-
event.preventDefault()
|
|
87
|
-
if (confirmable) send(value)
|
|
88
|
-
}} />
|
|
91
|
+
onChange={changeValue}
|
|
92
|
+
onKeyDown={pressEnter} />
|
|
89
93
|
<p id={messageId} className={clsx(css.message, error !== null && css.error)} role={error === null ? undefined : 'alert'}>{error ?? hint}</p>
|
|
90
94
|
</div>
|
|
91
95
|
</Modal>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* being restored.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useState, type ReactNode } from 'react'
|
|
7
|
+
import { useCallback, useState, type ReactNode } from 'react'
|
|
8
8
|
import {
|
|
9
9
|
Button, IconBranchOutlineRegular, IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconCloseOutlineRegular, StateDot,
|
|
10
10
|
} from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
@@ -202,6 +202,12 @@ function CreationCard({ creation, open: openRequest, prefix, stop, retry, withdr
|
|
|
202
202
|
const title = t(CREATION_TITLE[creation.state])
|
|
203
203
|
const name = openRequest?.name ?? null
|
|
204
204
|
const from = openRequest?.from ?? null
|
|
205
|
+
const requestThenRetry = useCallback(async (next: string | null): Promise<WorktreeRequestResult> => {
|
|
206
|
+
const result = await request(from, next)
|
|
207
|
+
if (result === 'accepted') retry(true)
|
|
208
|
+
return result
|
|
209
|
+
}, [from, request, retry])
|
|
210
|
+
const stopRenaming = useCallback((): void => { setRenaming(false) }, [])
|
|
205
211
|
return (
|
|
206
212
|
<div className={css.dock} data-forge-creation={running ? creation.phase : creation.state}>
|
|
207
213
|
<section className={css.card} aria-label={title} aria-busy={running}>
|
|
@@ -235,12 +241,8 @@ function CreationCard({ creation, open: openRequest, prefix, stop, retry, withdr
|
|
|
235
241
|
</section>
|
|
236
242
|
{renaming && name !== null && (
|
|
237
243
|
<WorktreeNameDialog mode="retry" initial={name} prefix={prefix} from={from} named
|
|
238
|
-
submit={
|
|
239
|
-
|
|
240
|
-
if (result === 'accepted') retry(true)
|
|
241
|
-
return result
|
|
242
|
-
}}
|
|
243
|
-
close={() => { setRenaming(false) }} t={t} />
|
|
244
|
+
submit={requestThenRetry}
|
|
245
|
+
close={stopRenaming} t={t} />
|
|
244
246
|
)}
|
|
245
247
|
</div>
|
|
246
248
|
)
|
|
@@ -259,7 +261,7 @@ function MissingCard({ created, missing, restoration, waiting, restore, leave, t
|
|
|
259
261
|
}): ReactNode {
|
|
260
262
|
const [restoring, setRestoring] = useState(false)
|
|
261
263
|
const [error, setError] = useState<string | null>(null)
|
|
262
|
-
const start = (): void => {
|
|
264
|
+
const start = useCallback((): void => {
|
|
263
265
|
setRestoring(true)
|
|
264
266
|
setError(null)
|
|
265
267
|
void restore().then(
|
|
@@ -272,7 +274,7 @@ function MissingCard({ created, missing, restoration, waiting, restore, leave, t
|
|
|
272
274
|
setError(failure instanceof Error ? failure.message : String(failure))
|
|
273
275
|
},
|
|
274
276
|
)
|
|
275
|
-
}
|
|
277
|
+
}, [restore])
|
|
276
278
|
// The restore this card asked for runs before the Host names its first step.
|
|
277
279
|
const phase = restoration?.phase ?? (restoring ? 'prepare' : null)
|
|
278
280
|
if (phase !== null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The worktree service's row page on the Plugins page: the archive cleanup switch. */
|
|
2
|
-
import { useId } from 'react'
|
|
2
|
+
import { useCallback, useId } from 'react'
|
|
3
3
|
import { SettingsForm, Switch } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
4
4
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
5
5
|
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
|
|
@@ -17,9 +17,10 @@ export type WorktreeSettingsProps = PropsRuntime<'plugins.row.config'> & PropsLo
|
|
|
17
17
|
* @returns the row page's form, or the summary line.
|
|
18
18
|
*/
|
|
19
19
|
export function WorktreeSettings(props: WorktreeSettingsProps) {
|
|
20
|
-
const { t } = props
|
|
20
|
+
const { edit, t } = props
|
|
21
21
|
const id = useId()
|
|
22
22
|
const state = props.useWorktreeForm(value => value)
|
|
23
|
+
const changeRetention = useCallback((next: boolean): void => { edit('retainOnArchive', next ? 'true' : 'false') }, [edit])
|
|
23
24
|
if (props.view === 'summary') return t('settings.retainOnArchive.title')
|
|
24
25
|
const disabled = !state.writable || state.saving
|
|
25
26
|
return <SettingsForm labels={rowFormLabels(t, 'settings.unavailable')} state={state} onSave={props.save} onDiscard={props.discard}>
|
|
@@ -29,7 +30,7 @@ export function WorktreeSettings(props: WorktreeSettingsProps) {
|
|
|
29
30
|
<p className={css.description}>{t('settings.retainOnArchive.description')}</p>
|
|
30
31
|
</div>
|
|
31
32
|
<Switch checked={state.retainOnArchive.text === 'true'} disabled={disabled} label={t('settings.retainOnArchive.title')}
|
|
32
|
-
onChange={
|
|
33
|
+
onChange={changeRetention} />
|
|
33
34
|
</div>
|
|
34
35
|
</SettingsForm>
|
|
35
36
|
}
|