@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
@@ -12,7 +12,7 @@
12
12
 
13
13
  import {
14
14
  useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type KeyboardEvent,
15
- type ReactNode,
15
+ type ReactNode, type RefObject,
16
16
  } from 'react'
17
17
  import clsx from 'clsx'
18
18
  import {
@@ -22,14 +22,19 @@ import {
22
22
  Menu, Modal, Tooltip,
23
23
  type MenuEntry,
24
24
  } from '@deepseek-ai/dsh-client-ui-primitives/client'
25
- import type { HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots/client'
25
+ import type {
26
+ GlobalStandardProps, HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore,
27
+ } from '@deepseek-ai/dsh-client-ui-slots/client'
28
+ // Type-only: the `useMediaQuery` standard prop merge.
29
+ import type {} from '@deepseek-ai/dsh-client-ui-responsive/client'
26
30
  import type { SidebarRightTabInfo } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
27
31
  import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
28
32
  import { assertNever } from '@deepseek-ai/dsh-util-values'
29
33
  import { fileAddressFor, pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path'
30
34
  import type {
31
- ForgeBaseBranch, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeExtensionState, ForgeLensFrame,
32
- ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope, ForgeLocalWrite, ForgeLocalWriteResult,
35
+ ForgeBaseBranch, ForgeBaseBranches, ForgeChangeCommits, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeExtensionState,
36
+ ForgeLensFrame, ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope, ForgeLocalWrite,
37
+ ForgeLocalWriteResult,
33
38
  } from '../types.ts'
34
39
  import { restorable } from '../restore.ts'
35
40
  import { lensVersion } from '../lens-version.ts'
@@ -46,11 +51,12 @@ import { BaseMenu } from './BaseMenu.tsx'
46
51
  import { HeadMenu } from './HeadMenu.tsx'
47
52
  import { parseChangesAddress, type ChangesSource, type ChangesTarget } from './changes-address.ts'
48
53
  import type { ChangesHead, ChangesLens, createChangesStore } from './changes-store.ts'
54
+ import { ChangeStatus, type BoundStatusActions, type ChangeStatusFacts } from './ChangeStatus.tsx'
49
55
  import { CommitMenu } from './CommitMenu.tsx'
50
56
  import { HideTestsSwitch, LensControl, LensMenu, LENSES, ViewedProgress } from './ReviewControls.tsx'
51
57
  import { viewedStateOf, type ViewedFiles, type ViewedMarks } from './viewed-files.ts'
52
58
  import { hostViewedOf, useHostViewed, type HostViewed } from './host-viewed.ts'
53
- import { Counts, DiffFile, type DiffFileAction, type DiffFileHandlers } from './DiffFile.tsx'
59
+ import { Counts, countsColumn, DiffFile, type DiffFileAction, type DiffFileHandlers } from './DiffFile.tsx'
54
60
  import { SectionReach } from './section-reach.ts'
55
61
  import { FileTreePane, type FileTreePosition } from './FileTreePane.tsx'
56
62
  import { changedFileTree, filesInTreeOrder } from './file-tree.ts'
@@ -68,7 +74,7 @@ import type { SourcedAnnotation, ViewAnnotations } from './annotations.ts'
68
74
  import { foldedHunks, useLensRun } from './lens-filter.ts'
69
75
  import { LensFilterMenu, type LensChoice } from './LensFilter.tsx'
70
76
  import type {} from './slots.ts'
71
- import { observeToolbarFold } from './toolbar-fold.ts'
77
+ import { observeHeaderFold, observeToolbarFold } from './toolbar-fold.ts'
72
78
  import type { FileThreads, ThreadActions, ThreadFocus, ThreadWrite } from './ReviewThreads.tsx'
73
79
  import { inFileOrder, type ThreadFilter } from './review-threads.ts'
74
80
  import { usePlacedThreads, useThreadRead, type PlacedThread } from './thread-state.ts'
@@ -82,10 +88,13 @@ type Translate = PropsLocale<typeof NS>['t']
82
88
  /** Kind of a local scope. */
83
89
  type ScopeKind = ForgeLocalScope['kind']
84
90
 
85
- /** A file the view scrolls to once, and the thread card it centers there with whether that card takes the focus. */
91
+ /**
92
+ * A file the view scrolls to once, and the thread card it centers there with whether that card takes the focus. The
93
+ * thread's web page opens instead when the changes read by then lack the file; null without a page.
94
+ */
86
95
  interface Wanted {
87
96
  readonly path: string
88
- readonly center: { readonly id: ForgeThreadId; readonly focus: boolean } | null
97
+ readonly center: { readonly id: ForgeThreadId; readonly focus: boolean; readonly url: string | null } | null
89
98
  }
90
99
 
91
100
  /** Business face of the changes tab body. */
@@ -104,11 +113,17 @@ export interface ChangesTabInjected {
104
113
  readonly panel: (visibility: string) => HostObservable<PanelSnapshot> | undefined
105
114
  readonly annotations: (address: string) => HostObservable<ViewAnnotations>
106
115
  }
107
- /** Lens titles Client plugins describe and the Host's lenses and annotation limit; bound as `useLenses` and `useExtensions`. */
116
+ /**
117
+ * Lens titles Client plugins describe, the Host's lenses and annotation limit, and the active UI language; bound as
118
+ * `useLenses`, `useExtensions`, and `useLocale`.
119
+ */
108
120
  readonly hooks: {
109
121
  readonly lenses: HostObservable<readonly ForgeLensDescription[]>
110
122
  readonly extensions: HostObservable<StreamSnapshot<ForgeExtensionState | null>>
123
+ readonly locale: HostObservable<string>
111
124
  }
125
+ /** The actions the status blocks of a change request's view run on it, beyond opening a link. */
126
+ readonly changeActions: BoundStatusActions
112
127
  /** Classify the shown files with a Host lens; `signal` aborts the stream. */
113
128
  readonly changesLens: (request: ForgeLensRequest, signal: AbortSignal) => HostStream<ForgeLensFrame>
114
129
  /** Open the panel stream again after it ended. */
@@ -131,7 +146,7 @@ export interface ChangesTabInjected {
131
146
  readonly localCommits: (head: string | null, base: string | null, signal: AbortSignal) => Promise<RemoteResult<ForgeLocalCommits>>
132
147
  /** Read the changes of a change request, or of consecutive commits of it, by its binding URL; `signal` aborts the read. */
133
148
  readonly changeRequestDiff: (
134
- url: string, commits: ForgeCommitRange | null, signal: AbortSignal,
149
+ url: string, commits: ForgeChangeCommits | null, signal: AbortSignal,
135
150
  ) => Promise<RemoteResult<ForgeChangeRequestDiff>>
136
151
  /** List the commits of a change request, or null when its provider does not read commits; `signal` aborts the read. */
137
152
  readonly changeRequestCommits: (url: string, signal: AbortSignal) => Promise<RemoteResult<ForgeCommitList | null>>
@@ -174,6 +189,7 @@ export type ChangesTabProps =
174
189
  & PropsStore<ReturnType<typeof createChangesStore>>
175
190
  & InjectFace<ChangesTabInjected>
176
191
  & PropsLocale<typeof NS>
192
+ & Pick<GlobalStandardProps, 'useMediaQuery'>
177
193
 
178
194
  /** The tab facts the changes view reads: its sidebar tab's, or the review page's for one change request. */
179
195
  export interface ChangesViewTab extends Pick<SidebarRightTabInfo['tab'], 'visible' | 'navigation' | 'signal'> {
@@ -183,8 +199,11 @@ export interface ChangesViewTab extends Pick<SidebarRightTabInfo['tab'], 'visibl
183
199
  readonly actions: Pick<SidebarRightTabInfo['tab']['actions'], 'bindCommands'>
184
200
  }
185
201
 
202
+ /** The tab's props that it resolves itself before it draws the view. */
203
+ type TabOnlyProps = 'useTabInfo' | 'sessionId' | 'usePanel' | 'useAnnotations' | 'useLocale' | 'useMediaQuery' | 'changeActions'
204
+
186
205
  /** Props of the changes view, which the changes tab and the review page draw. */
187
- export type ChangesViewProps = Omit<ChangesTabProps, 'useTabInfo' | 'sessionId' | 'usePanel' | 'useAnnotations'> & {
206
+ export type ChangesViewProps = Omit<ChangesTabProps, TabOnlyProps> & {
188
207
  /** Tab facts. */
189
208
  readonly tab: ChangesViewTab
190
209
  /** What the view shows. */
@@ -199,6 +218,11 @@ export type ChangesViewProps = Omit<ChangesTabProps, 'useTabInfo' | 'sessionId'
199
218
  readonly openFile: ((path: string) => void) | undefined
200
219
  /** Copy of the quote actions where they quote somewhere other than the Session's input. */
201
220
  readonly quoteCopy?: QuoteCopy | undefined
221
+ /**
222
+ * What the status control of a change request's view needs; undefined where the surroundings show the status, as on
223
+ * the review page, and the view then has no such control.
224
+ */
225
+ readonly status?: ChangeStatusFacts | undefined
202
226
  }
203
227
 
204
228
  /** Changes of either source as the view draws them. */
@@ -222,10 +246,10 @@ type ChangesData =
222
246
  readonly files: readonly ForgeDiffFile[]
223
247
  /** Binding URL of the change request. */
224
248
  readonly url: string
225
- /** Commit the files end at, the head or the last chosen commit, which supplies unchanged lines. */
249
+ /** Commit the files end at: the head, the last chosen commit, or the commit they go up to; it supplies unchanged lines. */
226
250
  readonly headSha: string
227
251
  /** Commits the files cover, or null for the whole change request. */
228
- readonly commits: ForgeCommitRange | null
252
+ readonly commits: ForgeChangeCommits | null
229
253
  /** Commits the checkout's branch has beyond the head, or null. */
230
254
  readonly localAhead: number | null
231
255
  /** Web page of each file at the head. */
@@ -259,6 +283,8 @@ const NO_FOLDS: ReadonlyMap<string, { readonly hunks: ReadonlySet<number>; reado
259
283
 
260
284
  const NO_PATHS: ReadonlySet<string> = new Set()
261
285
 
286
+ const NO_COMMITS: ReadonlySet<string> = new Set()
287
+
262
288
  const NO_ANNOTATIONS: ViewAnnotations = new Map()
263
289
 
264
290
  /** The toolbar row's close action, which has no menu to close. */
@@ -325,7 +351,7 @@ async function readChanges(
325
351
  source: ChangesSource,
326
352
  scope: ForgeLocalScope,
327
353
  localHead: ChangesHead | null,
328
- commits: ForgeCommitRange | null,
354
+ commits: ForgeChangeCommits | null,
329
355
  head: string | null,
330
356
  fresh: boolean,
331
357
  reads: Pick<ChangesTabInjected, 'localDiff' | 'changeRequestDiff' | 'changeRequestViewed'>,
@@ -358,6 +384,11 @@ function baseRefOf(scope: ForgeLocalScope): string | null {
358
384
  return scope.kind === 'branch' ? scope.base : null
359
385
  }
360
386
 
387
+ /** The consecutive commits among a tab's chosen commits, or null for all commits and for changes up to one commit. */
388
+ function rangeOf(commits: ForgeChangeCommits | null): ForgeCommitRange | null {
389
+ return commits !== null && 'from' in commits ? commits : null
390
+ }
391
+
361
392
  /** The commits a local scope shows, or null for all of them and for scopes other than `branch`. */
362
393
  function commitsOf(scope: ForgeLocalScope): ForgeCommitRange | null {
363
394
  return scope.kind === 'branch' ? scope.commits : null
@@ -366,9 +397,10 @@ function commitsOf(scope: ForgeLocalScope): ForgeCommitRange | null {
366
397
  /**
367
398
  * The source review comments on loaded changes record: the change request head, or the local scope with its base and,
368
399
  * for another branch than the Session's checked-out one, that branch with the worktree the changes were read in.
400
+ * Changes up to a commit are the whole change request as that commit ended it, so they record that commit as the head.
369
401
  */
370
402
  function reviewSourceOf(data: ChangesData): ReviewSource {
371
- if (data.kind === 'change') return { kind: 'change', url: data.url, headSha: data.headSha, commits: data.commits }
403
+ if (data.kind === 'change') return { kind: 'change', url: data.url, headSha: data.headSha, commits: rangeOf(data.commits) }
372
404
  const head: ReviewHead | undefined = data.head === null ? undefined : { key: data.head.ref, name: data.head.name, root: data.worktree }
373
405
  return {
374
406
  kind: 'local', scope: data.scope.kind, base: data.base, baseRef: baseRefOf(data.scope), commits: commitsOf(data.scope),
@@ -424,19 +456,54 @@ function pathTooltipOf(file: ForgeDiffFile, t: Translate): string {
424
456
  return file.status === 'renamed' && file.previousPath !== null ? t('diff.renamedPath', { from: file.previousPath, path: file.path }) : file.path
425
457
  }
426
458
 
459
+ /** The badge after a path and the letter a narrow view draws in its place. */
460
+ interface FileBadge {
461
+ readonly text: string
462
+ /** Git's status letter for the change, or `U` for an untracked file as editors mark it; the same in every language. */
463
+ readonly letter: string
464
+ }
465
+
427
466
  /** The badge after a path: how the file changed, and whether a branch view's file is untracked. */
428
- function badgeOf(file: ForgeDiffFile, data: ChangesData, t: Translate): string {
467
+ function badgeOf(file: ForgeDiffFile, data: ChangesData, t: Translate): FileBadge {
429
468
  const parts: string[] = []
430
- if (file.status === 'added') parts.push(t('diff.newFile'))
431
- else if (file.status === 'deleted') parts.push(t('diff.deletedFile'))
432
- else if (file.status === 'renamed' && file.previousPath !== null) parts.push(t('diff.renamed', { from: renamedFrom(file.previousPath, file.path) }))
433
- if (file.untracked && data.kind === 'local' && data.scope.kind === 'branch') parts.push(t('diff.badgeUncommitted'))
434
- return parts.join(' · ')
469
+ let letter = ''
470
+ if (file.status === 'added') {
471
+ parts.push(t('diff.newFile'))
472
+ letter = 'A'
473
+ } else if (file.status === 'deleted') {
474
+ parts.push(t('diff.deletedFile'))
475
+ letter = 'D'
476
+ } else if (file.status === 'renamed' && file.previousPath !== null) {
477
+ parts.push(t('diff.renamed', { from: renamedFrom(file.previousPath, file.path) }))
478
+ letter = 'R'
479
+ }
480
+ if (file.untracked && data.kind === 'local' && data.scope.kind === 'branch') {
481
+ parts.push(t('diff.badgeUncommitted'))
482
+ letter = 'U'
483
+ }
484
+ return { text: parts.join(' · '), letter }
485
+ }
486
+
487
+ /**
488
+ * Fold a header row for as long as it shows: its names shorten first, then its controls take their compact forms.
489
+ * @returns the ref of the row.
490
+ */
491
+ function useHeaderFold(): RefObject<HTMLDivElement | null> {
492
+ const row = useRef<HTMLDivElement>(null)
493
+ useLayoutEffect(() => {
494
+ /* v8 ignore next -- a header renders its row whenever it renders */
495
+ if (row.current === null) return
496
+ return observeHeaderFold(row.current)
497
+ }, [])
498
+ return row
435
499
  }
436
500
 
437
- function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDisabled, onReview, t }: {
501
+ function ChangeHeader({ url, entry, status, openLink, commitMenu, reviewCount, reviewDisabled, onReview, t }: {
438
502
  readonly url: string
503
+ /** The change request's panel entry; undefined before the panel names it and while the tab is hidden, which reads no panel state. */
439
504
  readonly entry: ChangeRequestEntry | undefined
505
+ /** What the status control needs, or undefined for a view without one. */
506
+ readonly status: ChangeStatusFacts | undefined
440
507
  /** Commit picker left of the review button. */
441
508
  readonly commitMenu: ReactNode
442
509
  readonly reviewCount: number
@@ -449,12 +516,22 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
449
516
  const number = numberOf(entry ?? { ref: null, url })
450
517
  const tone = toneOf(snapshot)
451
518
  const href = snapshot === null ? url : snapshot.url
519
+ const row = useHeaderFold()
520
+ const title = snapshot === null ? url : snapshot.title
452
521
  return (
453
- <div className={css.header}>
522
+ <div ref={row} className={css.header}>
454
523
  <ChangeRequestGlyph tone={tone} label={t('change.stateAria', { state: t(TONE_LABEL[tone]) })} />
455
- <span className={css.headerTitle}>{snapshot === null ? url : snapshot.title}</span>
456
- {number !== null && <span className={css.headerNumber}>{t('change.number', { number })}</span>}
524
+ <span className={css.headerName}>
525
+ <Tooltip label={title} side="bottom" portal delayMs={500} maxWidth={360} onlyWhenClipped>
526
+ <span className={css.headerTitle} data-fold-floor="">{title}</span>
527
+ </Tooltip>
528
+ {number !== null && <span className={css.headerNumber}>{t('change.number', { number })}</span>}
529
+ </span>
457
530
  <span className={css.headerEnd}>
531
+ {/* A hidden tab has no entry, so the control unmounts there with its open panel and the menus of its blocks. */}
532
+ {status !== undefined && entry !== undefined && snapshot !== null && (
533
+ <ChangeStatus entry={entry} snapshot={snapshot} {...status} t={t} />
534
+ )}
458
535
  {commitMenu}
459
536
  <Button size="sm" variant="outline" className={css.headerAction} disabled={reviewDisabled} onClick={onReview}>
460
537
  {t('review.submit')}{reviewCount > 0 ? ` (${reviewCount})` : ''}
@@ -470,9 +547,9 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
470
547
  }
471
548
 
472
549
  /**
473
- * The local view's header: the head picker, then for the `branch` scope the base branch picker and, while a working
474
- * tree is read, a note that uncommitted changes count; for another scope, what it compares. Writes and the create
475
- * button belong to the Session's own checkout.
550
+ * The local view's header: the head picker, then for the `branch` scope the base branch picker, whose menu says
551
+ * whether uncommitted changes count; for another scope, what it compares. Writes and the create button belong to the
552
+ * Session's own checkout.
476
553
  */
477
554
  function LocalHeader({
478
555
  state, scope, head, headMissing, base, baseLabel, missing, visible, diffBases, chooseHead, choose, commitMenu, bulk, createChangeRequest,
@@ -508,24 +585,39 @@ function LocalHeader({
508
585
  const listHeads = useCallback((query: string, signal: AbortSignal) => diffBases(null, query, signal), [diffBases])
509
586
  // A branch that no worktree has checked out is read from its commits; a checkout's comparison counts its uncommitted changes.
510
587
  const committedOnly = head !== null && head.worktree === null
588
+ const baseNote = t(committedOnly ? 'diff.base.noteCommitted' : 'diff.base.note')
589
+ // The base the automatic choice compares with: the panel's for the Session's own checkout, else the one the diff was read with.
590
+ const automaticBase = head === null ? state?.local?.base : baseLabel
591
+ const row = useHeaderFold()
511
592
  return (
512
- <div className={css.header}>
593
+ <div ref={row} className={css.header}>
513
594
  <span className={css.headerIcon}><IconBranchOutlineRegular size={15} /></span>
514
595
  <HeadMenu chosen={head} own={checkout?.branch ?? checkout?.commit ?? GIT_HEAD} missing={headMissing} visible={visible}
515
596
  list={listHeads} choose={chooseHead} t={t} />
516
597
  {scope === 'branch' ? <>
517
598
  <span className={css.headerArrow} aria-hidden="true">→</span>
518
- <BaseMenu chosen={base} label={base?.name ?? (head === null ? state?.local?.base : baseLabel) ?? t('diff.base.automatic')}
519
- missing={missing} note={t(committedOnly ? 'diff.base.noteCommitted' : 'diff.base.note')}
599
+ <BaseMenu chosen={base} label={base?.name ?? automaticBase ?? t('diff.base.automatic')}
600
+ missing={missing} note={baseNote}
520
601
  visible={visible} list={listBases} choose={choose} t={t} />
521
- {!committedOnly && <span className={clsx(css.headerNote, css.headerSuffix)}>{t('diff.base.uncommitted')}</span>}
522
- </> : <span className={css.headerNote}>{t(SCOPE_NOTE[scope])}</span>}
602
+ </> : (
603
+ <Tooltip label={t(SCOPE_NOTE[scope])} side="bottom" portal delayMs={500} onlyWhenClipped>
604
+ <span className={css.headerNote}>{t(SCOPE_NOTE[scope])}</span>
605
+ </Tooltip>
606
+ )}
523
607
  {(scope === 'branch' || creatable || bulk !== null) && <span className={css.headerEnd} data-forge-header-buttons={scope === 'branch' ? undefined : ''}>
524
608
  {scope === 'branch' && commitMenu}
525
609
  {bulk !== null && (
526
610
  <Button size="sm" variant="outline" className={css.headerAction} disabled={bulk.disabled} data-forge-write-all="" onClick={bulk.run}>{bulk.label}</Button>
527
611
  )}
528
- {creatable && <Button size="sm" variant="outline" className={css.headerAction} onClick={createChangeRequest}>{t('changes.local.create')}</Button>}
612
+ {creatable && (
613
+ // The tooltip names the button only in its icon form, where the label is cut off.
614
+ <Tooltip label={t('changes.local.create')} side="bottom" align="end" portal delayMs={500} onlyWhenClipped>
615
+ <Button size="sm" variant="outline" className={clsx(css.headerAction, css.compactable)} onClick={createChangeRequest}>
616
+ <span className={css.compactIcon} aria-hidden="true"><ChangeRequestGlyph tone="open" tinted={false} size={15} /></span>
617
+ <span className={css.compactText}>{t('changes.local.create')}</span>
618
+ </Button>
619
+ </Tooltip>
620
+ )}
529
621
  </span>}
530
622
  </div>
531
623
  )
@@ -537,6 +629,11 @@ function ScopeMenu({ scope, choose, t }: {
537
629
  readonly t: Translate
538
630
  }): ReactNode {
539
631
  const [open, setOpen] = useState(false)
632
+ const close = useCallback((): void => { setOpen(false) }, [])
633
+ const select = useCallback((id: string): void => {
634
+ setOpen(false)
635
+ choose(id as ScopeKind)
636
+ }, [choose])
540
637
  const items: MenuEntry[] = [
541
638
  { id: 'uncommitted', label: t(SCOPE_LABEL.uncommitted) },
542
639
  { id: 'unstaged', label: t(SCOPE_LABEL.unstaged) },
@@ -553,11 +650,8 @@ function ScopeMenu({ scope, choose, t }: {
553
650
  autoFocus
554
651
  selectedId={scope}
555
652
  items={items}
556
- onClose={() => { setOpen(false) }}
557
- onSelect={(id) => {
558
- setOpen(false)
559
- choose(id as ScopeKind)
560
- }}
653
+ onClose={close}
654
+ onSelect={select}
561
655
  anchor={(
562
656
  <button type="button" className={css.select} aria-haspopup="menu" aria-expanded={open} data-forge-scope={scope}
563
657
  onClick={() => { setOpen(value => !value) }}>
@@ -597,8 +691,15 @@ function OrphanReviews({ path, actions, t }: PropsLocale<typeof NS> & {
597
691
  * @param props - tab information, the tab's choices, the panel snapshot hook, reads and actions, and copy.
598
692
  * @returns the view body.
599
693
  */
600
- export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ...props }: ChangesTabProps): ReactNode {
694
+ export function ChangesTab({
695
+ useTabInfo, sessionId, usePanel, useAnnotations, useLocale, useMediaQuery, changeActions, ...props
696
+ }: ChangesTabProps): ReactNode {
601
697
  const { tab } = useTabInfo()
698
+ const locale = useLocale(value => value)
699
+ const coarsePointer = useMediaQuery('(pointer: coarse)')
700
+ const { openLink } = props
701
+ const status = useMemo(() => ({ locale, coarsePointer, actions: { ...changeActions, openLink } }),
702
+ [locale, coarsePointer, changeActions, openLink])
602
703
  const target = useMemo(() => parseChangesAddress(tab.contentId), [tab.contentId])
603
704
  if (target === undefined) throw new Error(`forge-panel: not a changes address "${tab.contentId}"`)
604
705
  const snapshot = usePanel(tab.visible ? 'visible' : 'inactive')
@@ -608,7 +709,7 @@ export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ..
608
709
  tabActions.openResource(fileAddressFor(sessionId, undefined, path))
609
710
  }, [tabActions, sessionId])
610
711
  return <ChangesView {...props} tab={tab} source={target.source} target={target} snapshot={snapshot} annotations={annotations}
611
- openFile={openFile} />
712
+ openFile={openFile} status={status} />
612
713
  }
613
714
 
614
715
  /**
@@ -617,7 +718,8 @@ export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ..
617
718
  * @returns the view body.
618
719
  */
619
720
  export function ChangesView({
620
- tab, source, target: viewTarget, snapshot, annotations: viewAnnotations, openFile, quoteCopy, useStore, actions, reconnect, localDiff,
721
+ tab, source, target: viewTarget, snapshot, annotations: viewAnnotations, openFile, quoteCopy, status, useStore, actions, reconnect,
722
+ localDiff,
621
723
  localWrite, diffBases, localText,
622
724
  localCommits, changeRequestDiff, changeRequestText, changeRequestCommits, changeRequestReview, changeRequestReviewWrite, viewedFiles,
623
725
  changeRequestViewed, setFileViewed, openLink, copyPath, createChangeRequest, addReviewToInput, addThreadToInput, reviewQueue,
@@ -753,7 +855,7 @@ export function ChangesView({
753
855
  // The Session's own checkout names no head, so its scopes keep the identity they had before heads.
754
856
  const localScope = useMemo((): ForgeLocalScope => {
755
857
  const shown = headRef === null ? {} : { head: headRef }
756
- return scope === 'branch' ? { kind: 'branch', ...shown, base: base?.ref ?? null, commits: chosenCommits } : { kind: scope, ...shown }
858
+ return scope === 'branch' ? { kind: 'branch', ...shown, base: base?.ref ?? null, commits: rangeOf(chosenCommits) } : { kind: scope, ...shown }
757
859
  }, [scope, headRef, base, chosenCommits])
758
860
  // Other plugins contribute to the Session's own local changes; another head shows without their slots and annotations.
759
861
  const target = localHead === null ? viewTarget : null
@@ -784,6 +886,11 @@ export function ChangesView({
784
886
  const dataKey = source.kind === 'local' ? JSON.stringify(localScope) : `change\n${JSON.stringify(changeCommits)}`
785
887
  const [loaded, setLoaded] = useState<{ readonly key: string; readonly data: ChangesData } | null>(null)
786
888
  const [failure, setFailure] = useState<{ readonly key: string; readonly code: string } | null>(null)
889
+ // Commits the code host answered it does not have when the reader opened a thread written on them. Threads written on
890
+ // them are lost and open in their file's outdated section; a refresh forgets the commits, so the host is asked again.
891
+ const [goneAt, setGoneAt] = useState<{ readonly attempt: number; readonly commits: ReadonlySet<string> }>(
892
+ { attempt, commits: NO_COMMITS })
893
+ const gone = goneAt.attempt === attempt ? goneAt.commits : NO_COMMITS
787
894
  // Names the read the inputs ask for; it is in flight until `finished` matches it.
788
895
  const read = version === null ? null : `${dataKey}\n${navigation.revision}\n${attempt}\n${version}`
789
896
  const [finished, setFinished] = useState<string | null>(null)
@@ -811,6 +918,15 @@ export function ChangesView({
811
918
  setFailure(null)
812
919
  return
813
920
  }
921
+ // The code host does not have the commit the changes go up to, which a thread written on it named: the view
922
+ // returns to all commits, where that thread stays in its file's outdated section and the pending jump ends.
923
+ if (!result.ok && result.error.code === 'forgePanel/commits-missing' && changeCommits !== null && 'upTo' in changeCommits) {
924
+ const commit = changeCommits.upTo
925
+ setGoneAt(value => ({ attempt, commits: new Set([...value.attempt === attempt ? value.commits : [], commit]) }))
926
+ actions.committed(tab.id, null)
927
+ live.current.report('toast.commitGone', { params: { commit: commit.slice(0, 7) } })
928
+ return
929
+ }
814
930
  // The worktree that had the shown branch checked out is gone, so the tab falls back to the branch's commits,
815
931
  // read again because what it loaded for the `branch` scope counted that worktree's files.
816
932
  if (!result.ok && result.error.code === 'forgePanel/no-working-tree') {
@@ -842,9 +958,13 @@ export function ChangesView({
842
958
  const prAuthor = entry?.snapshot?.author ?? null
843
959
  const threadRead = useThreadRead({ visible: tab.visible, url: source.kind === 'change' ? source.url : null, head: prHead,
844
960
  updatedAt: entry?.snapshot?.updatedAt ?? null, statusAt, attempt, revision: reviewRevision + hostRevision, read: changeRequestReview })
845
- const review = data?.kind === 'change' && threadRead.review !== null && threadRead.review.headSha === prHead
846
- && (data.commits !== null || data.headSha === prHead) ? threadRead.review : null
847
- const placed = usePlacedThreads(review, data?.kind === 'change' ? { head: prHead ?? '', end: data.headSha, commits: data.commits } : null)
961
+ // While other commits of the change request load, its threads stay placed in the changes shown before, so the thread
962
+ // list and its toolbar button stay where they are, with the list's scroll position, instead of leaving and coming back.
963
+ const threadsOn = data ?? (loaded?.data.kind === 'change' && source.kind === 'change' && loaded.data.url === source.url ? loaded.data : null)
964
+ const review = threadsOn?.kind === 'change' && threadRead.review !== null && threadRead.review.headSha === prHead
965
+ && (threadsOn.commits !== null || threadsOn.headSha === prHead) ? threadRead.review : null
966
+ const placed = usePlacedThreads(review,
967
+ threadsOn?.kind === 'change' ? { head: prHead ?? '', end: threadsOn.headSha, commits: threadsOn.commits, gone } : null)
848
968
  const [threadList, setThreadList] = useState<{
849
969
  readonly open: boolean
850
970
  readonly filter: ThreadFilter
@@ -854,6 +974,9 @@ export function ChangesView({
854
974
  const threadsToggle = useRef<HTMLButtonElement>(null)
855
975
  const [focus, setFocus] = useState<ThreadFocus | null>(null)
856
976
  const allFiles = useMemo(() => filesInTreeOrder(changedFileTree(data?.files ?? [])), [data])
977
+ // The thread list orders its files as the changes its threads are placed in do.
978
+ const threadFiles = useMemo(() => data !== null || threadsOn === null ? allFiles : filesInTreeOrder(changedFileTree(threadsOn.files)),
979
+ [data, threadsOn, allFiles])
857
980
  // A Host filter lens keeps files only once its result for the shown files arrived; until then every file shows.
858
981
  const extensions = useExtensions(current => current.state)
859
982
  const descriptions = useLenses(current => current)
@@ -870,6 +993,7 @@ export function ChangesView({
870
993
  })
871
994
  const kept = lensRun.run.kind === 'ready' ? lensRun.run.files : null
872
995
  const files = useMemo(() => allFiles.filter(file => shownBy(file, lens, hideTests, kept)), [allFiles, lens, hideTests, kept])
996
+ const countColumn = useMemo(() => countsColumn(files), [files])
873
997
  const lensCounts = useMemo(() => Object.fromEntries(LENSES.map(item => [item,
874
998
  allFiles.filter(file => shownBy(file, item, hideTests, kept)).length])) as Record<ChangesLens, number>, [allFiles, hideTests, kept])
875
999
  const lensTitle = (id: string): string => {
@@ -894,7 +1018,7 @@ export function ChangesView({
894
1018
  actions.filtered(tab.id, null)
895
1019
  report('filterLens.removed', { params: { lens: live.current.lensTitle(withdrawn) } })
896
1020
  }, [withdrawn, actions, tab.id, report])
897
- const chooseLens = (next: string | null): void => { actions.filtered(tab.id, next) }
1021
+ const chooseLens = useCallback((next: string | null): void => { actions.filtered(tab.id, next) }, [actions, tab.id])
898
1022
  // The hunks each kept file folds stay folded until the reader shows them for that file; a new result folds again.
899
1023
  const [unfolded, setUnfolded] = useState<{ readonly kept: typeof kept; readonly paths: ReadonlySet<string> }>(
900
1024
  { kept: null, paths: new Set() })
@@ -933,7 +1057,7 @@ export function ChangesView({
933
1057
  const failed = failure !== null && failure.key === dataKey ? failure.code : null
934
1058
  // Review marks can refresh while a file read is in flight. The commit supplies its text and the patch digests identify its gaps.
935
1059
  const expansionSource = useMemo(() => data?.kind === 'change'
936
- ? JSON.stringify([data.url, data.headSha, data.commits?.from, data.commits?.to, data.files.map(file => file.digest)])
1060
+ ? JSON.stringify([data.url, data.headSha, data.commits, data.files.map(file => file.digest)])
937
1061
  : data, [data])
938
1062
  const [expansion, setExpansion] = useState<Expansion>({ source: null, texts: {}, open: {} })
939
1063
  const current = expansion.source === expansionSource ? expansion : { source: expansionSource, texts: {}, open: {} }
@@ -974,12 +1098,18 @@ export function ChangesView({
974
1098
  if (kept !== null && !Object.hasOwn(kept, hidden.path)) actions.filtered(tab.id, null)
975
1099
  return
976
1100
  }
1101
+ const { center } = wanted
1102
+ // A thread opened before these changes were read has no card in them when they lack its file, so it opens on the host.
1103
+ if (center !== null && !allFiles.some(file => file.path === wanted.path)) {
1104
+ if (center.url !== null) openLink(center.url)
1105
+ setWanted(null)
1106
+ return
1107
+ }
977
1108
  // The browser's scroll anchoring keeps the section in place while the sections above it draw their lines.
978
1109
  const section = sections.current.get(wanted.path)
979
1110
  section?.scrollIntoView({ block: 'start' })
980
1111
  // A thread the reader opened from the thread list or a file's unresolved count centers inside its file, which the jump
981
1112
  // expanded and revealed; the jump ends here, so a later jump to the file stops at its header.
982
- const { center } = wanted
983
1113
  if (center !== null) {
984
1114
  /* v8 ignore next 4 -- a centered thread's file is drawn and its card unfolded, so both are found. */
985
1115
  const card = [...section?.querySelectorAll<HTMLElement>('[data-forge-thread]') ?? []]
@@ -989,8 +1119,8 @@ export function ChangesView({
989
1119
  }
990
1120
  if (scrollport.current !== null) jumpPosition.current = { data, top: scrollport.current.scrollTop }
991
1121
  setWanted(null)
992
- }, [tab.visible, wanted, data, allFiles, lens, hideTests, kept, actions, tab.id])
993
- const refresh = (): void => { setAttempt(value => value + 1) }
1122
+ }, [tab.visible, wanted, data, allFiles, lens, hideTests, kept, actions, tab.id, openLink])
1123
+ const refresh = useCallback((): void => { setAttempt(value => value + 1) }, [])
994
1124
  const writes = useLocalWrites({ localWrite, report, reread: refresh, rereading })
995
1125
  // Staging and restoring act on the `unstaged` scope and unstaging on `staged`; in the other scopes a write could leave
996
1126
  // the shown diff unchanged. Writes reach the Session's own checkout only, so another head offers none.
@@ -1002,17 +1132,31 @@ export function ChangesView({
1002
1132
  // Configuration reads may recover after the user fixes Git settings or raises the output limit.
1003
1133
  const message = failed === null ? undefined : FAILURE[failed]
1004
1134
  const changeUrl = source.kind === 'change' ? entry?.snapshot?.url ?? source.url : null
1135
+ // The change request's own page, which the recheck of an unknown review outcome opens rather than the snapshot's.
1136
+ const recheckUrl = source.kind === 'change' ? source.url : null
1005
1137
  // A head that is gone offers the Session's own checkout instead of a retry.
1006
1138
  const headMissing = failed === 'forgePanel/head-missing' && localHead !== null
1007
1139
  const failureText = baseFailure ?? (headMissing ? t('diff.headMissing', { head: localHead.name }) : t(message ?? 'diff.error'))
1008
1140
  const retry = baseFailure === undefined && !headMissing && (message === undefined || failed === 'forgePanel/filter-config-failed')
1009
- const automaticBase = baseFailure !== undefined ? (
1010
- <Button size="sm" variant="outline" onClick={() => { actions.based(tab.id, null) }}>{t('diff.useAutomaticBase')}</Button>
1011
- ) : headMissing ? (
1012
- <Button size="sm" variant="outline" data-forge-head-own="" onClick={() => { actions.headed(tab.id, null) }}>{t('diff.head.back')}</Button>
1013
- ) : (failed === 'forgePanel/commits-missing' || failed === 'forgePanel/commits-not-linear') && (
1014
- <Button size="sm" variant="outline" onClick={() => { actions.committed(tab.id, null) }}>{t('commits.showAll')}</Button>
1015
- )
1141
+ const chooseAutomaticBase = useCallback((): void => { actions.based(tab.id, null) }, [actions, tab.id])
1142
+ const backToOwnHead = useCallback((): void => { actions.headed(tab.id, null) }, [actions, tab.id])
1143
+ const showAllCommits = useCallback((): void => { actions.committed(tab.id, null) }, [actions, tab.id])
1144
+ const openChangeInBrowser = useCallback((): void => {
1145
+ /* v8 ignore next -- the control renders only once the change has a link */
1146
+ if (changeUrl !== null) openLink(changeUrl)
1147
+ }, [changeUrl, openLink])
1148
+ const recheckReview = useCallback((): void => {
1149
+ /* v8 ignore next -- the control renders only once a recheck link exists */
1150
+ if (recheckUrl !== null) openLink(recheckUrl)
1151
+ }, [openLink, recheckUrl])
1152
+ let automaticBase: ReactNode = false
1153
+ if (baseFailure !== undefined) {
1154
+ automaticBase = <Button size="sm" variant="outline" onClick={chooseAutomaticBase}>{t('diff.useAutomaticBase')}</Button>
1155
+ } else if (headMissing) {
1156
+ automaticBase = <Button size="sm" variant="outline" data-forge-head-own="" onClick={backToOwnHead}>{t('diff.head.back')}</Button>
1157
+ } else if (failed === 'forgePanel/commits-missing' || failed === 'forgePanel/commits-not-linear') {
1158
+ automaticBase = <Button size="sm" variant="outline" onClick={showAllCommits}>{t('commits.showAll')}</Button>
1159
+ }
1016
1160
 
1017
1161
  const update = (change: (value: Expansion) => Expansion): void => {
1018
1162
  setExpansion((previous) => {
@@ -1081,9 +1225,11 @@ export function ChangesView({
1081
1225
  return list
1082
1226
  }
1083
1227
 
1084
- // A review addresses the head commit, so it is submitted from the view of the whole change request. A pending review on
1085
- // the code host is submitted or discarded there; without one, the summary and any comment drafts kept in the browser
1086
- // are published as one review.
1228
+ // A review addresses the head commit whatever commits the view shows: the head the whole diff was read at, or the head
1229
+ // of the latest status beside chosen commits. A pending review on the code host is submitted or discarded there;
1230
+ // without one, the summary and any comment drafts kept in the browser are published as one review.
1231
+ let reviewHead: string | null = null
1232
+ if (data?.kind === 'change') reviewHead = data.commits === null ? data.headSha : prHead
1087
1233
  const pendingReview = review?.pendingReview ?? null
1088
1234
  const finishWrite = async (send: () => Promise<string | undefined>, done: ForgePanelKey): Promise<void> => {
1089
1235
  if (reviewRunning.current) return
@@ -1103,37 +1249,54 @@ export function ChangesView({
1103
1249
  setReviewBusy(false)
1104
1250
  }
1105
1251
  }
1106
- const reviewForm = tab.visible && data !== null && reviewOpen && data.kind === 'change' && data.commits === null && <SubmitReview queue={queue}
1107
- url={data.url} headSha={data.headSha} pending={pendingReview} events={review?.reviewEvents ?? null} busy={reviewBusy}
1108
- error={reviewError}
1109
- close={() => { setReviewOpen(false) }}
1110
- check={() => { openLink(data.url) }} reconcile={() => { queue.finish(false); setReviewError(null) }}
1111
- submit={() => {
1112
- const latest = queue.getSnapshot()
1113
- if (pendingReview === null) {
1114
- void publishReview(data.url, { kind: 'review', headSha: data.headSha, event: latest.event,
1115
- body: latest.body, comments: latest.comments.map(item => item.comment) }, url => queue.finish(true, url))
1116
- return
1252
+ // The change request a review addresses, at `reviewHead`; local changes offer no review form.
1253
+ const reviewData = data !== null && data.kind === 'change' ? data : null
1254
+ const closeReview = useCallback((): void => { setReviewOpen(false) }, [])
1255
+ const checkReview = useCallback((): void => {
1256
+ /* v8 ignore next -- the check control renders only with a change request */
1257
+ if (reviewData !== null) openLink(reviewData.url)
1258
+ }, [openLink, reviewData])
1259
+ const reconcileReview = useCallback((): void => {
1260
+ queue.finish(false)
1261
+ setReviewError(null)
1262
+ }, [queue])
1263
+ const discardReview = useCallback((): void => {
1264
+ /* v8 ignore next -- the discard control renders only with a change request, the head a review addresses, and a pending review */
1265
+ if (reviewData === null || reviewHead === null || pendingReview === null) return
1266
+ void finishWrite(() => writeReview(reviewData.url, { kind: 'discard-pending', headSha: reviewHead, review: pendingReview.id }), 'review.discarded')
1267
+ }, [finishWrite, pendingReview, reviewData, reviewHead, writeReview])
1268
+ const submitReviewForm = useCallback((): void => {
1269
+ /* v8 ignore next -- the review form renders only with a change request and the head a review addresses */
1270
+ if (reviewData === null || reviewHead === null) return
1271
+ const latest = queue.getSnapshot()
1272
+ if (pendingReview === null) {
1273
+ void publishReview(reviewData.url, { kind: 'review', headSha: reviewHead, event: latest.event,
1274
+ body: latest.body, comments: latest.comments.map(item => item.comment) }, url => queue.finish(true, url))
1275
+ return
1276
+ }
1277
+ // The submission is kept as the write to reconcile until the host answers, so an unknown outcome blocks another
1278
+ // submission, which would otherwise publish a second review once the pending review no longer reads.
1279
+ void finishWrite(async () => {
1280
+ if (!queue.begin({ kind: 'review', headSha: reviewHead, event: latest.event, body: latest.body, comments: [] })) {
1281
+ return t('review.saveFailed')
1117
1282
  }
1118
- // The submission is kept as the write to reconcile until the host answers, so an unknown outcome blocks another
1119
- // submission, which would otherwise publish a second review once the pending review no longer reads.
1120
- void finishWrite(async () => {
1121
- if (!queue.begin({ kind: 'review', headSha: data.headSha, event: latest.event, body: latest.body, comments: [] })) {
1122
- return t('review.saveFailed')
1123
- }
1124
- const refusal = await sendWrite(data.url, { kind: 'submit-pending', headSha: data.headSha, review: pendingReview.id,
1125
- event: latest.event, body: latest.body })
1126
- if (refusal === undefined) {
1127
- if (!queue.finish(true)) report('review.saveFailed')
1128
- return undefined
1129
- }
1130
- if (!refusal.unknown) queue.finish(false)
1131
- return refusal.message
1132
- }, 'review.submitted')
1133
- }}
1134
- discard={pendingReview === null ? undefined : () => {
1135
- void finishWrite(() => writeReview(data.url, { kind: 'discard-pending', headSha: data.headSha, review: pendingReview.id }), 'review.discarded')
1136
- }} t={t} />
1283
+ const refusal = await sendWrite(reviewData.url, { kind: 'submit-pending', headSha: reviewHead, review: pendingReview.id,
1284
+ event: latest.event, body: latest.body })
1285
+ if (refusal === undefined) {
1286
+ if (!queue.finish(true)) report('review.saveFailed')
1287
+ return undefined
1288
+ }
1289
+ if (!refusal.unknown) queue.finish(false)
1290
+ return refusal.message
1291
+ }, 'review.submitted')
1292
+ }, [finishWrite, pendingReview, publishReview, queue, report, reviewData, reviewHead, sendWrite, t])
1293
+ const reviewForm = tab.visible && reviewData !== null && reviewOpen && reviewHead !== null && <SubmitReview queue={queue}
1294
+ url={reviewData.url} headSha={reviewHead} pending={pendingReview} events={review?.reviewEvents ?? null} busy={reviewBusy}
1295
+ error={reviewError}
1296
+ close={closeReview}
1297
+ check={checkReview} reconcile={reconcileReview}
1298
+ submit={submitReviewForm}
1299
+ discard={pendingReview === null ? undefined : discardReview} t={t} />
1137
1300
 
1138
1301
  /** Add a comment to the pending review on the code host at the head the comment was selected on. */
1139
1302
  const addPending = (selection: ReviewSelection): Promise<string | undefined> => {
@@ -1149,7 +1312,7 @@ export function ChangesView({
1149
1312
  const recordActions: ReviewActions = {
1150
1313
  source: shownSource ?? (source.kind === 'local'
1151
1314
  ? reviewSourceOf({ kind: 'local', files: [], scope: localScope, head: localHead, worktree: localHead?.worktree ?? null, base: null, omitted: 0 })
1152
- : { kind: 'change', url: source.url, headSha: '', commits: changeCommits }),
1315
+ : { kind: 'change', url: source.url, headSha: '', commits: rangeOf(changeCommits) }),
1153
1316
  records: queue, addToInput: addReviewToInput, openLink, quoteCopy, onRemoved: reportRemoved,
1154
1317
  }
1155
1318
  const absentPaths = [...new Set([...reviewState.comments, ...reviewState.records.map(item => item.selection)]
@@ -1187,25 +1350,33 @@ export function ChangesView({
1187
1350
  if (next !== undefined) openThread(next, false)
1188
1351
  }
1189
1352
  /** Close the thread list at the reader's request and return the focus to its toggle. */
1190
- const closeThreadList = (): void => {
1353
+ const closeThreadList = useCallback((): void => {
1191
1354
  setThreadList(value => ({ ...value, open: false }))
1192
1355
  threadsToggle.current?.focus()
1193
- }
1356
+ }, [])
1194
1357
  /**
1195
- * Show a thread: all commits for a thread the chosen ones do not hold, whose diff holds the file of every thread with a
1196
- * position at the head, then its file, with the thread unfolded and centered; `focusCard` moves the focus to it. A
1197
- * thread on a file the shown changes lack opens on the host.
1358
+ * Show a thread in its file, unfolded and centered; `focusCard` moves the focus to it. With `written`, an outdated
1359
+ * thread shows in the changes up to the commit it was written on, where its lines still are, while the status names
1360
+ * the base commit those changes start from; without that commit, and when it is lost, it stays in its file's outdated
1361
+ * section. Chosen commits that do not show the thread give way to all commits, whose diff holds the file of every
1362
+ * thread with a position at the head: commits that do not hold its lines, and commits whose changes lack its file or
1363
+ * are still being read, when the thread list shows the places of the changes read before. A thread on a file that
1364
+ * all commits lack opens on the host, at once when they are loaded and else once they are.
1198
1365
  */
1199
- const openThread = ({ thread, place }: PlacedThread, focusCard: boolean): void => {
1200
- if (place.kind === 'elsewhere') actions.committed(tab.id, null)
1201
- else if (!allFiles.some(file => file.path === thread.path)) {
1202
- const url = thread.comments[0]?.url ?? null
1366
+ const openThread = ({ thread, place }: PlacedThread, focusCard: boolean, written = false): void => {
1367
+ const original = written && place.kind === 'outdated' && !place.lost && entry?.snapshot?.baseSha !== undefined ? thread.original : null
1368
+ // No file is held while other changes are read.
1369
+ const held = allFiles.some(file => file.path === thread.path)
1370
+ const url = thread.comments[0]?.url ?? null
1371
+ if (original !== null) actions.committed(tab.id, { upTo: original.commit })
1372
+ else if (place.kind === 'elsewhere' || (!held && changeCommits !== null)) actions.committed(tab.id, null)
1373
+ else if (!held && data !== null) {
1203
1374
  if (url !== null) openLink(url)
1204
1375
  return
1205
1376
  }
1206
1377
  setFocus(value => ({ id: thread.id, revision: (value?.revision ?? 0) + 1 }))
1207
1378
  setRevealed(value => new Set([...value, thread.path]))
1208
- jump(thread.path, { id: thread.id, focus: focusCard })
1379
+ jump(thread.path, { id: thread.id, focus: focusCard, url })
1209
1380
  }
1210
1381
  const jump = (path: string, center: Wanted['center'] = null): void => {
1211
1382
  setTreeState(value => ({ ...value, selected: path }))
@@ -1384,7 +1555,7 @@ export function ChangesView({
1384
1555
  {retry && <Button size="sm" variant="outline" onClick={refresh}>{t('retry')}</Button>}
1385
1556
  {automaticBase}
1386
1557
  {changeUrl !== null && (
1387
- <Button size="sm" variant="outline" onClick={() => { openLink(changeUrl) }}>{t('diff.viewInBrowser')}</Button>
1558
+ <Button size="sm" variant="outline" onClick={openChangeInBrowser}>{t('diff.viewInBrowser')}</Button>
1388
1559
  )}
1389
1560
  </div>
1390
1561
  )}
@@ -1397,13 +1568,14 @@ export function ChangesView({
1397
1568
  body = <div className={css.files}>{orphanRecords}<div className={css.centered}>{t('lens.empty')}</div></div>
1398
1569
  } else {
1399
1570
  body = (
1400
- <div ref={attachScrollport} className={css.files} data-forge-changes-scroll="" role="region"
1571
+ <div ref={attachScrollport} className={css.files} style={countColumn} data-forge-changes-scroll="" role="region"
1401
1572
  aria-label={t('diff.allFiles', { count: files.length })} aria-keyshortcuts="ArrowLeft ArrowRight V" tabIndex={0}
1402
1573
  onKeyDown={navigateFiles} onScroll={(event) => {
1403
1574
  if (jumpPosition.current?.top !== event.currentTarget.scrollTop) jumpPosition.current = null
1404
1575
  }}>
1405
1576
  {files.map((file) => {
1406
1577
  const path = file.path
1578
+ const badge = badgeOf(file, data, t)
1407
1579
  return (
1408
1580
  <DiffFile
1409
1581
  key={path}
@@ -1417,7 +1589,8 @@ export function ChangesView({
1417
1589
  open={current.open[path] ?? NO_GAPS}
1418
1590
  split={split}
1419
1591
  wrap={wrap}
1420
- badge={badgeOf(file, data, t)}
1592
+ badge={badge.text}
1593
+ badgeLetter={badge.letter}
1421
1594
  tooltip={pathTooltipOf(file, t)}
1422
1595
  threads={fileThreads.get(path)}
1423
1596
  annotations={annotations.get(path)}
@@ -1452,7 +1625,27 @@ export function ChangesView({
1452
1625
  const toggleExpansion = (): void => { setChosen(Object.fromEntries(files.map(file => [file.path, !anyExpanded]))) }
1453
1626
  const toggleSplit = (): void => { actions.toggledSplit(tab.id) }
1454
1627
  const toggleWrap = (): void => { actions.toggledWrap(tab.id) }
1455
- const toggleTests = (): void => { actions.toggledTests(tab.id) }
1628
+ const toggleTests = useCallback((): void => { actions.toggledTests(tab.id) }, [actions, tab.id])
1629
+ const chooseScope = useCallback((next: ForgeLocalScope['kind']): void => { actions.scoped(tab.id, next) }, [actions, tab.id])
1630
+ const dropUncertainReview = useCallback((): void => {
1631
+ queue.finish(false)
1632
+ setReviewError(null)
1633
+ }, [queue])
1634
+ const retryLens = useCallback((): void => { setLensAttempt(value => value + 1) }, [])
1635
+ const clearLens = useCallback((): void => { chooseLens(null) }, [chooseLens])
1636
+ const chooseThreadFilter = useCallback((filter: ThreadFilter): void => {
1637
+ setThreadList(value => ({ ...value, filter }))
1638
+ }, [])
1639
+ const claimThreadList = useCallback((): void => { setThreadList(value => ({ ...value, claim: false })) }, [])
1640
+ const openListedThread = useCallback((entry: PlacedThread, covering: boolean): void => {
1641
+ // A list that covers the files closes and hands the focus to the thread it opens, which it would cover.
1642
+ if (covering) setThreadList(value => ({ ...value, open: false }))
1643
+ openThread(entry, covering, true)
1644
+ }, [openThread])
1645
+ const chooseCommit = useCallback((next: ForgeCommitRange | null): void => { actions.committed(tab.id, next) }, [actions, tab.id])
1646
+ const chooseLocalHead = useCallback((next: ChangesHead | null): void => { actions.headed(tab.id, next) }, [actions, tab.id])
1647
+ const chooseBase = useCallback((next: ForgeBaseBranch | null): void => { actions.based(tab.id, next) }, [actions, tab.id])
1648
+ const openReview = useCallback((): void => { setReviewOpen(true) }, [])
1456
1649
  const treeAction = t(treePosition === 'left' ? 'diff.moveFileTreeRight' : treePosition === 'right' ? 'diff.hideFileTree' : 'diff.showFileTreeLeft')
1457
1650
  let additions = 0
1458
1651
  let deletions = 0
@@ -1463,33 +1656,42 @@ export function ChangesView({
1463
1656
  const viewedCount = files.filter(file => viewedStateOf(marks, file.path, file.digest) === 'viewed').length
1464
1657
  const treeShown = allFiles.length > 0 && treePosition !== 'hidden'
1465
1658
  const lensProps = { lens, counts: lensCounts, hideTests, choose: (next: ChangesLens) => { actions.lensed(tab.id, next) }, t }
1466
- const commitMenu = source.kind === 'local' && scope !== 'branch' ? null : <CommitMenu chosen={chosenCommits} visible={tab.visible}
1467
- list={source.kind === 'local' ? listLocalCommits : listChangeCommits} kept={source.kind === 'local' ? 'newest' : 'oldest'}
1468
- version={commitsVersion}
1469
- choose={(next) => { actions.committed(tab.id, next) }} t={t} />
1659
+ const localSource = source.kind === 'local'
1660
+ const commitList = localSource ? listLocalCommits : listChangeCommits
1661
+ const commitKept = localSource ? 'newest' : 'oldest'
1662
+ const commitMenu = localSource && scope !== 'branch' ? null : (
1663
+ // The narrowest header leaves out a picker that shows every commit; chosen commits stay, to say what the files are of.
1664
+ <span className={clsx(css.commitSlot, chosenCommits === null && css.foldCommits)}>
1665
+ <CommitMenu chosen={chosenCommits} visible={tab.visible}
1666
+ list={commitList} kept={commitKept} version={commitsVersion}
1667
+ choose={chooseCommit} t={t} />
1668
+ </span>
1669
+ )
1670
+ const baseLabel = data?.kind === 'local' ? data.base : null
1671
+ const bulk = writeSide === undefined ? null : {
1672
+ label: t(writeSide === 'unstaged' ? 'diff.stageAll' : 'diff.unstageAll'),
1673
+ disabled: writes.writing || files.length === 0,
1674
+ run: () => { writes.write(writeSide === 'unstaged' ? 'stage' : 'unstage', files) },
1675
+ }
1470
1676
  const toolbarStyle: CSSProperties & { '--forge-tree-width': string } = { '--forge-tree-width': `${treeWidth}px` }
1471
1677
  return (
1472
1678
  <div className={css.root} data-forge-changes={source.kind} onKeyDown={toggleViewed}>
1473
1679
  {source.kind === 'local'
1474
1680
  ? <LocalHeader state={state} scope={scope} head={localHead} headMissing={headMissing} base={base}
1475
- baseLabel={data?.kind === 'local' ? data.base : null} missing={failed === 'forgePanel/base-missing'} visible={tab.visible}
1476
- diffBases={diffBases} chooseHead={(next) => { actions.headed(tab.id, next) }}
1477
- choose={(next) => { actions.based(tab.id, next) }} commitMenu={commitMenu}
1478
- bulk={writeSide === undefined ? null : {
1479
- label: t(writeSide === 'unstaged' ? 'diff.stageAll' : 'diff.unstageAll'),
1480
- disabled: writes.writing || files.length === 0,
1481
- run: () => { writes.write(writeSide === 'unstaged' ? 'stage' : 'unstage', files) },
1482
- }}
1681
+ baseLabel={baseLabel} missing={failed === 'forgePanel/base-missing'} visible={tab.visible}
1682
+ diffBases={diffBases} chooseHead={chooseLocalHead}
1683
+ choose={chooseBase} commitMenu={commitMenu}
1684
+ bulk={bulk}
1483
1685
  createChangeRequest={createChangeRequest} t={t} />
1484
- : <ChangeHeader url={source.url} entry={entry} openLink={openLink} commitMenu={commitMenu}
1686
+ : <ChangeHeader url={source.url} entry={entry} status={status} openLink={openLink} commitMenu={commitMenu}
1485
1687
  reviewCount={(pendingReview?.comments ?? 0) + reviewState.comments.length}
1486
- reviewDisabled={data === null || changeCommits !== null} onReview={() => { setReviewOpen(true) }} t={t} />}
1688
+ reviewDisabled={reviewHead === null} onReview={openReview} t={t} />}
1487
1689
  {!reviewOpen && reviewState.error !== null && <Notice>{t(reviewState.error === 'load' ? 'review.loadFailed' : 'review.saveFailed')}</Notice>}
1488
1690
  {!reviewOpen && reviewState.uncertain !== null && !reviewBusy && source.kind === 'change' && <div className={css.reviewNotice} role="alert">
1489
1691
  <span>{t('review.unknown')}</span>
1490
1692
  {reviewState.uncertain.kind === 'comment' && <blockquote>{reviewState.uncertain.comment.body}</blockquote>}
1491
- <Button size="sm" variant="outline" onClick={() => { openLink(source.url) }}>{t('review.recheck')}</Button>
1492
- <Button size="sm" variant="outline" onClick={() => { queue.finish(false); setReviewError(null) }}>{t('review.confirmRetry')}</Button>
1693
+ <Button size="sm" variant="outline" onClick={recheckReview}>{t('review.recheck')}</Button>
1694
+ <Button size="sm" variant="outline" onClick={dropUncertainReview}>{t('review.confirmRetry')}</Button>
1493
1695
  </div>}
1494
1696
  {!reviewOpen && reviewError !== null && reviewState.uncertain === null && <Notice>{reviewError}</Notice>}
1495
1697
  <div className={css.toolbar} data-tree={treeShown ? treePosition : 'hidden'} style={toolbarStyle}>
@@ -1498,7 +1700,7 @@ export function ChangesView({
1498
1700
  <div ref={toolbarRow} className={css.toolbarMain}>
1499
1701
  {/* A branch that no worktree has checked out has neither a working tree nor an index, so it has the `branch` scope alone. */}
1500
1702
  {tab.visible && source.kind === 'local' && (localHead === null || localHead.worktree !== null)
1501
- && <ScopeMenu scope={scope} choose={(next) => { actions.scoped(tab.id, next) }} t={t} />}
1703
+ && <ScopeMenu scope={scope} choose={chooseScope} t={t} />}
1502
1704
  {tab.visible && (
1503
1705
  <span className={css.filesSlot}><ChangedFilesMenu {...navigator} loading={data === null && failed === null} visible /></span>
1504
1706
  )}
@@ -1585,8 +1787,8 @@ export function ChangesView({
1585
1787
  <Notice action={<span className={css.noticeAction}>
1586
1788
  {lensRun.run.code === 'forgePanel/lens-stale'
1587
1789
  ? <Button size="sm" variant="outline" onClick={refresh}>{t('diff.refresh')}</Button>
1588
- : <Button size="sm" variant="outline" onClick={() => { setLensAttempt(value => value + 1) }}>{t('retry')}</Button>}
1589
- <Button size="sm" variant="outline" onClick={() => { chooseLens(null) }}>{t('filterLens.clear')}</Button>
1790
+ : <Button size="sm" variant="outline" onClick={retryLens}>{t('retry')}</Button>}
1791
+ <Button size="sm" variant="outline" onClick={clearLens}>{t('filterLens.clear')}</Button>
1590
1792
  </span>}>
1591
1793
  {lensRun.run.code === 'forgePanel/lens-stale' ? t('filterLens.stale', { lens: chosenChoice.title })
1592
1794
  : lensRun.run.code === 'forgePanel/lens-interrupted' ? t('filterLens.interrupted', { lens: chosenChoice.title })
@@ -1609,15 +1811,11 @@ export function ChangesView({
1609
1811
  {allFiles.length > 0 && (
1610
1812
  <FileTreePane {...navigator} id={treeId} position={treePosition} least={lensWidth} onWidth={setTreeWidth} />
1611
1813
  )}
1612
- {review !== null && data?.kind === 'change' && threadList.open && (
1613
- <ThreadList entries={placed.entries} files={allFiles} truncated={review.truncated} url={data.url}
1614
- filter={threadList.filter} choose={(filter) => { setThreadList(value => ({ ...value, filter })) }}
1615
- claim={threadList.claim} claimed={() => { setThreadList(value => ({ ...value, claim: false })) }}
1616
- open={(entry, covering) => {
1617
- // A list that covers the files closes and hands the focus to the thread it opens, which it would cover.
1618
- if (covering) setThreadList(value => ({ ...value, open: false }))
1619
- openThread(entry, covering)
1620
- }}
1814
+ {review !== null && threadsOn?.kind === 'change' && threadList.open && (
1815
+ <ThreadList entries={placed.entries} files={threadFiles} truncated={review.truncated} url={threadsOn.url}
1816
+ filter={threadList.filter} choose={chooseThreadFilter}
1817
+ claim={threadList.claim} claimed={claimThreadList}
1818
+ open={openListedThread}
1621
1819
  openLink={openLink} forge={family} close={closeThreadList} t={t} />
1622
1820
  )}
1623
1821
  </div>