@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.
Files changed (178) hide show
  1. package/README.i18n.yaml +10 -10
  2. package/README.md +16 -15
  3. package/README.zh.md +16 -15
  4. package/lib/client.js +18 -18
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +67 -18
  7. package/lib/typert.host.js +89 -45
  8. package/lib/typert.remote-client.d.ts +7 -7
  9. package/lib/typert.remote-client.d.ts.map +1 -1
  10. package/lib/typert.remote-client.js +48 -36
  11. package/lib/types/client/BranchPicker.d.ts.map +1 -1
  12. package/lib/types/client/BranchPicker.js.map +1 -1
  13. package/lib/types/client/ChangeRequestCard.d.ts +10 -1
  14. package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
  15. package/lib/types/client/ChangeRequestCard.js.map +1 -1
  16. package/lib/types/client/ChangeRequestOverview.d.ts +16 -0
  17. package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
  18. package/lib/types/client/ChangeRequestOverview.js.map +1 -1
  19. package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -1
  20. package/lib/types/client/ChangeRequestsSection.js.map +1 -1
  21. package/lib/types/client/ChangeStatus.d.ts +41 -0
  22. package/lib/types/client/ChangeStatus.d.ts.map +1 -0
  23. package/lib/types/client/ChangeStatus.js.map +1 -0
  24. package/lib/types/client/ChangedFiles.d.ts.map +1 -1
  25. package/lib/types/client/ChangedFiles.js.map +1 -1
  26. package/lib/types/client/ChangesTab.d.ts +23 -8
  27. package/lib/types/client/ChangesTab.d.ts.map +1 -1
  28. package/lib/types/client/ChangesTab.js.map +1 -1
  29. package/lib/types/client/CommitMenu.d.ts +8 -5
  30. package/lib/types/client/CommitMenu.d.ts.map +1 -1
  31. package/lib/types/client/CommitMenu.js.map +1 -1
  32. package/lib/types/client/CopyCommandButton.d.ts +19 -0
  33. package/lib/types/client/CopyCommandButton.d.ts.map +1 -0
  34. package/lib/types/client/CopyCommandButton.js.map +1 -0
  35. package/lib/types/client/DiffFile.d.ts +20 -3
  36. package/lib/types/client/DiffFile.d.ts.map +1 -1
  37. package/lib/types/client/DiffFile.js.map +1 -1
  38. package/lib/types/client/EnvironmentRows.d.ts.map +1 -1
  39. package/lib/types/client/EnvironmentRows.js.map +1 -1
  40. package/lib/types/client/FileLabel.d.ts +5 -5
  41. package/lib/types/client/FileLabel.d.ts.map +1 -1
  42. package/lib/types/client/FileLabel.js.map +1 -1
  43. package/lib/types/client/HostSettings.d.ts.map +1 -1
  44. package/lib/types/client/HostSettings.js.map +1 -1
  45. package/lib/types/client/LensFilter.d.ts.map +1 -1
  46. package/lib/types/client/LensFilter.js.map +1 -1
  47. package/lib/types/client/ReviewComposer.d.ts.map +1 -1
  48. package/lib/types/client/ReviewComposer.js.map +1 -1
  49. package/lib/types/client/ReviewControls.d.ts.map +1 -1
  50. package/lib/types/client/ReviewControls.js.map +1 -1
  51. package/lib/types/client/ReviewThread.d.ts.map +1 -1
  52. package/lib/types/client/ReviewThread.js.map +1 -1
  53. package/lib/types/client/ReviewThreads.d.ts +17 -2
  54. package/lib/types/client/ReviewThreads.d.ts.map +1 -1
  55. package/lib/types/client/ReviewThreads.js.map +1 -1
  56. package/lib/types/client/SubmitReview.d.ts.map +1 -1
  57. package/lib/types/client/SubmitReview.js.map +1 -1
  58. package/lib/types/client/ThreadList.d.ts.map +1 -1
  59. package/lib/types/client/ThreadList.js.map +1 -1
  60. package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
  61. package/lib/types/client/ViewOptionsMenu.js.map +1 -1
  62. package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -1
  63. package/lib/types/client/WorktreeNameDialog.js.map +1 -1
  64. package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
  65. package/lib/types/client/WorktreeProgress.js.map +1 -1
  66. package/lib/types/client/WorktreeSettings.d.ts.map +1 -1
  67. package/lib/types/client/WorktreeSettings.js.map +1 -1
  68. package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
  69. package/lib/types/client/WorktreeToggle.js.map +1 -1
  70. package/lib/types/client/changes-store.d.ts +7 -4
  71. package/lib/types/client/changes-store.d.ts.map +1 -1
  72. package/lib/types/client/changes-store.js.map +1 -1
  73. package/lib/types/client/glyphs.d.ts +14 -1
  74. package/lib/types/client/glyphs.d.ts.map +1 -1
  75. package/lib/types/client/glyphs.js.map +1 -1
  76. package/lib/types/client/index.d.ts +1 -2
  77. package/lib/types/client/index.d.ts.map +1 -1
  78. package/lib/types/client/index.js.map +1 -1
  79. package/lib/types/client/locales.d.ts +5 -4
  80. package/lib/types/client/locales.d.ts.map +1 -1
  81. package/lib/types/client/locales.js.map +1 -1
  82. package/lib/types/client/minute-clock.d.ts +7 -0
  83. package/lib/types/client/minute-clock.d.ts.map +1 -0
  84. package/lib/types/client/minute-clock.js.map +1 -0
  85. package/lib/types/client/mount.d.ts.map +1 -1
  86. package/lib/types/client/mount.js.map +1 -1
  87. package/lib/types/client/review-page/ReviewActivity.d.ts.map +1 -1
  88. package/lib/types/client/review-page/ReviewActivity.js.map +1 -1
  89. package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -1
  90. package/lib/types/client/review-page/ReviewChat.js.map +1 -1
  91. package/lib/types/client/review-page/ReviewDetail.d.ts +4 -1
  92. package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -1
  93. package/lib/types/client/review-page/ReviewDetail.js.map +1 -1
  94. package/lib/types/client/review-page/ReviewList.d.ts.map +1 -1
  95. package/lib/types/client/review-page/ReviewList.js.map +1 -1
  96. package/lib/types/client/review-page/ReviewPage.d.ts +2 -2
  97. package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -1
  98. package/lib/types/client/review-page/ReviewPage.js.map +1 -1
  99. package/lib/types/client/review-page/ReviewStatus.d.ts +17 -13
  100. package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -1
  101. package/lib/types/client/review-page/ReviewStatus.js.map +1 -1
  102. package/lib/types/client/review-page/review-store.d.ts +1 -1
  103. package/lib/types/client/review-threads.d.ts +14 -7
  104. package/lib/types/client/review-threads.d.ts.map +1 -1
  105. package/lib/types/client/review-threads.js.map +1 -1
  106. package/lib/types/client/status.d.ts +0 -6
  107. package/lib/types/client/status.d.ts.map +1 -1
  108. package/lib/types/client/status.js.map +1 -1
  109. package/lib/types/client/thread-state.d.ts +2 -2
  110. package/lib/types/client/thread-state.d.ts.map +1 -1
  111. package/lib/types/client/thread-state.js.map +1 -1
  112. package/lib/types/client/toolbar-fold.d.ts +16 -6
  113. package/lib/types/client/toolbar-fold.d.ts.map +1 -1
  114. package/lib/types/client/toolbar-fold.js.map +1 -1
  115. package/lib/types/index.d.ts +25 -12
  116. package/lib/types/index.d.ts.map +1 -1
  117. package/lib/types/index.js.map +1 -1
  118. package/lib/types/panel.js.map +1 -1
  119. package/lib/types/types.d.ts +22 -5
  120. package/lib/types/types.d.ts.map +1 -1
  121. package/lib/types/worktree.js.map +1 -1
  122. package/package.json +60 -58
  123. package/src/client/BaseMenu.module.css +6 -3
  124. package/src/client/BranchPicker.tsx +28 -19
  125. package/src/client/ChangeRequestCard.tsx +71 -41
  126. package/src/client/ChangeRequestOverview.tsx +174 -74
  127. package/src/client/ChangeRequestsSection.tsx +33 -8
  128. package/src/client/ChangeStatus.module.css +70 -0
  129. package/src/client/ChangeStatus.tsx +104 -0
  130. package/src/client/ChangedFiles.tsx +20 -7
  131. package/src/client/ChangesTab.module.css +89 -20
  132. package/src/client/ChangesTab.tsx +332 -134
  133. package/src/client/CommitMenu.tsx +77 -38
  134. package/src/client/CopyCommandButton.tsx +25 -0
  135. package/src/client/DiffFile.tsx +83 -21
  136. package/src/client/EnvironmentRows.tsx +13 -11
  137. package/src/client/FileLabel.module.css +16 -18
  138. package/src/client/FileLabel.tsx +15 -31
  139. package/src/client/Forge.module.css +3 -10
  140. package/src/client/HostSettings.tsx +10 -8
  141. package/src/client/LensFilter.tsx +11 -9
  142. package/src/client/ReviewComposer.tsx +29 -17
  143. package/src/client/ReviewControls.tsx +8 -6
  144. package/src/client/ReviewThread.tsx +63 -21
  145. package/src/client/ReviewThreads.tsx +126 -34
  146. package/src/client/SubmitReview.tsx +5 -3
  147. package/src/client/ThreadList.module.css +4 -3
  148. package/src/client/ThreadList.tsx +5 -5
  149. package/src/client/ViewOptionsMenu.tsx +10 -8
  150. package/src/client/WorktreeNameDialog.tsx +15 -11
  151. package/src/client/WorktreeProgress.tsx +11 -9
  152. package/src/client/WorktreeSettings.tsx +4 -3
  153. package/src/client/WorktreeToggle.tsx +65 -35
  154. package/src/client/changes-store.ts +8 -5
  155. package/src/client/glyphs.tsx +23 -1
  156. package/src/client/index.ts +1 -2
  157. package/src/client/locales.ts +40 -32
  158. package/src/client/minute-clock.ts +19 -0
  159. package/src/client/mount.ts +66 -51
  160. package/src/client/review-page/ReviewActivity.tsx +5 -4
  161. package/src/client/review-page/ReviewChat.tsx +46 -17
  162. package/src/client/review-page/ReviewDetail.tsx +62 -31
  163. package/src/client/review-page/ReviewList.tsx +23 -18
  164. package/src/client/review-page/ReviewPage.module.css +81 -10
  165. package/src/client/review-page/ReviewPage.tsx +43 -35
  166. package/src/client/review-page/ReviewStatus.tsx +64 -39
  167. package/src/client/review-threads.ts +23 -11
  168. package/src/client/status.ts +0 -9
  169. package/src/client/thread-state.ts +8 -7
  170. package/src/client/toolbar-fold.ts +59 -14
  171. package/src/index.ts +78 -20
  172. package/src/panel.ts +1 -1
  173. package/src/types.ts +24 -5
  174. package/src/worktree.ts +1 -1
  175. package/lib/types/client/AttentionIndicator.d.ts +0 -22
  176. package/lib/types/client/AttentionIndicator.d.ts.map +0 -1
  177. package/lib/types/client/AttentionIndicator.js.map +0 -1
  178. package/src/client/AttentionIndicator.tsx +0 -37
@@ -1,5 +1,5 @@
1
1
  /** A provider row's page on the Plugins page: the hosts the provider serves, each with its sign-in state. */
2
- import { useEffect, useId, useRef, useState, type ReactNode } from 'react'
2
+ import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from 'react'
3
3
  import {
4
4
  Button, IconRefreshOutlineRegular, IconTrashOutlineRegular, SettingsForm, StateDot, Tooltip, type StateDotState,
5
5
  } from '@deepseek-ai/dsh-client-ui-primitives/client'
@@ -8,6 +8,7 @@ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-cli
8
8
  import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
9
9
  import { assertNever } from '@deepseek-ai/dsh-util-values'
10
10
  import type { ForgePanelKey, NS } from './locales.ts'
11
+ import { CopyCommandButton } from './CopyCommandButton.tsx'
11
12
  import type { HostFormActions, HostFormState, HostProblem } from './host-settings-form.ts'
12
13
  import type { HostSignIn } from './host-sign-in.ts'
13
14
  import { rowFormLabels } from './row-form-labels.ts'
@@ -111,7 +112,8 @@ function HostRow({ host, signIn, removable, disabled, onRemove, onCopy, t }: {
111
112
  {command !== undefined && (
112
113
  <div className={css.command}>
113
114
  <code className={css.commandText}>{command}</code>
114
- <Button size="sm" aria-label={t('signin.copy')} onClick={() => { onCopy(command) }}>{t('signin.copyShort')}</Button>
115
+ <CopyCommandButton command={command} copyText={onCopy} label={t('signin.copyShort')}
116
+ ariaLabel={t('signin.copy')} variant="ghost" />
115
117
  </div>
116
118
  )}
117
119
  {reason !== null && reason !== '' && <p className={css.reason}>{reason}</p>}
@@ -126,7 +128,7 @@ function HostRow({ host, signIn, removable, disabled, onRemove, onCopy, t }: {
126
128
  * @returns the row page's form, or the summary line.
127
129
  */
128
130
  export function HostSettings(props: HostSettingsProps): ReactNode {
129
- const { t, forge, view } = props
131
+ const { t, forge, view, add: addHost } = props
130
132
  const labelId = useId()
131
133
  const messageId = useId()
132
134
  const state = props.useHostForm(value => value)
@@ -147,13 +149,13 @@ export function HostSettings(props: HostSettingsProps): ReactNode {
147
149
  window.addEventListener('focus', again)
148
150
  return () => { window.removeEventListener('focus', again) }
149
151
  }, [shown, savedKey])
150
- if (view === 'summary') return t('hosts.title')
151
- const disabled = !state.writable || state.saving
152
- const add = (): void => {
153
- const refused = props.add(text)
152
+ const add = useCallback((): void => {
153
+ const refused = addHost(text)
154
154
  setProblem(refused)
155
155
  if (refused === undefined) setText('')
156
- }
156
+ }, [addHost, text])
157
+ if (view === 'summary') return t('hosts.title')
158
+ const disabled = !state.writable || state.saving
157
159
  return (
158
160
  <SettingsForm labels={rowFormLabels(t, 'hosts.unavailable')} state={state} onSave={props.save} onDiscard={props.discard}>
159
161
  <div className={css.field}>
@@ -1,6 +1,6 @@
1
1
  /** The changes toolbar's filter lens menu: the Host's lenses with the files each keeps among the shown files. */
2
2
 
3
- import { useState, type ReactNode } from 'react'
3
+ import { useCallback, useState, type ReactNode } from 'react'
4
4
  import { IconChevronDownOutlineRegular, IconLayersOutlineRegular, IconLoadingOutlineRegular, Menu, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives/client'
5
5
  import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
6
6
  import type { LensRun } from './lens-filter.ts'
@@ -70,6 +70,14 @@ export function LensFilterMenu({ lenses, chosen, run, choose, visible, t }: Prop
70
70
  readonly visible: boolean
71
71
  }): ReactNode {
72
72
  const [open, setOpen] = useState(false)
73
+ const close = useCallback((): void => { setOpen(false) }, [])
74
+ const select = useCallback((row: string): void => {
75
+ setOpen(false)
76
+ const lens = lensOfRow(row)
77
+ /* v8 ignore next -- the menu offers only rows that choose a lens */
78
+ if (lens === undefined) return
79
+ choose(lens)
80
+ }, [choose])
73
81
  let status: ReactNode = null
74
82
  if (run.kind === 'running') {
75
83
  status = <>
@@ -82,14 +90,8 @@ export function LensFilterMenu({ lenses, chosen, run, choose, visible, t }: Prop
82
90
  return (
83
91
  <Menu open={visible && open} portal dense align="start" autoFocus items={lensEntries(lenses, t)}
84
92
  selectedId={chosen === null ? NO_LENS : lensRowId(chosen.id)}
85
- onClose={() => { setOpen(false) }}
86
- onSelect={(row) => {
87
- setOpen(false)
88
- const lens = lensOfRow(row)
89
- /* v8 ignore next -- the menu offers only rows that choose a lens */
90
- if (lens === undefined) return
91
- choose(lens)
92
- }}
93
+ onClose={close}
94
+ onSelect={select}
93
95
  anchor={(
94
96
  <button type="button" className={css.trigger} aria-haspopup="menu" aria-expanded={visible && open}
95
97
  aria-label={chosen === null ? t('filterLens.aria') : t('filterLens.chosenAria', { lens: chosen.title })}
@@ -1,6 +1,6 @@
1
1
  /** Plain-text comment editor for a frozen selection in either review tab. */
2
2
 
3
- import { useEffect, useRef, useState, type ReactNode } from 'react'
3
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
4
4
  import clsx from 'clsx'
5
5
  import { Button, IconChevronDownOutlineRegular, Menu, MenuItemButton } from '@deepseek-ai/dsh-client-ui-primitives/client'
6
6
  import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
@@ -38,6 +38,9 @@ export interface ReviewActions {
38
38
  readonly renderActions?: (owner: Omit<ForgeCommentActionsProps, 'target'>) => ReactNode
39
39
  }
40
40
 
41
+ /** One way of sending the edited comment; a failure text preserves the form. */
42
+ type ReviewDeliver = (selection: ReviewSelection) => Promise<string | undefined>
43
+
41
44
  /**
42
45
  * Render a primary action with an optional second action in its menu.
43
46
  * @param props - the main action, the optional menu action, the menu's name, and availability.
@@ -54,12 +57,18 @@ export function SplitAction({ disabled, label, run, menuLabel, menu, other }: {
54
57
  readonly menu: () => void
55
58
  }): ReactNode {
56
59
  const [open, setOpen] = useState(false)
60
+ const closeMenu = useCallback((): void => { setOpen(false) }, [])
61
+ const toggleMenu = useCallback((): void => { setOpen(value => !value) }, [])
62
+ const chooseMenu = useCallback((): void => {
63
+ setOpen(false)
64
+ menu()
65
+ }, [menu])
57
66
  return <div className={css.gitAction}>
58
67
  <Button size="sm" variant="primary" className={clsx(other !== undefined && css.gitMain)} disabled={disabled} onClick={run}>{label}</Button>
59
- {other !== undefined && <Menu open={open && !disabled} portal dense align="end" autoFocus onClose={() => { setOpen(false) }}
68
+ {other !== undefined && <Menu open={open && !disabled} portal dense align="end" autoFocus onClose={closeMenu}
60
69
  anchor={<Button size="sm" variant="primary" className={clsx(css.gitArrow)} disabled={disabled} aria-haspopup="menu" aria-expanded={open && !disabled}
61
- aria-label={menuLabel} onClick={() => { setOpen(value => !value) }}><IconChevronDownOutlineRegular size={14} /></Button>}>
62
- <MenuItemButton onSelect={() => { setOpen(false); menu() }}>{other}</MenuItemButton>
70
+ aria-label={menuLabel} onClick={toggleMenu}><IconChevronDownOutlineRegular size={14} /></Button>}>
71
+ <MenuItemButton onSelect={chooseMenu}>{other}</MenuItemButton>
63
72
  </Menu>}
64
73
  </div>
65
74
  }
@@ -84,10 +93,10 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
84
93
  const running = useRef(false)
85
94
  const input = useRef<HTMLTextAreaElement>(null)
86
95
  useEffect(() => { input.current?.focus() }, [])
87
- const comment = (): ReviewSelection => ({ ...selection, comment: { ...selection.comment, body: body.current } })
96
+ const comment = useCallback((): ReviewSelection => ({ ...selection, comment: { ...selection.comment, body: body.current } }), [selection])
88
97
  const range = reviewRange(selection.comment)
89
98
  /** Send the comment to the code host, closing the form once it is taken and keeping its text otherwise. */
90
- const send = async (destination: ((selection: ReviewSelection) => Promise<string | undefined>) | undefined): Promise<void> => {
99
+ const send = useCallback(async (destination: ReviewDeliver | undefined): Promise<void> => {
91
100
  if (running.current || destination === undefined) return
92
101
  running.current = true
93
102
  setBusy(true)
@@ -102,7 +111,16 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
102
111
  running.current = false
103
112
  setBusy(false)
104
113
  }
105
- }
114
+ }, [close, comment, t])
115
+ const addToInput = useCallback((): void => {
116
+ const selected = comment()
117
+ settleQuote(actions.addToInput(selected), (accepted) => {
118
+ if (accepted) { actions.onQuoted?.(selected); close() }
119
+ else setError(t(copy.failed))
120
+ })
121
+ }, [actions, close, comment, copy.failed, t])
122
+ const runQueue = useCallback((): void => { void send(actions.queue) }, [actions.queue, send])
123
+ const runPublish = useCallback((): void => { void send(actions.publish) }, [actions.publish, send])
106
124
  return (
107
125
  <section className={css.root} aria-label={t('review.range', { range })}
108
126
  data-forge-comment={`${selection.comment.side}${selection.comment.startLine}-${selection.comment.endLine}`}>
@@ -118,13 +136,7 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
118
136
  {error !== null && <div className={css.error} role="alert">{error}</div>}
119
137
  <div className={css.actions}>
120
138
  <Button size="sm" className={clsx(css.cancel)} disabled={busy} onClick={close}>{t('review.cancel')}</Button>
121
- <Button size="sm" variant={actions.queue === undefined ? 'primary' : 'outline'} disabled={busy || empty} onClick={() => {
122
- const selected = comment()
123
- settleQuote(actions.addToInput(selected), (accepted) => {
124
- if (accepted) { actions.onQuoted?.(selected); close() }
125
- else setError(t(copy.failed))
126
- })
127
- }}>{t(copy.add)}</Button>
139
+ <Button size="sm" variant={actions.queue === undefined ? 'primary' : 'outline'} disabled={busy || empty} onClick={addToInput}>{t(copy.add)}</Button>
128
140
  {actions.renderActions?.({
129
141
  selection: {
130
142
  path: selection.comment.path, side: selection.comment.side,
@@ -136,10 +148,10 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
136
148
  })}
137
149
  {visible && actions.queue !== undefined && <SplitAction disabled={busy || actions.publishingBlocked === true || empty}
138
150
  label={t(busy ? 'review.publishing' : actions.reviewStarted === true ? 'review.queue' : 'review.startReview')}
139
- run={() => { void send(actions.queue) }} menuLabel={t('review.hostActions')}
140
- other={actions.publish === undefined ? undefined : t('review.publish')} menu={() => { void send(actions.publish) }} />}
151
+ run={runQueue} menuLabel={t('review.hostActions')}
152
+ other={actions.publish === undefined ? undefined : t('review.publish')} menu={runPublish} />}
141
153
  {actions.queue === undefined && actions.publish !== undefined && <Button size="sm" variant="primary"
142
- disabled={busy || actions.publishingBlocked === true || empty} onClick={() => { void send(actions.publish) }}>{t('review.publish')}</Button>}
154
+ disabled={busy || actions.publishingBlocked === true || empty} onClick={runPublish}>{t('review.publish')}</Button>}
143
155
 
144
156
  </div>
145
157
  </section>
@@ -4,7 +4,7 @@
4
4
  * share of shown files the reader marked viewed. The thread list shares the segmented radio group.
5
5
  */
6
6
 
7
- import { useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
7
+ import { useCallback, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
8
8
  import { IconChevronDownOutlineRegular, Menu, Switch, Tooltip, type MenuEntry } 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 { ChangesLens } from './changes-store.ts'
@@ -175,6 +175,11 @@ export function LensControl({ lens, counts, hideTests, choose, t, need }: LensPr
175
175
  */
176
176
  export function LensMenu({ lens, counts, hideTests, choose, visible, t }: LensProps & { readonly visible: boolean }): ReactNode {
177
177
  const [open, setOpen] = useState(false)
178
+ const close = useCallback((): void => { setOpen(false) }, [])
179
+ const select = useCallback((id: string): void => {
180
+ setOpen(false)
181
+ choose(id as ChangesLens)
182
+ }, [choose])
178
183
  const items: MenuEntry[] = LENSES.map((item) => {
179
184
  // Like the segment, a disabled lens shows no count, since hidden test files are not counted.
180
185
  const disabled = item === 'test' && hideTests
@@ -186,11 +191,8 @@ export function LensMenu({ lens, counts, hideTests, choose, visible, t }: LensPr
186
191
  })
187
192
  return (
188
193
  <Menu open={visible && open} portal dense align="start" autoFocus selectedId={lens} items={items}
189
- onClose={() => { setOpen(false) }}
190
- onSelect={(id) => {
191
- setOpen(false)
192
- choose(id as ChangesLens)
193
- }}
194
+ onClose={close}
195
+ onSelect={select}
194
196
  anchor={(
195
197
  <button type="button" className={css.trigger} aria-haspopup="menu" aria-expanded={visible && open}
196
198
  aria-label={t('lens.menuAria', { lens: t(LENS_LABEL[lens]) })} data-forge-lens-menu={lens}
@@ -1,13 +1,13 @@
1
1
  /** Inline comment records and the editing of comment drafts kept in the browser at their captured code location. */
2
2
 
3
- import { useCallback, useState, useSyncExternalStore, type ReactNode } from 'react'
3
+ import { useCallback, useMemo, useState, useSyncExternalStore, type ReactNode } from 'react'
4
4
  import { Button, Tag } from '@deepseek-ai/dsh-client-ui-primitives/client'
5
5
  import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
6
6
  import type { ReviewActions } from './ReviewComposer.tsx'
7
7
  import { CardMenu, DeleteConfirm } from './ReviewThreads.tsx'
8
8
  import { EMPTY_FILE_REVIEW, type FileReviewState, type ReviewThread as Thread } from './review-queue.ts'
9
9
  import { INPUT_QUOTE_COPY, reviewRange, settleQuote } from './review.ts'
10
- import type { NS } from './locales.ts'
10
+ import type { ForgePanelKey, NS } from './locales.ts'
11
11
  import css from './ReviewThreads.module.css'
12
12
  import composerCss from './ReviewComposer.module.css'
13
13
 
@@ -25,6 +25,40 @@ export function useFileReview(actions: ReviewActions | undefined, path: string):
25
25
  return useSyncExternalStore(actions?.records?.subscribe ?? noSubscription, read)
26
26
  }
27
27
 
28
+ /** Copy of the publish button: the draft's move into the pending review, or how to start one. */
29
+ function publishKey(moving: boolean, started: boolean): ForgePanelKey {
30
+ if (moving) return 'review.publishing'
31
+ if (started) return 'review.queue'
32
+ return 'review.startReview'
33
+ }
34
+
35
+ /** The button that adds a saved comment draft to the pending review on the code host. */
36
+ function PublishButton({ moving, started, waiting, queue, move, t }: {
37
+ readonly moving: boolean
38
+ readonly started: boolean
39
+ readonly waiting: boolean
40
+ readonly queue: NonNullable<ReviewActions['queue']>
41
+ readonly move: (add: NonNullable<ReviewActions['queue']>) => Promise<void>
42
+ readonly t: PropsLocale<typeof NS>['t']
43
+ }) {
44
+ const publish = useCallback((): void => { void move(queue) }, [move, queue])
45
+ return (
46
+ <Button size="sm" disabled={waiting} onClick={publish}>
47
+ {t(publishKey(moving, started))}
48
+ </Button>
49
+ )
50
+ }
51
+
52
+ /** The button that opens a published comment again on the code host. */
53
+ function RecheckButton({ url, openLink, t }: {
54
+ readonly url: string
55
+ readonly openLink: (url: string) => void
56
+ readonly t: PropsLocale<typeof NS>['t']
57
+ }) {
58
+ const recheck = useCallback((): void => { openLink(url) }, [openLink, url])
59
+ return <Button size="sm" onClick={recheck}>{t('review.recheck')}</Button>
60
+ }
61
+
28
62
  /**
29
63
  * Render a saved comment at its line: its lines and state, the menu of its less frequent actions, its text, and Add to
30
64
  * input. A reference or a publication receipt can be removed from the view, which leaves the main input and the code
@@ -47,15 +81,18 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
47
81
  // A draft published while its form is open becomes a receipt, which has neither form.
48
82
  const editing = mode === 'edit' && thread.kind === 'pending'
49
83
  const confirming = mode === 'delete' && thread.kind === 'pending'
50
- const quoted = editing ? { ...thread.selection, comment: { ...comment, body } } : thread.selection
84
+ const quoted = useMemo(
85
+ () => editing ? { ...thread.selection, comment: { ...comment, body } } : thread.selection,
86
+ [body, comment, editing, thread.selection],
87
+ )
51
88
  const range = reviewRange(comment)
52
89
  const copy = actions.quoteCopy ?? INPUT_QUOTE_COPY
53
90
  const status = thread.kind === 'pending' ? 'review.browserDraft' : thread.kind === 'published' ? 'review.published' : copy.added
54
- const save = (): boolean => actions.records?.editThread(thread.key, body) === true
91
+ const save = useCallback((): boolean => actions.records?.editThread(thread.key, body) === true, [actions, body, thread.key])
55
92
  const queue = actions.queue
56
93
  const waiting = locked || moving
57
94
  /** Add the draft to the pending review on the code host, then delete it from the browser. */
58
- const move = async (add: NonNullable<ReviewActions['queue']>): Promise<void> => {
95
+ const move = useCallback(async (add: NonNullable<ReviewActions['queue']>): Promise<void> => {
59
96
  setMoving(true)
60
97
  setError(null)
61
98
  try {
@@ -67,8 +104,8 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
67
104
  } finally {
68
105
  setMoving(false)
69
106
  }
70
- }
71
- const select = (id: string): void => {
107
+ }, [actions, t, thread.selection, thread.key])
108
+ const select = useCallback((id: string): void => {
72
109
  if (id === 'edit') {
73
110
  setBody(comment.body)
74
111
  setMode('edit')
@@ -78,7 +115,17 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
78
115
  if (removed === null) setError(t('review.saveFailed'))
79
116
  else actions.onRemoved?.(removed)
80
117
  }
81
- }
118
+ }, [actions, comment.body, t, thread.key])
119
+ const cancelDelete = useCallback((): void => { setError(null); setMode('view') }, [])
120
+ const confirmDelete = useCallback((): void => {
121
+ if (actions.records?.editThread(thread.key, null) !== true) setError(t('review.saveFailed'))
122
+ }, [actions, t, thread.key])
123
+ const addToInput = useCallback((): void => {
124
+ settleQuote(actions.addToInput(quoted), (accepted) => { if (!accepted) setError(t(copy.failed)) })
125
+ }, [actions, copy.failed, quoted, t])
126
+ const finishEdit = useCallback((): void => {
127
+ if (save()) { setMode('view'); setError(null) } else setError(t('review.saveFailed'))
128
+ }, [save, t])
82
129
  return <section className={css.card} data-forge-review-thread={thread.kind} data-side={comment.side} aria-label={t('review.range', { range })}>
83
130
  <div className={css.recordHeader}>
84
131
  <div className={css.recordInfo}>
@@ -101,21 +148,16 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
101
148
  }} />
102
149
  : <div className={css.plain}>{comment.body}</div>}
103
150
  {confirming && <DeleteConfirm question={t('thread.deleteConfirm')} confirmLabel={t('review.remove')} disabled={waiting} error={error}
104
- cancel={() => { setError(null); setMode('view') }}
105
- confirm={() => { if (actions.records?.editThread(thread.key, null) !== true) setError(t('review.saveFailed')) }} t={t} />}
151
+ cancel={cancelDelete}
152
+ confirm={confirmDelete} t={t} />}
106
153
  {error !== null && !confirming && <div className={composerCss.error} role="alert">{error}</div>}
107
154
  <div className={css.actions}>
108
- <Button size="sm" disabled={quoted.comment.body.trim() === ''} onClick={() => {
109
- settleQuote(actions.addToInput(quoted), (accepted) => { if (!accepted) setError(t(copy.failed)) })
110
- }}>{t(copy.add)}</Button>
111
- {editing && <Button size="sm" disabled={waiting || body.trim() === ''} onClick={() => {
112
- if (save()) { setMode('view'); setError(null) } else setError(t('review.saveFailed'))
113
- }}>{t('review.done')}</Button>}
114
- {thread.kind === 'pending' && queue !== undefined && mode === 'view' && !outdated && <Button size="sm" disabled={waiting}
115
- onClick={() => { void move(queue) }}>
116
- {t(moving ? 'review.publishing' : actions.reviewStarted === true ? 'review.queue' : 'review.startReview')}
117
- </Button>}
118
- {thread.kind === 'published' && actions.openLink !== undefined && <Button size="sm" onClick={() => { actions.openLink?.(thread.url) }}>{t('review.recheck')}</Button>}
155
+ <Button size="sm" disabled={quoted.comment.body.trim() === ''} onClick={addToInput}>{t(copy.add)}</Button>
156
+ {editing && <Button size="sm" disabled={waiting || body.trim() === ''} onClick={finishEdit}>{t('review.done')}</Button>}
157
+ {thread.kind === 'pending' && queue !== undefined && mode === 'view' && !outdated && <PublishButton moving={moving}
158
+ started={actions.reviewStarted === true} waiting={waiting} queue={queue} move={move} t={t} />}
159
+ {thread.kind === 'published' && actions.openLink !== undefined
160
+ && <RecheckButton url={thread.url} openLink={actions.openLink} t={t} />}
119
161
  </div>
120
162
  </section>
121
163
  }