@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
@@ -4,16 +4,16 @@
4
4
  * accepted only when each of its commits has the one listed before it as its first parent.
5
5
  */
6
6
 
7
- import { useEffect, useRef, useState, type ReactNode } from 'react'
7
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
8
8
  import clsx from 'clsx'
9
9
  import {
10
10
  Button, IconCheckOutlineRegular, IconChevronDownOutlineRegular, Menu, MenuItemButton, StateDot, Tooltip,
11
11
  } from '@deepseek-ai/dsh-client-ui-primitives/client'
12
12
  import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
13
- import type { ForgeCommitList } from '@deepseek-ai/dsh-experimental-forge/types'
13
+ import type { ForgeCommit, ForgeCommitList } from '@deepseek-ai/dsh-experimental-forge/types'
14
14
  import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
15
15
  import { rangeStart } from '../commit-range.ts'
16
- import type { ForgeCommitRange, ForgeLocalCommits } from '../types.ts'
16
+ import type { ForgeChangeCommits, ForgeCommitRange, ForgeLocalCommits } from '../types.ts'
17
17
  import { formatAgo } from './format.ts'
18
18
  import type { NS } from './locales.ts'
19
19
  import css from './CommitMenu.module.css'
@@ -23,8 +23,8 @@ const SHORT = 7
23
23
 
24
24
  /** Props of the commit picker. */
25
25
  export interface CommitMenuProps extends PropsLocale<typeof NS> {
26
- /** Commits shown, or null for all of them. */
27
- readonly chosen: ForgeCommitRange | null
26
+ /** Commits shown, or null for all of them. The owner of a change request view may show its changes up to one commit. */
27
+ readonly chosen: ForgeChangeCommits | null
28
28
  /** Whether the owning tab is visible; a hidden tab keeps the menu closed. */
29
29
  readonly visible: boolean
30
30
  /** Read the commits; null means the source cannot show single commits. `signal` aborts the read. */
@@ -43,17 +43,49 @@ export interface CommitMenuProps extends PropsLocale<typeof NS> {
43
43
  * @param t - forge panel copy.
44
44
  * @returns the label.
45
45
  */
46
- export function commitsLabel(chosen: ForgeCommitRange | null, t: PropsLocale<typeof NS>['t']): string {
46
+ export function commitsLabel(chosen: ForgeChangeCommits | null, t: PropsLocale<typeof NS>['t']): string {
47
47
  if (chosen === null) return t('commits.all')
48
+ // Changes up to a commit read as that commit, as one commit shown alone does.
49
+ if ('upTo' in chosen) return chosen.upTo.slice(0, SHORT)
48
50
  if (chosen.from === chosen.to) return chosen.from.slice(0, SHORT)
49
51
  return t('commits.range', { from: chosen.from.slice(0, SHORT), to: chosen.to.slice(0, SHORT) })
50
52
  }
51
53
 
54
+ /** Name the shown commits in the trigger's attribute: empty for all of them, `..sha` up to a commit, else `from..to`. */
55
+ function commitsAttribute(chosen: ForgeChangeCommits | null): string {
56
+ if (chosen === null) return ''
57
+ return 'upTo' in chosen ? `..${chosen.upTo}` : `${chosen.from}..${chosen.to}`
58
+ }
59
+
60
+ /** One commit row of the picker: its short object name, its title, when it was authored, and the mark of the shown run. */
61
+ function CommitRow({ commit, selected, ago, onPick }: {
62
+ readonly commit: ForgeCommit
63
+ readonly selected: boolean
64
+ readonly ago: string
65
+ readonly onPick: (sha: string) => void
66
+ }) {
67
+ const sha = commit.sha
68
+ const pick = useCallback((): void => { onPick(sha) }, [onPick, sha])
69
+ return (
70
+ <MenuItemButton current={selected} onSelect={pick}>
71
+ <span className={css.option} data-forge-commit={sha}>
72
+ <span className={css.sha}>{sha.slice(0, SHORT)}</span>
73
+ <span className={css.title}>{commit.title}</span>
74
+ <span className={css.meta}>{ago}</span>
75
+ <span className={clsx(css.check, !selected && css.unchecked)}><IconCheckOutlineRegular size={14} /></span>
76
+ </span>
77
+ </MenuItemButton>
78
+ )
79
+ }
80
+
52
81
  /**
53
82
  * Render the trigger and, while open, the commit list. A click shows one commit; a Shift click shows the commits up to
54
83
  * the clicked one, from the one commit shown, wherever it was chosen, or else from the last commit clicked without Shift.
84
+ * Changes up to a commit, which only the view's owner chooses, have a row of their own above the list, since the list
85
+ * may no longer hold that commit.
55
86
  * @param props - the shown commits, the listing read, the choose action, and copy.
56
- * @returns the trigger with its portalled menu, or nothing when the source cannot show single commits.
87
+ * @returns the trigger with its portalled menu, or nothing when the source cannot show single commits and shows all of
88
+ * them.
57
89
  */
58
90
  export function CommitMenu({ chosen, visible, list, kept, version, choose, t }: CommitMenuProps): ReactNode {
59
91
  const [open, setOpen] = useState(false)
@@ -64,7 +96,9 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
64
96
  readonly result: RemoteResult<ForgeCommitList | ForgeLocalCommits | null>
65
97
  } | null>(null)
66
98
  const shift = useRef(false)
67
- const anchor = useRef<string | null>(chosen?.from ?? null)
99
+ const range = chosen !== null && 'from' in chosen ? chosen : null
100
+ const upTo = chosen !== null && 'upTo' in chosen ? chosen.upTo : null
101
+ const anchor = useRef<string | null>(range?.from ?? null)
68
102
  const loaded = useRef<string | null>(null)
69
103
  const shown = visible && open
70
104
  const key = `${version}\n${String(attempt)}`
@@ -80,13 +114,12 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
80
114
  })
81
115
  return () => { controller.abort() }
82
116
  }, [visible, key, list])
83
- if (current?.ok === true && current.value === null) return null
84
117
  const commits = current?.ok === true && current.value !== null ? current.value : null
85
- const close = (): void => {
118
+ const close = useCallback((): void => {
86
119
  setOpen(false)
87
120
  setRejected(false)
88
- }
89
- const pick = (sha: string | null): void => {
121
+ }, [])
122
+ const pick = useCallback((sha: string | null): void => {
90
123
  if (sha === null || commits === null) {
91
124
  close()
92
125
  anchor.current = null
@@ -95,7 +128,7 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
95
128
  }
96
129
  const order = commits.commits.map(commit => commit.sha)
97
130
  // One commit shown alone starts the run, also when the view's owner chose it and not a click here.
98
- const held = chosen !== null && chosen.from === chosen.to ? chosen.from : anchor.current
131
+ const held = range !== null && range.from === range.to ? range.from : anchor.current
99
132
  const start = shift.current && held !== null && order.includes(held) ? held : sha
100
133
  const [from, to] = order.indexOf(start) <= order.indexOf(sha) ? [start, sha] : [sha, start]
101
134
  // Two ends cannot name a run that leaves the first-parent line, so the menu stays open and says why.
@@ -105,51 +138,56 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
105
138
  }
106
139
  close()
107
140
  if (!shift.current || start === sha) anchor.current = sha
108
- if (from !== chosen?.from || to !== chosen.to) choose({ from, to })
109
- }
141
+ if (from !== range?.from || to !== range.to) choose({ from, to })
142
+ }, [choose, chosen, close, commits, range])
143
+ const chooseAll = useCallback((): void => { pick(null) }, [pick])
144
+ const retryListing = useCallback((): void => { setAttempt(count => count + 1) }, [])
145
+ // Changes up to a commit keep the picker, which is the way back to all commits.
146
+ if (current?.ok === true && current.value === null && upTo === null) return null
110
147
  const inChosen = (index: number): boolean => {
111
- if (chosen === null || commits === null) return false
148
+ if (range === null || commits === null) return false
112
149
  const order = commits.commits.map(commit => commit.sha)
113
- return index >= order.indexOf(chosen.from) && index <= order.indexOf(chosen.to) && order.includes(chosen.from)
150
+ return index >= order.indexOf(range.from) && index <= order.indexOf(range.to) && order.includes(range.from)
114
151
  }
115
152
 
116
153
  let body: ReactNode
117
154
  if (current === null) {
118
155
  body = <div className={css.status} role="status"><StateDot state="ongoing" />{t('commits.loading')}</div>
119
- } else if (!current.ok || commits === null) {
156
+ } else if (!current.ok) {
120
157
  body = (
121
158
  <div className={css.status} role="status">
122
159
  <span>{t('commits.failed')}</span>
123
- <Button size="sm" variant="outline" onClick={() => { setAttempt(count => count + 1) }}>{t('retry')}</Button>
160
+ <Button size="sm" variant="outline" onClick={retryListing}>{t('retry')}</Button>
124
161
  </div>
125
162
  )
126
163
  } else {
127
164
  const now = Date.now()
165
+ const rows = commits?.commits ?? []
128
166
  body = <>
129
- <MenuItemButton current={chosen === null} onSelect={() => { pick(null) }}>
167
+ <MenuItemButton current={chosen === null} onSelect={chooseAll}>
130
168
  <span className={css.option}>
131
169
  <span className={css.allTitle}>{t('commits.all')}</span>
132
- <span className={css.meta}>{t('commits.count', { count: commits.commits.length })}</span>
170
+ {commits !== null && <span className={css.meta}>{t('commits.count', { count: commits.commits.length })}</span>}
133
171
  {chosen === null && <IconCheckOutlineRegular size={14} className={css.check} />}
134
172
  </span>
135
173
  </MenuItemButton>
136
- {commits.commits.length > 0 && <div className={css.label} role="presentation">{t('commits.shiftHint')}</div>}
137
- {commits.commits.map((commit, index) => {
138
- const selected = inChosen(index)
139
- return (
140
- <MenuItemButton key={commit.sha} current={selected} onSelect={() => { pick(commit.sha) }}>
141
- <span className={css.option} data-forge-commit={commit.sha}>
142
- <span className={css.sha}>{commit.sha.slice(0, SHORT)}</span>
143
- <span className={css.title}>{commit.title}</span>
144
- <span className={css.meta}>{formatAgo(commit.authoredAt, now, t) ?? ''}</span>
145
- <span className={clsx(css.check, !selected && css.unchecked)}><IconCheckOutlineRegular size={14} /></span>
146
- </span>
147
- </MenuItemButton>
148
- )
149
- })}
150
- {commits.truncated && (
174
+ {upTo !== null && (
175
+ <MenuItemButton current onSelect={close}>
176
+ <span className={css.option} data-forge-commit-up-to={upTo}>
177
+ <span className={css.sha}>{upTo.slice(0, SHORT)}</span>
178
+ <span className={css.title}>{t('commits.threadCommit')}</span>
179
+ <span className={css.check}><IconCheckOutlineRegular size={14} /></span>
180
+ </span>
181
+ </MenuItemButton>
182
+ )}
183
+ {rows.length > 0 && <div className={css.label} role="presentation">{t('commits.shiftHint')}</div>}
184
+ {rows.map((commit, index) => (
185
+ <CommitRow key={commit.sha} commit={commit} selected={inChosen(index)}
186
+ ago={formatAgo(commit.authoredAt, now, t) ?? ''} onPick={pick} />
187
+ ))}
188
+ {commits?.truncated === true && (
151
189
  <div className={css.note}>
152
- {t(kept === 'oldest' ? 'commits.truncatedOldest' : 'commits.truncatedNewest', { count: commits.commits.length })}
190
+ {t(kept === 'oldest' ? 'commits.truncatedOldest' : 'commits.truncatedNewest', { count: rows.length })}
153
191
  </div>
154
192
  )}
155
193
  </>
@@ -168,7 +206,8 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
168
206
  anchor={(
169
207
  <Tooltip label={t('commits.aria', { commits: label })} side="bottom" portal delayMs={500}>
170
208
  <button type="button" className={clsx(css.trigger, chosen !== null && css.chosen)} aria-haspopup="menu" aria-expanded={shown}
171
- aria-label={t('commits.aria', { commits: label })} data-forge-commits={chosen === null ? '' : `${chosen.from}..${chosen.to}`}
209
+ aria-label={t('commits.aria', { commits: label })}
210
+ data-forge-commits={commitsAttribute(chosen)}
172
211
  onClick={() => { setOpen(value => !value); setRejected(false) }}>
173
212
  <span className={css.triggerName}>{label}</span>
174
213
  <IconChevronDownOutlineRegular size={12} />
@@ -0,0 +1,25 @@
1
+ /** The button the forge surfaces use to copy a host's sign-in command. */
2
+
3
+ import { useCallback } from 'react'
4
+ import { Button } from '@deepseek-ai/dsh-client-ui-primitives/client'
5
+ import type { ButtonVariant } from '@deepseek-ai/dsh-client-ui-primitives/client'
6
+
7
+ /**
8
+ * Copy one host command through the caller's clipboard channel.
9
+ * @param props.command - the command text to copy.
10
+ * @param props.copyText - the surface's clipboard writer.
11
+ * @param props.label - the button text.
12
+ * @param props.ariaLabel - accessible name when the button text alone is not the action's name.
13
+ * @param props.variant - visual family; outlined unless the surface places it in a command row.
14
+ * @returns the copy button.
15
+ */
16
+ export function CopyCommandButton({ command, copyText, label, ariaLabel, variant = 'outline' }: {
17
+ readonly command: string
18
+ readonly copyText: (text: string) => void
19
+ readonly label: string
20
+ readonly ariaLabel?: string | undefined
21
+ readonly variant?: ButtonVariant | undefined
22
+ }) {
23
+ const copy = useCallback((): void => { copyText(command) }, [command, copyText])
24
+ return <Button size="sm" variant={variant} aria-label={ariaLabel} onClick={copy}>{label}</Button>
25
+ }
@@ -6,7 +6,7 @@
6
6
  * it redraws only when its own props change.
7
7
  */
8
8
 
9
- import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
9
+ import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type Dispatch, type ReactNode, type SetStateAction } from 'react'
10
10
  import clsx from 'clsx'
11
11
  import { flushSync } from 'react-dom'
12
12
  import {
@@ -113,6 +113,8 @@ export interface DiffFileProps {
113
113
  readonly wrap: boolean
114
114
  /** Badge text after the path, or empty for none. */
115
115
  readonly badge: string
116
+ /** The letter a narrow view draws in place of the badge text, or empty without a badge. */
117
+ readonly badgeLetter: string
116
118
  /** Hover text of the path: both paths of a renamed file, else the path. */
117
119
  readonly tooltip: string
118
120
  /** Whether the reader marked this change viewed, or marked an earlier change of the file. */
@@ -144,20 +146,45 @@ export interface DiffFileProps {
144
146
  readonly t: Translate
145
147
  }
146
148
 
149
+ /** The line counts {@link Counts} draws for one file. */
150
+ type CountedFile = Pick<ForgeDiffFile, 'additions' | 'deletions' | 'binary'>
151
+
152
+ const addedCount = (file: CountedFile): string => `+${file.additions.toLocaleString('en-US')}`
153
+ const deletedCount = (file: CountedFile): string => `−${file.deletions.toLocaleString('en-US')}`
154
+
155
+ /** The width {@link Counts} reads from the nearest ancestor that sets it, in `ch` of the counts' monospace font. */
156
+ export type CountsColumn = CSSProperties & { '--forge-deleted-width': string }
157
+
147
158
  /**
148
- * Render added and deleted line counts, or the binary label for binary content.
159
+ * Size the deleted count of a list of files to the list's widest `−N`. The counts end at a row's trailing edge, so
160
+ * with one width for the deleted count every row under the element that takes the style also ends its added count on
161
+ * one edge.
162
+ * @param files - every file the list can show.
163
+ * @returns the style for the list's container.
164
+ */
165
+ export function countsColumn(files: readonly CountedFile[]): CountsColumn {
166
+ let deleted = 0
167
+ for (const file of files) {
168
+ if (!file.binary) deleted = Math.max(deleted, deletedCount(file).length)
169
+ }
170
+ return { '--forge-deleted-width': `${deleted}ch` }
171
+ }
172
+
173
+ /**
174
+ * Render added and deleted line counts, or the binary label for binary content. Under a container styled with
175
+ * {@link countsColumn}, the deleted count fills that width from the trailing edge.
149
176
  * @param props - the counts and copy.
150
177
  * @returns the counts.
151
178
  */
152
179
  export function Counts({ file, t }: {
153
- readonly file: Pick<ForgeDiffFile, 'additions' | 'deletions' | 'binary'>
180
+ readonly file: CountedFile
154
181
  readonly t: Translate
155
182
  }): ReactNode {
156
183
  if (file.binary) return <span>{t('diff.binaryLabel')}</span>
157
184
  return (
158
185
  <span className={css.counts}>
159
- <span className={css.added}>{`+${file.additions.toLocaleString('en-US')}`}</span>
160
- <span className={css.deleted}>{`−${file.deletions.toLocaleString('en-US')}`}</span>
186
+ <span className={css.added}>{addedCount(file)}</span>
187
+ <span className={css.deleted}>{deletedCount(file)}</span>
161
188
  </span>
162
189
  )
163
190
  }
@@ -282,6 +309,21 @@ function pairKind(pair: SplitRow): 'context' | 'change' {
282
309
  return pair.left !== null && pair.left.kind === 'context' ? 'context' : 'change'
283
310
  }
284
311
 
312
+ /** An open comment editor for one range, which closes itself out of the ranges being written. */
313
+ function RangeEditor({ item, actions, visible, setEditors, t }: {
314
+ readonly item: ReviewSelection
315
+ readonly actions: ReviewActions
316
+ readonly visible: boolean
317
+ readonly setEditors: Dispatch<SetStateAction<readonly ReviewSelection[]>>
318
+ readonly t: Translate
319
+ }) {
320
+ const comment = item.comment
321
+ const close = useCallback((): void => {
322
+ setEditors(list => list.filter(open => !sameRange(open.comment, comment)))
323
+ }, [comment, setEditors])
324
+ return <ReviewComposer selection={item} visible={visible} actions={actions} close={close} t={t} />
325
+ }
326
+
285
327
  /** The hunks of one file with their collapsed and expanded unchanged lines. */
286
328
  function Lines({ file, text, open, handlers, split, wrap, review, visible, comments, threads, folded, annotations, t }: Pick<DiffFileProps,
287
329
  'file' | 'text' | 'open' | 'handlers' | 'split' | 'wrap' | 'review' | 'visible' | 'threads' | 'folded' | 't'> & LinesNotes): ReactNode {
@@ -536,8 +578,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
536
578
  return nodes
537
579
  }
538
580
  const editorOf = (item: ReviewSelection, actions: ReviewActions): ReactNode =>
539
- <ReviewComposer key={`comment-${rangeKey(item)}`} selection={item} visible={visible} actions={actions}
540
- close={() => { setEditors(list => list.filter(open => !sameRange(open.comment, item.comment))) }} t={t} />
581
+ <RangeEditor key={`comment-${rangeKey(item)}`} item={item} actions={actions} visible={visible} setEditors={setEditors} t={t} />
541
582
  // Side by side, a row's comments sit in a row of two cells under its columns, each continuing its line's background.
542
583
  const notes = (key: string, pair: SplitRow): void => {
543
584
  const left = commentsAt('L', pair.left?.no ?? null)
@@ -712,6 +753,27 @@ function Body(props: DiffFileProps): ReactNode {
712
753
  </>
713
754
  }
714
755
 
756
+ /** One row of a file's menu: it closes the menu, then runs the action. */
757
+ function FileMenuAction({ action, close, t }: {
758
+ readonly action: DiffFileAction
759
+ readonly close: () => void
760
+ readonly t: Translate
761
+ }) {
762
+ const run = useCallback((): void => {
763
+ close()
764
+ action.run()
765
+ }, [action, close])
766
+ return (
767
+ <MenuItemButton
768
+ separatorBefore={action.separated === true}
769
+ disabled={action.disabled === true}
770
+ onSelect={run}
771
+ >
772
+ {t(action.label)}
773
+ </MenuItemButton>
774
+ )
775
+ }
776
+
715
777
  /** File actions live only while their owning tab is visible. */
716
778
  function FileMenu({ name, file, handlers, t }: {
717
779
  readonly name: string
@@ -720,6 +782,7 @@ function FileMenu({ name, file, handlers, t }: {
720
782
  readonly t: Translate
721
783
  }): ReactNode {
722
784
  const [menuOpen, setMenuOpen] = useState(false)
785
+ const close = useCallback((): void => { setMenuOpen(false) }, [])
723
786
  return (
724
787
  <Menu
725
788
  open={menuOpen}
@@ -727,7 +790,7 @@ function FileMenu({ name, file, handlers, t }: {
727
790
  align="end"
728
791
  dense
729
792
  autoFocus
730
- onClose={() => { setMenuOpen(false) }}
793
+ onClose={close}
731
794
  anchor={(
732
795
  <button
733
796
  type="button"
@@ -742,17 +805,7 @@ function FileMenu({ name, file, handlers, t }: {
742
805
  )}
743
806
  >
744
807
  {handlers.actions(file).map(action => (
745
- <MenuItemButton
746
- key={action.label}
747
- separatorBefore={action.separated === true}
748
- disabled={action.disabled === true}
749
- onSelect={() => {
750
- setMenuOpen(false)
751
- action.run()
752
- }}
753
- >
754
- {t(action.label)}
755
- </MenuItemButton>
808
+ <FileMenuAction key={action.label} action={action} close={close} t={t} />
756
809
  ))}
757
810
  {menuOpen && <div className={css.menuPlugins}>{handlers.fileMenu(file, () => { setMenuOpen(false) })}</div>}
758
811
  </Menu>
@@ -792,7 +845,8 @@ function WriteTool({ kind, name, file, disabled, handlers, t }: {
792
845
  */
793
846
  function DiffFileSection(props: DiffFileProps): ReactNode {
794
847
  const {
795
- file, expanded, large, revealed, badge, tooltip, viewed, viewedNote, viewedDisabled, writes, writing = false, threads, handlers, t,
848
+ file, expanded, large, revealed, badge, badgeLetter, tooltip, viewed, viewedNote, viewedDisabled, writes, writing = false,
849
+ threads, handlers, t,
796
850
  } = props
797
851
  const name = file.path.slice(file.path.lastIndexOf('/') + 1)
798
852
  const element = useRef<HTMLElement | null>(null)
@@ -841,7 +895,15 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
841
895
  </Tooltip>
842
896
  )}
843
897
  <span className={css.fileSpacer} data-forge-path-spacer="" />
844
- {badge !== '' && <span className={css.badge}>{badge}</span>}
898
+ {badge !== '' && (
899
+ // The tooltip repeats the badge's words where they are cut: past half the title, or to their letter in a narrow view.
900
+ <Tooltip label={badge} side="bottom" portal delayMs={500} openOnClick onlyWhenClipped>
901
+ <span className={css.badge} data-forge-file-badge="">
902
+ <span className={css.badgeText}>{badge}</span>
903
+ <span className={css.badgeLetter} aria-hidden="true">{badgeLetter}</span>
904
+ </span>
905
+ </Tooltip>
906
+ )}
845
907
  </span>
846
908
  {!file.binary && <Counts file={file} t={t} />}
847
909
  {writes !== undefined && (
@@ -1,6 +1,6 @@
1
1
  /** Environment section rows: the Session's checkout, its branch changes, and a lost panel stream. */
2
2
 
3
- import { useEffect, useRef, useState, type ReactNode } from 'react'
3
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
4
4
  import {
5
5
  Button, IconBranchOutlineRegular, IconEllipsisOutlineRegular, IconFilesDiffOutlineRegular, IconWarningTriangleOutlineRegular,
6
6
  MarqueeText, Menu, StateDot, Tooltip, useHoverMarquee,
@@ -202,6 +202,16 @@ export function LocalChangesRow({
202
202
  && openChangeRequestOf(snapshot.state) === undefined)
203
203
  const inCheckout = usePanel(snapshot => snapshot.state?.checkout.state === 'ready')
204
204
  const [open, setOpen] = useState(false)
205
+ const view = useCallback((): void => {
206
+ viewLocalChanges()
207
+ dismissOverlay()
208
+ }, [dismissOverlay, viewLocalChanges])
209
+ const close = useCallback((): void => { setOpen(false) }, [])
210
+ const select = useCallback((id: string): void => {
211
+ setOpen(false)
212
+ if (id === 'create') createChangeRequest()
213
+ else view()
214
+ }, [createChangeRequest, view])
205
215
  if (!inCheckout) return null
206
216
  let additions = 0
207
217
  let deletions = 0
@@ -210,10 +220,6 @@ export function LocalChangesRow({
210
220
  deletions += file.deletions
211
221
  }
212
222
  const count = local?.files.length ?? 0
213
- const view = (): void => {
214
- viewLocalChanges()
215
- dismissOverlay()
216
- }
217
223
  return (
218
224
  <div className={css.envRow} data-session-panel-row="" data-forge-local="">
219
225
  <button
@@ -237,7 +243,7 @@ export function LocalChangesRow({
237
243
  <span data-row-part="menu">
238
244
  <Menu
239
245
  open={open}
240
- onClose={() => { setOpen(false) }}
246
+ onClose={close}
241
247
  portal
242
248
  align="end"
243
249
  anchor={(
@@ -255,11 +261,7 @@ export function LocalChangesRow({
255
261
  { id: 'view', label: t('change.viewChanges') },
256
262
  ...creatable ? [{ id: 'create', label: t('changes.local.create') }] : [],
257
263
  ]}
258
- onSelect={(id) => {
259
- setOpen(false)
260
- if (id === 'create') createChangeRequest()
261
- else view()
262
- }}
264
+ onSelect={select}
263
265
  />
264
266
  </span>
265
267
  </div>
@@ -6,43 +6,41 @@
6
6
  min-width: 0;
7
7
  }
8
8
 
9
- /* The name keeps its natural width; the directory takes only the space left, so it shortens first. */
9
+ /* One line shows. The name keeps its natural width and the directory takes only the space left, so the directory
10
+ shortens first; a directory without room for its floor wraps to a second line, which the height cuts off, and the
11
+ name then shortens on a line of its own. */
10
12
  .parts {
11
13
  display: flex;
14
+ flex-wrap: wrap;
12
15
  align-items: baseline;
13
- gap: 6px;
16
+ column-gap: 6px;
14
17
  min-width: 0;
18
+ max-height: 1.5em;
19
+ max-height: 1lh;
15
20
  overflow: hidden;
16
21
  white-space: nowrap;
17
22
  }
18
23
 
24
+ .name,
25
+ .directory {
26
+ overflow: hidden;
27
+ text-overflow: ellipsis;
28
+ }
29
+
19
30
  .name {
20
31
  flex: 0 1 auto;
32
+ min-width: 0;
21
33
  color: var(--dsw-alias-label-primary);
22
34
  }
23
35
 
36
+ /* `FileLabel` sets the floor: the directory's own length, or the fewest characters worth showing. */
24
37
  .directory {
25
38
  flex: 1 1 0;
39
+ min-width: var(--forge-directory-floor);
26
40
  color: var(--dsw-alias-label-tertiary);
27
41
  font-size: 11px;
28
42
  }
29
43
 
30
- .shortened {
31
- display: flex;
32
- min-width: 0;
33
- overflow: hidden;
34
- }
35
-
36
- .head {
37
- min-width: 0;
38
- overflow: hidden;
39
- text-overflow: ellipsis;
40
- }
41
-
42
- .tail {
43
- flex: none;
44
- }
45
-
46
44
  .visuallyHidden {
47
45
  position: absolute;
48
46
  width: 1px;
@@ -1,45 +1,24 @@
1
1
  /**
2
- * The label of a changed file in the files menu, the local changes list, and a
3
- * file's header: its name, then its directory in smaller subdued type, with the
4
- * complete path in a tooltip.
2
+ * The label of a changed file in a file's header and the thread list: its name, then its directory in smaller subdued
3
+ * type, each on one line that ends in an ellipsis when space runs out, with the complete path in a tooltip.
5
4
  */
6
5
 
7
- import type { ReactNode } from 'react'
6
+ import type { CSSProperties, ReactNode } from 'react'
8
7
  import clsx from 'clsx'
9
8
  import { Tooltip } from '@deepseek-ai/dsh-client-ui-primitives/client'
10
9
  import { pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path'
11
10
  import css from './FileLabel.module.css'
12
11
 
13
- /** Characters at the end of a name or directory that stay whole while its start shortens. */
14
- const KEPT_END = 12
15
-
16
- /** Shortest start worth shortening; a text this much longer than its kept end is split. */
17
- const MIN_START = 4
12
+ /** Characters of a directory that show before it gives up its place: a shorter stub tells nothing of the path. */
13
+ const DIRECTORY_FLOOR = 12
18
14
 
19
15
  /** Hover delay before the complete path shows, so moving across a list does not flash it. */
20
16
  const TOOLTIP_DELAY_MS = 500
21
17
 
22
- /** Split off the end that stays whole, by characters so a surrogate pair is never cut. */
23
- function partsOf(text: string): { readonly start: string; readonly end: string } {
24
- const characters = Array.from(text)
25
- if (characters.length <= KEPT_END + MIN_START) return { start: text, end: '' }
26
- return { start: characters.slice(0, -KEPT_END).join(''), end: characters.slice(-KEPT_END).join('') }
27
- }
28
-
29
- /** One text whose start ends in an ellipsis when space runs out, while its end stays whole. */
30
- function Shortened({ text, className }: { readonly text: string; readonly className: string | undefined }): ReactNode {
31
- const { start, end } = partsOf(text)
32
- return (
33
- <span className={clsx(css.shortened, className)}>
34
- <span className={css.head}>{start}</span>
35
- {end !== '' && <span className={css.tail}>{end}</span>}
36
- </span>
37
- )
38
- }
39
-
40
18
  /**
41
- * Render a changed file's name and directory. The directory gives up its space
42
- * before the name does; assistive technology reads the complete path.
19
+ * Render a changed file's name and directory. The directory takes only the space the name leaves and shortens at its
20
+ * end; it shows nothing once fewer than {@link DIRECTORY_FLOOR} of its characters fit. The name then shortens at its
21
+ * end. Assistive technology reads the complete path.
43
22
  * @param props.path - the file's path in the repository.
44
23
  * @param props.tooltip - the hover text, such as both paths of a renamed file; defaults to the path.
45
24
  * @param props.className - class of the outer element, which callers size within their row.
@@ -52,12 +31,17 @@ export function FileLabel({ path, tooltip, className }: {
52
31
  }): ReactNode {
53
32
  const { directory, name } = pathPartsOf(path)
54
33
  const folder = directory.replace(/[/\\]$/, '')
34
+ // By characters, so a surrogate pair counts once; `ch` over-measures a little in a proportional font, which only
35
+ // hides a directory a few pixels early.
36
+ const floor: CSSProperties & { '--forge-directory-floor': string } = {
37
+ '--forge-directory-floor': `${Math.min(Array.from(folder).length, DIRECTORY_FLOOR)}ch`,
38
+ }
55
39
  return (
56
40
  <Tooltip label={tooltip ?? path} side="bottom" portal delayMs={TOOLTIP_DELAY_MS} maxWidth={360}>
57
41
  <span className={clsx(css.label, className)} data-forge-file-label="">
58
42
  <span className={css.parts} aria-hidden="true">
59
- <Shortened text={name} className={css.name} />
60
- {folder !== '' && <Shortened text={folder} className={css.directory} />}
43
+ <span className={css.name}>{name}</span>
44
+ {folder !== '' && <span className={css.directory} style={floor}>{folder}</span>}
61
45
  </span>
62
46
  <span className={css.visuallyHidden}>{path}</span>
63
47
  </span>
@@ -145,6 +145,8 @@
145
145
  .diff {
146
146
  display: inline-flex;
147
147
  gap: 8px;
148
+ /* The case-sensitive forms of the UI font centre `+` and `−` on the digits; its default forms sit lower. */
149
+ font-feature-settings: 'case';
148
150
  font-variant-numeric: tabular-nums;
149
151
  }
150
152
 
@@ -481,15 +483,6 @@
481
483
  }
482
484
  }
483
485
 
484
- .attention {
485
- position: absolute;
486
- inset: 0;
487
- border-radius: 50%;
488
- corner-shape: round;
489
- background: var(--dsw-alias-state-warn-primary);
490
- box-shadow: 0 0 0 1.5px var(--dsw-alias-bg-base);
491
- }
492
-
493
486
  /* The unresolved review thread count at the end of the changes row. */
494
487
  .threads {
495
488
  display: inline-flex;
@@ -498,7 +491,7 @@
498
491
  color: var(--dsw-alias-label-secondary);
499
492
  }
500
493
 
501
- /* Text read only by assistive technology: a fact row's name and the attention mark's description. */
494
+ /* Text read only by assistive technology: a fact row's name. */
502
495
  .visuallyHidden {
503
496
  position: absolute;
504
497
  width: 1px;