@cerbur/clutch-dsh-worktree 0.1.17 → 0.1.19

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 (288) hide show
  1. package/README.md +207 -42
  2. package/README.zh.md +174 -38
  3. package/assets/screenshots/screenshots-agent-steer.jpg +0 -0
  4. package/assets/screenshots/screenshots-baseline-sync.png +0 -0
  5. package/lib/client/WorktreeSurface.d.ts.map +1 -1
  6. package/lib/client/WorktreeSurface.js +55 -12
  7. package/lib/client/WorktreeSurface.js.map +1 -1
  8. package/lib/client/branch/GitBranchSelector.d.ts +23 -0
  9. package/lib/client/branch/GitBranchSelector.d.ts.map +1 -0
  10. package/lib/client/branch/GitBranchSelector.js +142 -0
  11. package/lib/client/branch/GitBranchSelector.js.map +1 -0
  12. package/lib/client/context/worktree-context-store.d.ts +3 -1
  13. package/lib/client/context/worktree-context-store.d.ts.map +1 -1
  14. package/lib/client/context/worktree-context-store.js +4 -2
  15. package/lib/client/context/worktree-context-store.js.map +1 -1
  16. package/lib/client/context/worktree-context.d.ts +3 -2
  17. package/lib/client/context/worktree-context.d.ts.map +1 -1
  18. package/lib/client/context/worktree-context.js +5 -3
  19. package/lib/client/context/worktree-context.js.map +1 -1
  20. package/lib/client/dashboard/WorktreeDashboard.d.ts +11 -3
  21. package/lib/client/dashboard/WorktreeDashboard.d.ts.map +1 -1
  22. package/lib/client/dashboard/WorktreeDashboard.js +181 -75
  23. package/lib/client/dashboard/WorktreeDashboard.js.map +1 -1
  24. package/lib/client/dashboard/dashboard-selection.d.ts +8 -3
  25. package/lib/client/dashboard/dashboard-selection.d.ts.map +1 -1
  26. package/lib/client/dashboard/dashboard-selection.js +29 -4
  27. package/lib/client/dashboard/dashboard-selection.js.map +1 -1
  28. package/lib/client/dashboard/git/GitChangedFiles.d.ts +2 -1
  29. package/lib/client/dashboard/git/GitChangedFiles.d.ts.map +1 -1
  30. package/lib/client/dashboard/git/GitChangedFiles.js +8 -6
  31. package/lib/client/dashboard/git/GitChangedFiles.js.map +1 -1
  32. package/lib/client/dashboard/git/GitCommitList.d.ts +6 -1
  33. package/lib/client/dashboard/git/GitCommitList.d.ts.map +1 -1
  34. package/lib/client/dashboard/git/GitCommitList.js +34 -29
  35. package/lib/client/dashboard/git/GitCommitList.js.map +1 -1
  36. package/lib/client/dashboard/git/GitCommitStats.d.ts +8 -0
  37. package/lib/client/dashboard/git/GitCommitStats.d.ts.map +1 -0
  38. package/lib/client/dashboard/git/GitCommitStats.js +7 -0
  39. package/lib/client/dashboard/git/GitCommitStats.js.map +1 -0
  40. package/lib/client/dashboard/git/WorktreeGitOverview.d.ts.map +1 -1
  41. package/lib/client/dashboard/git/WorktreeGitOverview.js +2 -1
  42. package/lib/client/dashboard/git/WorktreeGitOverview.js.map +1 -1
  43. package/lib/client/dashboard/git/WorktreeGitPanel.d.ts +1 -1
  44. package/lib/client/dashboard/git/WorktreeGitPanel.d.ts.map +1 -1
  45. package/lib/client/dashboard/git/WorktreeGitPanel.js +28 -9
  46. package/lib/client/dashboard/git/WorktreeGitPanel.js.map +1 -1
  47. package/lib/client/dashboard/git/file-address.d.ts +5 -2
  48. package/lib/client/dashboard/git/file-address.d.ts.map +1 -1
  49. package/lib/client/dashboard/git/file-address.js +50 -7
  50. package/lib/client/dashboard/git/file-address.js.map +1 -1
  51. package/lib/client/dashboard/git/git-facts.js +1 -1
  52. package/lib/client/dashboard/git/git-facts.js.map +1 -1
  53. package/lib/client/dashboard/git/useWorktreeGitState.d.ts +7 -2
  54. package/lib/client/dashboard/git/useWorktreeGitState.d.ts.map +1 -1
  55. package/lib/client/dashboard/git/useWorktreeGitState.js +84 -21
  56. package/lib/client/dashboard/git/useWorktreeGitState.js.map +1 -1
  57. package/lib/client/dsh-icons.d.ts +2 -0
  58. package/lib/client/dsh-icons.d.ts.map +1 -1
  59. package/lib/client/dsh-icons.js +2 -0
  60. package/lib/client/dsh-icons.js.map +1 -1
  61. package/lib/client/dsh-slot-contract.d.ts +8 -1
  62. package/lib/client/dsh-slot-contract.d.ts.map +1 -1
  63. package/lib/client/entry.d.ts.map +1 -1
  64. package/lib/client/entry.js +22 -4
  65. package/lib/client/entry.js.map +1 -1
  66. package/lib/client/locales.d.ts +86 -2
  67. package/lib/client/locales.d.ts.map +1 -1
  68. package/lib/client/locales.js +100 -16
  69. package/lib/client/locales.js.map +1 -1
  70. package/lib/client/permission/worktree-permission.d.ts.map +1 -1
  71. package/lib/client/permission/worktree-permission.js +14 -6
  72. package/lib/client/permission/worktree-permission.js.map +1 -1
  73. package/lib/client/select/SearchableSingleSelect.d.ts +44 -0
  74. package/lib/client/select/SearchableSingleSelect.d.ts.map +1 -0
  75. package/lib/client/select/SearchableSingleSelect.js +180 -0
  76. package/lib/client/select/SearchableSingleSelect.js.map +1 -0
  77. package/lib/client/select/WorktreeSelector.d.ts +14 -0
  78. package/lib/client/select/WorktreeSelector.d.ts.map +1 -0
  79. package/lib/client/select/WorktreeSelector.js +11 -0
  80. package/lib/client/select/WorktreeSelector.js.map +1 -0
  81. package/lib/client/settings/diagnostics.d.ts +4 -0
  82. package/lib/client/settings/diagnostics.d.ts.map +1 -1
  83. package/lib/client/settings/diagnostics.js +12 -0
  84. package/lib/client/settings/diagnostics.js.map +1 -1
  85. package/lib/client/steer/SteerDock.d.ts +8 -0
  86. package/lib/client/steer/SteerDock.d.ts.map +1 -0
  87. package/lib/client/steer/SteerDock.js +12 -0
  88. package/lib/client/steer/SteerDock.js.map +1 -0
  89. package/lib/client/steer/steer-activity.d.ts +18 -0
  90. package/lib/client/steer/steer-activity.d.ts.map +1 -0
  91. package/lib/client/steer/steer-activity.js +37 -0
  92. package/lib/client/steer/steer-activity.js.map +1 -0
  93. package/lib/client/steer/steer-state.d.ts +24 -0
  94. package/lib/client/steer/steer-state.d.ts.map +1 -0
  95. package/lib/client/steer/steer-state.js +102 -0
  96. package/lib/client/steer/steer-state.js.map +1 -0
  97. package/lib/client/surface/actions/useLifecycleActions.js +1 -1
  98. package/lib/client/surface/actions/useLifecycleActions.js.map +1 -1
  99. package/lib/client/surface/actions/useWorktreeRegistration.d.ts +1 -1
  100. package/lib/client/surface/actions/useWorktreeRegistration.d.ts.map +1 -1
  101. package/lib/client/surface/actions/useWorktreeRegistration.js +32 -11
  102. package/lib/client/surface/actions/useWorktreeRegistration.js.map +1 -1
  103. package/lib/client/surface/components/RegistrationDialog.d.ts +3 -3
  104. package/lib/client/surface/components/RegistrationDialog.d.ts.map +1 -1
  105. package/lib/client/surface/components/RegistrationDialog.js +70 -5
  106. package/lib/client/surface/components/RegistrationDialog.js.map +1 -1
  107. package/lib/client/surface/components/WorkspaceTree.d.ts.map +1 -1
  108. package/lib/client/surface/components/WorkspaceTree.js +11 -8
  109. package/lib/client/surface/components/WorkspaceTree.js.map +1 -1
  110. package/lib/client/surface/components/dialogs.d.ts +1 -1
  111. package/lib/client/surface/components/dialogs.d.ts.map +1 -1
  112. package/lib/client/surface/components/dialogs.js +24 -15
  113. package/lib/client/surface/components/dialogs.js.map +1 -1
  114. package/lib/client/surface/state/useRegistrationState.d.ts +6 -1
  115. package/lib/client/surface/state/useRegistrationState.d.ts.map +1 -1
  116. package/lib/client/surface/state/useRegistrationState.js +7 -0
  117. package/lib/client/surface/state/useRegistrationState.js.map +1 -1
  118. package/lib/client/surface/state/useSurfaceRefresh.d.ts.map +1 -1
  119. package/lib/client/surface/state/useSurfaceRefresh.js +6 -3
  120. package/lib/client/surface/state/useSurfaceRefresh.js.map +1 -1
  121. package/lib/client/surface/types.d.ts +10 -2
  122. package/lib/client/surface/types.d.ts.map +1 -1
  123. package/lib/client/view/worktree-error-copy.d.ts.map +1 -1
  124. package/lib/client/view/worktree-error-copy.js +4 -0
  125. package/lib/client/view/worktree-error-copy.js.map +1 -1
  126. package/lib/client/view/worktree-view-read.d.ts +7 -2
  127. package/lib/client/view/worktree-view-read.d.ts.map +1 -1
  128. package/lib/client/view/worktree-view-read.js +57 -18
  129. package/lib/client/view/worktree-view-read.js.map +1 -1
  130. package/lib/client/worktree-connection.d.ts +4 -0
  131. package/lib/client/worktree-connection.d.ts.map +1 -1
  132. package/lib/client/worktree-connection.js +20 -1
  133. package/lib/client/worktree-connection.js.map +1 -1
  134. package/lib/client.js +2361 -834
  135. package/lib/client.js.map +1 -1
  136. package/lib/contract/baseline-sync.d.ts +27 -0
  137. package/lib/contract/baseline-sync.d.ts.map +1 -0
  138. package/lib/contract/baseline-sync.js +2 -0
  139. package/lib/contract/baseline-sync.js.map +1 -0
  140. package/lib/contract/index.contract.js +16 -0
  141. package/lib/contract/index.contract.js.map +1 -1
  142. package/lib/contract/index.d.ts +73 -12
  143. package/lib/contract/index.d.ts.map +1 -1
  144. package/lib/contract/index.js +4 -0
  145. package/lib/contract/index.js.map +1 -1
  146. package/lib/contract/worktree-permission.d.ts +2 -0
  147. package/lib/contract/worktree-permission.d.ts.map +1 -1
  148. package/lib/contract/worktree-permission.js +1 -1
  149. package/lib/contract/worktree-permission.js.map +1 -1
  150. package/lib/contract/worktree-tool-changes.d.ts +2 -0
  151. package/lib/contract/worktree-tool-changes.d.ts.map +1 -1
  152. package/lib/host/baseline-sync.d.ts +15 -0
  153. package/lib/host/baseline-sync.d.ts.map +1 -0
  154. package/lib/host/baseline-sync.js +93 -0
  155. package/lib/host/baseline-sync.js.map +1 -0
  156. package/lib/host/remote.d.ts +2 -1
  157. package/lib/host/remote.d.ts.map +1 -1
  158. package/lib/host/remote.js +8 -1
  159. package/lib/host/remote.js.map +1 -1
  160. package/lib/host/service.d.ts +18 -6
  161. package/lib/host/service.d.ts.map +1 -1
  162. package/lib/host/service.js +45 -2
  163. package/lib/host/service.js.map +1 -1
  164. package/lib/host/worktree-permission.d.ts +12 -0
  165. package/lib/host/worktree-permission.d.ts.map +1 -1
  166. package/lib/host/worktree-permission.js +87 -16
  167. package/lib/host/worktree-permission.js.map +1 -1
  168. package/lib/host/worktree-tool-changes.d.ts +1 -1
  169. package/lib/host/worktree-tool-changes.d.ts.map +1 -1
  170. package/lib/host/worktree-tool-changes.js +5 -2
  171. package/lib/host/worktree-tool-changes.js.map +1 -1
  172. package/lib/index.d.ts +1 -1
  173. package/lib/index.d.ts.map +1 -1
  174. package/lib/index.js.map +1 -1
  175. package/lib/manage/manager-git-history.d.ts +5 -7
  176. package/lib/manage/manager-git-history.d.ts.map +1 -1
  177. package/lib/manage/manager-git-history.js +158 -65
  178. package/lib/manage/manager-git-history.js.map +1 -1
  179. package/lib/manage/manager-git-paths.d.ts +7 -0
  180. package/lib/manage/manager-git-paths.d.ts.map +1 -0
  181. package/lib/manage/manager-git-paths.js +62 -0
  182. package/lib/manage/manager-git-paths.js.map +1 -0
  183. package/lib/manage/manager-worktrees.d.ts +9 -1
  184. package/lib/manage/manager-worktrees.d.ts.map +1 -1
  185. package/lib/manage/manager-worktrees.js +69 -14
  186. package/lib/manage/manager-worktrees.js.map +1 -1
  187. package/lib/manage/manager.d.ts +17 -5
  188. package/lib/manage/manager.d.ts.map +1 -1
  189. package/lib/manage/manager.js +81 -4
  190. package/lib/manage/manager.js.map +1 -1
  191. package/lib/manage/types.d.ts +5 -0
  192. package/lib/manage/types.d.ts.map +1 -1
  193. package/lib/provider/git/adapter.d.ts +13 -12
  194. package/lib/provider/git/adapter.d.ts.map +1 -1
  195. package/lib/provider/git/adapter.js +152 -29
  196. package/lib/provider/git/adapter.js.map +1 -1
  197. package/lib/provider/git/branch-name.d.ts +5 -0
  198. package/lib/provider/git/branch-name.d.ts.map +1 -0
  199. package/lib/provider/git/branch-name.js +16 -0
  200. package/lib/provider/git/branch-name.js.map +1 -0
  201. package/lib/provider/git/branches.d.ts +11 -0
  202. package/lib/provider/git/branches.d.ts.map +1 -0
  203. package/lib/provider/git/branches.js +37 -0
  204. package/lib/provider/git/branches.js.map +1 -0
  205. package/lib/provider/sidecar/repository.d.ts.map +1 -1
  206. package/lib/provider/sidecar/repository.js +2 -1
  207. package/lib/provider/sidecar/repository.js.map +1 -1
  208. package/lib/provider/sidecar/sidecar-schema.d.ts.map +1 -1
  209. package/lib/provider/sidecar/sidecar-schema.js +2 -0
  210. package/lib/provider/sidecar/sidecar-schema.js.map +1 -1
  211. package/lib/provider/transaction/operations/create.d.ts.map +1 -1
  212. package/lib/provider/transaction/operations/create.js +18 -6
  213. package/lib/provider/transaction/operations/create.js.map +1 -1
  214. package/lib/provider/transaction/recovery/failure-recovery.d.ts.map +1 -1
  215. package/lib/provider/transaction/recovery/failure-recovery.js +3 -2
  216. package/lib/provider/transaction/recovery/failure-recovery.js.map +1 -1
  217. package/lib/provider/transaction/recovery/recover.d.ts.map +1 -1
  218. package/lib/provider/transaction/recovery/recover.js +8 -5
  219. package/lib/provider/transaction/recovery/recover.js.map +1 -1
  220. package/lib/provider/transaction/support/journal.d.ts.map +1 -1
  221. package/lib/provider/transaction/support/journal.js +1 -0
  222. package/lib/provider/transaction/support/journal.js.map +1 -1
  223. package/lib/provider/types.d.ts +24 -4
  224. package/lib/provider/types.d.ts.map +1 -1
  225. package/lib/provider/types.js.map +1 -1
  226. package/lib/tool/agent-relay.d.ts +55 -0
  227. package/lib/tool/agent-relay.d.ts.map +1 -0
  228. package/lib/tool/agent-relay.js +159 -0
  229. package/lib/tool/agent-relay.js.map +1 -0
  230. package/lib/tool/delegation.d.ts +1 -0
  231. package/lib/tool/delegation.d.ts.map +1 -1
  232. package/lib/tool/delegation.js +32 -6
  233. package/lib/tool/delegation.js.map +1 -1
  234. package/lib/tool/dispatch-session.d.ts +18 -0
  235. package/lib/tool/dispatch-session.d.ts.map +1 -0
  236. package/lib/tool/dispatch-session.js +41 -0
  237. package/lib/tool/dispatch-session.js.map +1 -0
  238. package/lib/tool/errors.d.ts +6 -0
  239. package/lib/tool/errors.d.ts.map +1 -1
  240. package/lib/tool/errors.js +16 -2
  241. package/lib/tool/errors.js.map +1 -1
  242. package/lib/tool/guidance.d.ts +1 -0
  243. package/lib/tool/guidance.d.ts.map +1 -1
  244. package/lib/tool/guidance.js +2 -0
  245. package/lib/tool/guidance.js.map +1 -1
  246. package/lib/tool/index.d.ts.map +1 -1
  247. package/lib/tool/index.js +38 -4
  248. package/lib/tool/index.js.map +1 -1
  249. package/lib/tool/inputs.d.ts.map +1 -1
  250. package/lib/tool/inputs.js +6 -6
  251. package/lib/tool/inputs.js.map +1 -1
  252. package/lib/tool/list-models.js +2 -2
  253. package/lib/tool/list-models.js.map +1 -1
  254. package/lib/tool/list-sessions.js +2 -2
  255. package/lib/tool/list-sessions.js.map +1 -1
  256. package/lib/tool/list-worktrees.d.ts.map +1 -1
  257. package/lib/tool/list-worktrees.js +9 -2
  258. package/lib/tool/list-worktrees.js.map +1 -1
  259. package/lib/tool/native-session.d.ts +4 -0
  260. package/lib/tool/native-session.d.ts.map +1 -1
  261. package/lib/tool/native-session.js +17 -0
  262. package/lib/tool/native-session.js.map +1 -1
  263. package/lib/tool/new-worktree.js +4 -4
  264. package/lib/tool/new-worktree.js.map +1 -1
  265. package/lib/tool/report-result.d.ts.map +1 -1
  266. package/lib/tool/report-result.js +9 -7
  267. package/lib/tool/report-result.js.map +1 -1
  268. package/lib/tool/schema.d.ts +8 -0
  269. package/lib/tool/schema.d.ts.map +1 -1
  270. package/lib/tool/schema.js +31 -2
  271. package/lib/tool/schema.js.map +1 -1
  272. package/lib/tool/send-message.d.ts.map +1 -1
  273. package/lib/tool/send-message.js +8 -7
  274. package/lib/tool/send-message.js.map +1 -1
  275. package/lib/tool/span-worktree.d.ts.map +1 -1
  276. package/lib/tool/span-worktree.js +33 -59
  277. package/lib/tool/span-worktree.js.map +1 -1
  278. package/lib/tool/types.d.ts +2 -0
  279. package/lib/tool/types.d.ts.map +1 -1
  280. package/lib/tool/wire-schema.d.ts +4 -0
  281. package/lib/tool/wire-schema.d.ts.map +1 -0
  282. package/lib/tool/wire-schema.js +24 -0
  283. package/lib/tool/wire-schema.js.map +1 -0
  284. package/lib/typert.host.js +283 -52
  285. package/lib/typert.remote-client.d.ts +13 -5
  286. package/lib/typert.remote-client.d.ts.map +1 -1
  287. package/lib/typert.remote-client.js +283 -52
  288. package/package.json +7 -2
@@ -1,23 +1,51 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { NotificationToasts } from '../surface/components/NotificationToasts.js';
3
+ import { worktreeDiagnostics } from '../settings/diagnostics.js';
3
4
  import { toWorktreeViewError } from '../view/worktree-view.js';
4
5
  import { formatWorktreeViewError } from '../view/worktree-error-copy.js';
5
- import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
6
- import { Button, Input, Modal, StateDot, Tooltip, writeClipboard, } from '@deepseek-ai/dsh-client-ui-primitives';
7
- import { IconBranchOutline16, IconCheckOutline16, IconCopyOutline16, IconEditOutline16, IconPanelLeftOutline16, IconSearchOutline16, } from '../dsh-icons.js';
6
+ import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';
7
+ import { Button, Modal, StateDot, Tooltip, writeClipboard, } from '@deepseek-ai/dsh-client-ui-primitives';
8
+ import { IconBranchOutline16, IconChevronRightOutline14, IconCopyOutline16, IconEditOutline16, IconPanelLeftOutline16, } from '../dsh-icons.js';
8
9
  import { isBlankSession, relativeTime, sessionDisplayLabel } from '../session/session-view.js';
9
10
  import { currentSessionIdFromList } from '../session/session-selection.js';
10
11
  import { sessionStatusLabel, sessionTimeLabel } from '../session/session-labels.js';
11
12
  import { OpenInAppButton } from './OpenInAppButton.js';
12
13
  import { mountDashboardOverlay } from './dashboard-overlay.js';
13
- import { isMainWorktreeId } from './dashboard-selection.js';
14
+ import { isMainWorktreeId, selectDerivedWorktrees, selectBaseWorktree } from './dashboard-selection.js';
14
15
  import { selectWorktreeAcquisitionFacts } from './worktree-acquisition-facts.js';
15
16
  import styles from './dashboard.css';
16
17
  import { WorktreeInstructions } from './WorktreeInstructions.js';
17
18
  import { WorktreeGitPanel } from './git/WorktreeGitPanel.js';
18
19
  import { useWorktreeGitOverview, WorktreeGitOverviewValue } from './git/WorktreeGitOverview.js';
20
+ import { GitBranchPicker } from '../branch/GitBranchSelector.js';
19
21
  import { ToolSettings } from '../settings/ToolSettings.js';
20
22
  const TABS = ['overview', 'git', 'sessions', 'children', 'settings'];
23
+ /** getRandomValues is also available on plain-HTTP LAN origins. */
24
+ function createSyncRequestId() {
25
+ return 'sync:' + Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, '0')).join('');
26
+ }
27
+ function baselineSyncFailureNotices(record, requestId, result, t, onOpenSession) {
28
+ if (result.status === 'dispatched')
29
+ return [];
30
+ const status = result.status;
31
+ const context = record.branch + ' · ' + record.absolutePath;
32
+ return [{
33
+ key: JSON.stringify(['sync', record.workspaceId, record.worktreeId, requestId, result.sessionId]),
34
+ context,
35
+ error: {
36
+ code: 'WORKTREE_SYNC_PARTIAL', message: result.error ?? '', retryable: false,
37
+ details: { workspaceId: record.workspaceId, worktreeId: record.worktreeId,
38
+ requestId, sessionId: result.sessionId, status },
39
+ },
40
+ text: t(`dashboard.sync.${status}`) + ' ' + t('dashboard.sync.partial'),
41
+ message: (translate) => translate(`dashboard.sync.${status}`) + ' ' + translate('dashboard.sync.partial'),
42
+ describe: (translate) => translate('dashboard.action.sync') + ' · ' + context,
43
+ actions: onOpenSession === undefined ? [] : [{
44
+ label: t('dashboard.sync.openSession'), leaveSettings: true,
45
+ onClick: () => onOpenSession(result.sessionId),
46
+ }],
47
+ }];
48
+ }
21
49
  function DashboardIcon({ kind }) {
22
50
  const paths = {
23
51
  overview: 'M3 3h7v7H3z M14 3h7v7h-7z M3 14h7v7H3z M14 14h7v7h-7z',
@@ -36,27 +64,34 @@ function Card({ title, icon, action, children, }) {
36
64
  function DashboardFactRow({ label, children, action, baseline = false, }) {
37
65
  return (_jsxs("div", { children: [_jsx("dt", { children: label }), _jsx("dd", { "data-dashboard-baseline": baseline ? true : undefined, children: children }), _jsx("span", { className: styles.dashboardFactAction, children: action })] }));
38
66
  }
39
- function PlaceholderButton({ children, t }) {
40
- return (_jsx("button", { type: "button", className: styles.dashboardButton, disabled: true, title: t('dashboard.soon'), children: children }));
41
- }
42
- function WorktreeBaselineEditor({ value, branches, currentBranch, onSave, t, disabled, context, }) {
67
+ function WorktreeBaselineEditor({ value, renderValue, branches, loading, currentBranch, onSave, onFetch, onLoad, t, disabled, context, }) {
43
68
  const [saved, setSaved] = useState(value);
44
69
  const [draft, setDraft] = useState();
45
- const [search, setSearch] = useState('');
46
70
  const [pending, setPending] = useState(false);
47
71
  const [error, setError] = useState();
48
72
  const busy = useRef(false);
49
73
  const alive = useRef(true);
50
- const optionRefs = useRef([]);
51
74
  const trigger = useRef(null);
52
75
  const wasOpen = useRef(false);
53
76
  const expected = useRef(value);
54
- const pickerId = useId();
55
- const options = branches.filter((branch) => branch.name !== currentBranch);
77
+ // Workspace projections omit the branch catalog; this editor owns on-demand results.
78
+ const [fetched, setFetched] = useState();
79
+ const [reading, setReading] = useState(false);
80
+ const editorOpen = useRef(false);
81
+ const editorGeneration = useRef(0);
82
+ const requestGeneration = useRef(0);
83
+ const roster = fetched ?? branches;
84
+ const options = useMemo(() => roster.filter((branch) => branch.kind === 'remote' || branch.name !== currentBranch), [roster, currentBranch]);
85
+ const draftMatches = options.filter((branch) => (branch.ref ?? branch.name) === draft ||
86
+ (!draft?.startsWith('refs/') && (branch.name === draft ||
87
+ (branch.kind === 'remote' && 'remotes/' + branch.name === draft))));
88
+ const validDraft = draftMatches.length === 1;
56
89
  useEffect(() => {
57
90
  alive.current = true;
58
91
  return () => {
59
92
  alive.current = false;
93
+ editorGeneration.current++;
94
+ requestGeneration.current++;
60
95
  };
61
96
  }, []);
62
97
  useEffect(() => {
@@ -71,58 +106,48 @@ function WorktreeBaselineEditor({ value, branches, currentBranch, onSave, t, dis
71
106
  const closeEditor = () => {
72
107
  if (pending)
73
108
  return;
109
+ editorOpen.current = false;
110
+ editorGeneration.current++;
111
+ requestGeneration.current++;
112
+ setReading(false);
74
113
  setDraft(undefined);
75
- setSearch('');
76
114
  setError(undefined);
77
115
  };
78
116
  const openEditor = () => {
117
+ editorOpen.current = true;
118
+ editorGeneration.current++;
119
+ requestGeneration.current++;
120
+ setReading(false);
79
121
  expected.current = saved;
80
122
  setDraft(saved ?? '');
81
- setSearch('');
82
123
  setError(undefined);
83
124
  };
84
- const query = search.trim().toLowerCase();
85
- const filteredOptions = query.length === 0
86
- ? options
87
- : options.filter((branch) => branch.name.toLowerCase().includes(query));
88
- const activeIndex = filteredOptions.findIndex((branch) => branch.name === draft);
89
- // The list is a permanent, fixed-height region: filtering swaps its rows but
90
- // never changes its height, so the modal frame stays put.
91
- const listOpen = filteredOptions.length > 0;
92
- const selectOption = (index) => {
93
- if (pending)
94
- return;
95
- const branch = filteredOptions[index];
96
- if (branch === undefined)
97
- return;
98
- setDraft(branch.name);
99
- };
100
- const moveOption = (offset) => {
101
- if (filteredOptions.length === 0)
102
- return;
103
- const nextIndex = activeIndex < 0
104
- ? offset > 0
105
- ? 0
106
- : filteredOptions.length - 1
107
- : (activeIndex + offset + filteredOptions.length) % filteredOptions.length;
108
- selectOption(nextIndex);
109
- optionRefs.current[nextIndex]?.scrollIntoView({ block: 'nearest' });
110
- };
111
- const onSearchKeyDown = (event) => {
112
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
113
- event.preventDefault();
114
- moveOption(event.key === 'ArrowDown' ? 1 : -1);
125
+ const lifetime = editorGeneration.current;
126
+ const readBranches = async (read) => {
127
+ if (!alive.current || !editorOpen.current || editorGeneration.current !== lifetime)
128
+ return options;
129
+ const request = ++requestGeneration.current;
130
+ const isCurrent = () => alive.current && editorOpen.current &&
131
+ editorGeneration.current === lifetime && requestGeneration.current === request;
132
+ setReading(true);
133
+ try {
134
+ const next = await read();
135
+ if (isCurrent())
136
+ setFetched(next);
137
+ return next.filter((branch) => branch.kind === 'remote' || branch.name !== currentBranch);
115
138
  }
116
- else if (event.key === 'Enter' && filteredOptions.length > 0) {
117
- event.preventDefault();
118
- selectOption(activeIndex < 0 ? 0 : activeIndex);
139
+ finally {
140
+ if (isCurrent())
141
+ setReading(false);
119
142
  }
120
143
  };
121
144
  const save = async () => {
122
145
  if (busy.current ||
123
146
  draft === undefined ||
124
147
  onSave === undefined ||
125
- !options.some((branch) => branch.name === draft))
148
+ loading ||
149
+ reading ||
150
+ !validDraft)
126
151
  return;
127
152
  busy.current = true;
128
153
  setPending(true);
@@ -132,8 +157,10 @@ function WorktreeBaselineEditor({ value, branches, currentBranch, onSave, t, dis
132
157
  if (alive.current) {
133
158
  setSaved(result);
134
159
  expected.current = result;
160
+ editorOpen.current = false;
161
+ editorGeneration.current++;
162
+ requestGeneration.current++;
135
163
  setDraft(undefined);
136
- setSearch('');
137
164
  }
138
165
  }
139
166
  catch (cause) {
@@ -146,9 +173,7 @@ function WorktreeBaselineEditor({ value, branches, currentBranch, onSave, t, dis
146
173
  setPending(false);
147
174
  }
148
175
  };
149
- return (_jsxs(_Fragment, { children: [_jsx(DashboardFactRow, { label: t('dashboard.base'), baseline: true, action: onSave !== undefined ? (_jsx(Tooltip, { label: t('dashboard.editBase'), side: "bottom", delayMs: 500, disabled: disabled || options.length === 0, children: _jsx("button", { type: "button", ref: trigger, className: styles.dashboardIconButton, "data-dashboard-baseline-edit": true, "aria-label": t('dashboard.editBase'), title: t('dashboard.editBase'), "aria-haspopup": "dialog", "aria-expanded": draft !== undefined, disabled: disabled || options.length === 0, onClick: openEditor, children: _jsx(IconEditOutline16, {}) }) })) : undefined, children: saved === undefined ? (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) : (_jsx("span", { "data-dashboard-baseline-value": true, children: saved })) }), _jsx(Modal, { open: draft !== undefined, onClose: closeEditor, closeLabel: t('dialog.closeBaseline'), title: t('dashboard.editBase'), description: t('dashboard.editBaseDescription'), className: styles.dashboardBaselineModal, contentClassName: styles.dashboardBaselineModalContent, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", disabled: pending, onClick: closeEditor, children: t('dashboard.cancelBase') }), _jsx(Button, { variant: "primary", "data-dashboard-baseline-save": true, disabled: pending || disabled || !options.some((branch) => branch.name === draft), onClick: () => void save(), children: t(pending ? 'dashboard.savingBase' : 'dashboard.saveBase') })] }), children: _jsxs("div", { className: styles.dashboardBaselinePicker, "data-dashboard-baseline-modal": true, children: [_jsx(Input, { icon: _jsx(IconSearchOutline16, {}), className: styles.dashboardBaselineSearch, "aria-label": t('dashboard.searchBranches'), role: "combobox", "aria-autocomplete": "list", "aria-controls": listOpen ? `${pickerId}-options` : undefined, "aria-expanded": listOpen, "aria-haspopup": "listbox", "aria-activedescendant": listOpen && activeIndex >= 0 ? `${pickerId}-option-${activeIndex}` : undefined, "data-dashboard-baseline-search": true, disabled: pending || disabled, placeholder: t('dashboard.searchBranches'), value: search, onKeyDown: onSearchKeyDown, onChange: (event) => setSearch(event.currentTarget.value) }), _jsx("div", { className: styles.dashboardBaselineOptions, "data-dashboard-baseline-options": true, children: listOpen ? (_jsx("div", { id: `${pickerId}-options`, className: styles.dashboardBaselineList, role: "listbox", "aria-label": t('dashboard.searchBranches'), children: filteredOptions.map((branch, index) => (_jsxs("button", { type: "button", ref: (element) => {
150
- optionRefs.current[index] = element;
151
- }, id: `${pickerId}-option-${index}`, className: styles.dashboardBaselineOption, "data-dashboard-baseline-option": branch.name, "data-highlighted": activeIndex === index ? true : undefined, role: "option", "aria-selected": branch.name === draft, onClick: () => selectOption(index), children: [_jsx(IconBranchOutline16, {}), _jsx("span", { className: styles.dashboardBaselineOptionLabel, children: branch.name }), branch.name === draft && _jsx(IconCheckOutline16, {})] }, branch.name))) })) : (_jsx("div", { className: styles.dashboardBaselineEmpty, "data-dashboard-baseline-empty": true, role: "status", "aria-live": "polite", children: t('dashboard.noMatchingBranches') })) }), _jsx(NotificationToasts, { notices: error === undefined
176
+ return (_jsxs(_Fragment, { children: [_jsx(DashboardFactRow, { label: t('dashboard.base'), baseline: true, action: onSave !== undefined ? (_jsx(Tooltip, { label: t('dashboard.editBase'), side: "bottom", delayMs: 500, disabled: disabled || (options.length === 0 && onLoad === undefined), children: _jsx("button", { type: "button", ref: trigger, className: styles.dashboardIconButton, "data-dashboard-baseline-edit": true, "aria-label": t('dashboard.editBase'), title: t('dashboard.editBase'), "aria-haspopup": "dialog", "aria-expanded": draft !== undefined, disabled: disabled || (options.length === 0 && onLoad === undefined), onClick: openEditor, children: _jsx(IconEditOutline16, {}) }) })) : undefined, children: renderValue !== undefined ? renderValue(saved) : saved === undefined ? (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) : (_jsx("span", { "data-dashboard-baseline-value": true, title: saved, children: saved.replace(/^refs\/(heads|remotes)\//u, '') })) }), _jsx(Modal, { open: draft !== undefined, onClose: closeEditor, closeLabel: t('dialog.closeBaseline'), title: t('dashboard.editBase'), description: t('dashboard.editBaseDescription'), className: styles.dashboardBaselineModal, contentClassName: styles.dashboardBaselineModalContent, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", disabled: pending, onClick: closeEditor, children: t('dashboard.cancelBase') }), _jsx(Button, { variant: "primary", "data-dashboard-baseline-save": true, disabled: pending || disabled || loading || reading || !validDraft, onClick: () => void save(), children: t(pending ? 'dashboard.savingBase' : 'dashboard.saveBase') })] }), children: _jsxs("div", { className: styles.dashboardBaselinePicker, "data-dashboard-baseline-modal": true, children: [draft !== undefined && _jsx(GitBranchPicker, { branches: options, value: draft, onChange: setDraft, t: t, disabled: pending || disabled, loading: loading, onClose: closeEditor, onLoad: onLoad === undefined ? undefined : () => readBranches(onLoad), onFetch: onFetch === undefined ? undefined : () => readBranches(onFetch) }, lifetime), _jsx(NotificationToasts, { notices: error === undefined
152
177
  ? []
153
178
  : [
154
179
  {
@@ -167,7 +192,7 @@ function WorktreeBaselineEditor({ value, branches, currentBranch, onSave, t, dis
167
192
  ] })] }) })] }));
168
193
  }
169
194
  /** A managed Worktree or browser Main projection with explicit unavailable states for inapplicable facts. */
170
- export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose, onOpenSidebar, isRightSidebarExpanded, sessions, sessionPresentations, sessionIds, actionPending, onOpenSession, onCreateSession, onCreateWorktree, onArchiveWorktree, onOpenFile, onSaveInstructions, onSaveBaseline, branches = [], }) {
195
+ export function WorktreeDashboard({ manager, record, worktrees = [], mainRecord, onOpenWorktree, workspaceTitle, t, onClose, onOpenSidebar, isRightSidebarExpanded, sessions, sessionPresentations, sessionIds, actionPending, onOpenSession, onCreateSession, onCreateWorktree, onArchiveWorktree, onSyncBaseline, onOpenFile, onSaveInstructions, onSaveBaseline, onFetchBranches, onLoadBranches, branches = [], branchesLoading = false, }) {
171
196
  const surface = useRef(null);
172
197
  const heading = useRef(null);
173
198
  const [placement, setPlacement] = useState();
@@ -222,7 +247,7 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
222
247
  return () => {
223
248
  branchCopyGeneration.current += 1;
224
249
  };
225
- }, [record.branch]);
250
+ }, [record.branch, record.currentBranch, record.currentHead?.name]);
226
251
  const copyPath = async () => {
227
252
  if (copyPending.current)
228
253
  return;
@@ -243,8 +268,10 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
243
268
  copyPending.current = false;
244
269
  }
245
270
  };
246
- const branchAvailable = record.branch.length > 0;
247
- const displayBranch = branchAvailable ? record.branch : t('dashboard.branchUnavailable');
271
+ const isMain = isMainWorktreeId(record.worktreeId);
272
+ const refName = record.currentHead?.name ?? record.currentBranch ?? record.branch;
273
+ const branchAvailable = refName.length > 0;
274
+ const displayBranch = branchAvailable ? refName : t('dashboard.branchUnavailable');
248
275
  const copyBranch = async () => {
249
276
  if (!branchAvailable || branchCopyPending.current)
250
277
  return;
@@ -252,7 +279,7 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
252
279
  const generation = branchCopyGeneration.current;
253
280
  setBranchCopyState('pending');
254
281
  try {
255
- const copied = await writeClipboard(record.branch);
282
+ const copied = await writeClipboard(refName);
256
283
  if (generation === branchCopyGeneration.current)
257
284
  setBranchCopyState(copied ? 'copied' : 'failed');
258
285
  }
@@ -265,7 +292,7 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
265
292
  branchCopyPending.current = false;
266
293
  }
267
294
  };
268
- const healthKey = record.health === 'ready'
295
+ const healthKey = isMain ? 'dashboard.mainReady' : record.health === 'ready'
269
296
  ? 'worktree.ready'
270
297
  : record.health === 'repair'
271
298
  ? 'worktree.repair'
@@ -276,10 +303,10 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
276
303
  : record.health === 'cleaned'
277
304
  ? 'dashboard.cleaned'
278
305
  : 'dashboard.unknown';
279
- const liveBranch = record.currentBranch === null
306
+ const liveBranch = record.currentHead?.name ?? (record.currentBranch === null
280
307
  ? t('dashboard.detached')
281
308
  : (record.currentBranch ??
282
- (branchAvailable ? record.branch : t('dashboard.branchUnavailable')));
309
+ (branchAvailable ? record.branch : t('dashboard.branchUnavailable'))));
283
310
  const baselineCurrentBranch = record.currentBranch === undefined ? record.branch : (record.currentBranch ?? undefined);
284
311
  const persistBaseline = onSaveBaseline === undefined
285
312
  ? undefined
@@ -289,6 +316,73 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
289
316
  return result;
290
317
  };
291
318
  const displayedBaseline = onSaveBaseline === undefined ? record.baseBranch : baselineBranch;
319
+ const [syncOpen, setSyncOpen] = useState(false);
320
+ const [syncStrategy, setSyncStrategy] = useState('rebase');
321
+ const [syncPending, setSyncPending] = useState(false);
322
+ const [syncError, setSyncError] = useState();
323
+ const [syncResult, setSyncResult] = useState();
324
+ const syncRequest = useRef();
325
+ const syncBusy = useRef(false);
326
+ const syncGeneration = useRef(0);
327
+ useEffect(() => {
328
+ syncGeneration.current++;
329
+ syncBusy.current = false;
330
+ syncRequest.current = undefined;
331
+ setSyncOpen(false);
332
+ setSyncPending(false);
333
+ setSyncError(undefined);
334
+ setSyncResult(undefined);
335
+ return () => { syncGeneration.current++; };
336
+ }, [record.workspaceId, record.worktreeId, displayedBaseline, manager]);
337
+ const closeSync = () => {
338
+ if (syncBusy.current)
339
+ return;
340
+ syncGeneration.current++;
341
+ setSyncOpen(false);
342
+ };
343
+ const startSync = async () => {
344
+ if (syncBusy.current || syncResult || !onSyncBaseline || !displayedBaseline)
345
+ return;
346
+ const generation = syncGeneration.current;
347
+ syncBusy.current = true;
348
+ setSyncPending(true);
349
+ setSyncError(undefined);
350
+ let requestId = syncRequest.current;
351
+ try {
352
+ requestId ??= createSyncRequestId();
353
+ syncRequest.current = requestId;
354
+ const result = await onSyncBaseline(syncStrategy, displayedBaseline, requestId);
355
+ if (generation !== syncGeneration.current) {
356
+ // Retiring navigation must not discard an already-created Session's failure.
357
+ // Capture the original identity without reviving UI sources or callbacks.
358
+ if (result.status !== 'dispatched')
359
+ worktreeDiagnostics.recordInactive('sync:' + requestId, baselineSyncFailureNotices(record, requestId, result, t));
360
+ return;
361
+ }
362
+ setSyncResult(result);
363
+ if (result.status === 'dispatched') {
364
+ setSyncOpen(false);
365
+ onOpenSession(result.sessionId);
366
+ }
367
+ }
368
+ catch (cause) {
369
+ if (generation === syncGeneration.current)
370
+ setSyncError(toWorktreeViewError(cause));
371
+ }
372
+ finally {
373
+ if (generation === syncGeneration.current) {
374
+ syncBusy.current = false;
375
+ setSyncPending(false);
376
+ }
377
+ }
378
+ };
379
+ const partialSync = syncResult !== undefined && syncResult.status !== 'dispatched'
380
+ ? { ...syncResult, status: syncResult.status } : undefined;
381
+ const renderBaseline = (value) => {
382
+ const label = value === undefined ? (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) : (_jsx("span", { "data-dashboard-baseline-value": true, title: value, children: value.replace(/^refs\/(heads|remotes)\//u, '') }));
383
+ const base = selectBaseWorktree(record, worktrees, mainRecord, value);
384
+ return base === undefined || onOpenWorktree === undefined ? label : (_jsxs("button", { type: "button", className: styles.dashboardBaseLink, "data-dashboard-base-worktree": base.worktreeId, "aria-label": t('dashboard.openBaseWorktree'), title: t('dashboard.openBaseWorktree'), onClick: () => onOpenWorktree(base), children: [label, _jsx(IconChevronRightOutline14, {})] }));
385
+ };
292
386
  const gitOverview = useWorktreeGitOverview({
293
387
  manager,
294
388
  workspaceId: record.workspaceId,
@@ -300,14 +394,19 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
300
394
  const acquisitionFacts = selectWorktreeAcquisitionFacts(record);
301
395
  const acquisitionLabel = acquisitionFacts.timestampKind === 'imported' ? 'dashboard.imported' : 'dashboard.created';
302
396
  const tabLabel = (value) => t(`dashboard.tab.${value}`);
303
- const placeholder = _jsx("span", { className: styles.dashboardSoon, children: t('dashboard.soon') });
397
+ const derivedWorktrees = selectDerivedWorktrees(record, worktrees);
398
+ const worktreeList = (records) => records.length === 0 ? (_jsx("div", { className: styles.dashboardEmpty, children: _jsx("p", { children: t('dashboard.noChildren') }) })) : (_jsx("ul", { className: styles.dashboardSessions, children: records.map((child) => (_jsx("li", { children: _jsxs("button", { type: "button", "data-dashboard-worktree": child.worktreeId, disabled: onOpenWorktree === undefined, onClick: () => onOpenWorktree?.(child), children: [_jsx(IconBranchOutline16, {}), _jsxs("span", { className: styles.dashboardSessionLabel, children: [_jsx("strong", { children: child.currentHead?.name ?? child.currentBranch ?? child.branch }), _jsx("code", { className: styles.dashboardChildPath, children: child.absolutePath })] }), _jsxs("span", { className: styles.dashboardChildState, children: [child.status === 'removed' && _jsx("span", { className: styles.dashboardSoon, children: t('dashboard.archived') }), _jsx("span", { className: styles.dashboardHealth, "data-health": child.health ?? 'unknown', children: t(child.health === 'ready' ? 'worktree.ready'
399
+ : child.health === 'repair' ? 'worktree.repair'
400
+ : child.health === 'recovery-needed' ? 'worktree.recovery'
401
+ : child.health === 'branch-drift' ? 'worktree.branchDrift'
402
+ : child.health === 'cleaned' ? 'dashboard.cleaned' : 'dashboard.unknown') })] }), _jsx("span", { "aria-hidden": "true", children: "\u2192" })] }) }, child.worktreeId))) }));
304
403
  const selectTab = (next, focus = false) => {
305
404
  setTab(next);
306
405
  if (focus)
307
406
  document.getElementById(`${id}-${next}`)?.focus();
308
407
  };
309
408
  const tabLink = (next, label) => (_jsxs("button", { type: "button", className: styles.dashboardLink, onClick: () => selectTab(next, true), children: [label, _jsx("span", { "aria-hidden": "true", children: "\u2192" })] }));
310
- const sessionList = (ids) => ids.length === 0 ? (_jsx("div", { className: styles.dashboardEmpty, children: _jsx("p", { children: t('dashboard.noSessions') }) })) : (_jsx("ul", { className: styles.dashboardSessions, children: ids.map((sessionId) => {
409
+ const sessionList = (ids) => ids.length === 0 ? (_jsxs("div", { className: styles.dashboardEmpty, children: [_jsx("p", { children: t('dashboard.noSessions') }), onCreateSession !== undefined && _jsx("button", { type: "button", className: styles.dashboardButton, disabled: actionPending, onClick: onCreateSession, children: t('dashboard.newSession') })] })) : (_jsx("ul", { className: styles.dashboardSessions, children: ids.map((sessionId) => {
311
410
  const presentation = sessionPresentations[sessionId];
312
411
  const blank = isBlankSession(sessionId, sessions);
313
412
  const statusLabel = presentation === undefined ? undefined : sessionStatusLabel(t, presentation.status);
@@ -327,6 +426,12 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
327
426
  if (event.defaultPrevented)
328
427
  return;
329
428
  if (event.key === 'Escape') {
429
+ // Portal keys bubble through this React ancestor before the native
430
+ // Modal's document listener. Let it closeSync (including its busy guard).
431
+ if (syncOpen)
432
+ return;
433
+ if (event.target?.closest?.('[data-single-select-picker]'))
434
+ return;
330
435
  // Other dashboard menus own Escape even when focus remains elsewhere in the surface.
331
436
  if (event.currentTarget.querySelector('[role="menu"]'))
332
437
  return;
@@ -343,14 +448,7 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
343
448
  }, children: topActionIsCreateSession ? t('dashboard.newSession') : _jsxs(_Fragment, { children: ["\u2190 ", t('dashboard.back')] }) }), !rightSidebarOpen && onOpenSidebar !== undefined && (_jsx(Tooltip, { label: t('dashboard.openSidebar'), side: "bottom", delayMs: 500, children: _jsx("button", { type: "button", className: styles.dashboardSidebarButton, "aria-label": t('dashboard.openSidebar'), title: t('dashboard.openSidebar'), "data-sidebar-right-expand": true, onClick: () => {
344
449
  onOpenSidebar();
345
450
  setRightSidebarOpen(true);
346
- }, children: _jsx(IconPanelLeftOutline16, {}) }) }))] })] }), _jsxs("div", { className: styles.dashboardPage, children: [_jsxs("header", { className: styles.dashboardHeader, children: [_jsxs("div", { className: styles.dashboardIdentity, children: [_jsxs("div", { className: styles.dashboardTitleRow, "data-dashboard-copy": "branch", role: branchAvailable ? 'button' : undefined, tabIndex: branchAvailable ? 0 : undefined, "aria-label": branchAvailable ? t('dashboard.copyBranch') : undefined, title: branchAvailable ? t('dashboard.copyBranch') : undefined, "aria-busy": branchAvailable && branchCopyState === 'pending' ? true : undefined, onClick: branchAvailable ? () => void copyBranch() : undefined, onKeyDown: branchAvailable
347
- ? (event) => {
348
- if (event.key === 'Enter' || event.key === ' ') {
349
- event.preventDefault();
350
- void copyBranch();
351
- }
352
- }
353
- : undefined, children: [_jsx(IconBranchOutline16, {}), _jsx("h1", { id: `${id}-title`, ref: heading, tabIndex: -1, children: displayBranch }), _jsxs("span", { className: styles.dashboardHealth, "data-health": record.health ?? 'unknown', children: [_jsx("span", { "aria-hidden": "true", children: "\u25CF" }), t(healthKey)] }), record.status === 'removed' && (_jsx("span", { className: styles.dashboardSoon, children: t('dashboard.archived') }))] }), _jsxs("div", { className: styles.dashboardPath, children: [_jsx("span", { className: styles.dashboardFieldLabel, children: "cwd" }), _jsx("code", { children: record.absolutePath }), _jsx("button", { type: "button", className: styles.dashboardIconButton, "aria-label": t('worktree.copyPath'), title: t('worktree.copyPath'), disabled: copyState === 'pending', onClick: () => {
451
+ }, children: _jsx(IconPanelLeftOutline16, {}) }) }))] })] }), _jsxs("div", { className: styles.dashboardPage, children: [_jsxs("header", { className: styles.dashboardHeader, children: [_jsxs("div", { className: styles.dashboardIdentity, children: [_jsxs("div", { className: styles.dashboardTitleRow, children: [_jsx(IconBranchOutline16, {}), _jsx("h1", { id: `${id}-title`, ref: heading, tabIndex: -1, children: _jsx("button", { type: "button", className: styles.dashboardRefButton, "data-dashboard-copy": "branch", disabled: !branchAvailable, "aria-label": branchAvailable ? t('dashboard.copyBranch') : undefined, title: branchAvailable ? t('dashboard.copyBranch') : undefined, "aria-busy": branchAvailable && branchCopyState === 'pending' ? true : undefined, onClick: branchAvailable ? () => void copyBranch() : undefined, children: displayBranch }) }), record.currentHead?.kind !== undefined && record.currentHead.kind !== 'branch' && _jsx("span", { className: styles.dashboardSoon, children: t(record.currentHead.kind === 'tag' ? 'dashboard.refKind.tag' : 'dashboard.refKind.commit') }), _jsxs("span", { className: styles.dashboardHealth, "data-health": isMain ? 'local' : record.health ?? 'unknown', children: [_jsx("span", { "aria-hidden": "true", children: "\u25CF" }), t(healthKey)] }), record.status === 'removed' && (_jsx("span", { className: styles.dashboardSoon, children: t('dashboard.archived') }))] }), _jsxs("div", { className: styles.dashboardPath, children: [_jsx("span", { className: styles.dashboardFieldLabel, children: "cwd" }), _jsx("code", { children: record.absolutePath }), _jsx("button", { type: "button", className: styles.dashboardIconButton, "aria-label": t('worktree.copyPath'), title: t('worktree.copyPath'), disabled: copyState === 'pending', onClick: () => {
354
452
  void copyPath();
355
453
  }, children: _jsx(IconCopyOutline16, {}) })] }), _jsx(NotificationToasts, { notices: [
356
454
  ...(branchCopyState === 'failed'
@@ -367,7 +465,7 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
367
465
  ? t('dashboard.branchCopied')
368
466
  : copyState === 'copied'
369
467
  ? t('dashboard.copied')
370
- : '\u00a0' })] }), _jsx("div", { className: styles.dashboardHeaderAside, children: _jsxs("dl", { className: styles.dashboardFacts, children: [_jsx(DashboardFactRow, { label: t(acquisitionLabel), children: acquisitionFacts.timestamp ? (_jsx("time", { dateTime: acquisitionFacts.timestamp, children: new Date(acquisitionFacts.timestamp).toLocaleString() })) : (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) }), !isMainWorktreeId(record.worktreeId) && persistBaseline !== undefined ? (_jsx(WorktreeBaselineEditor, { context: workspaceTitle + ' · ' + record.branch + ' · ' + record.absolutePath, value: baselineBranch, branches: branches, currentBranch: baselineCurrentBranch, onSave: persistBaseline, t: t, disabled: record.status !== 'active' || record.health === 'recovery-needed' })) : (_jsx(DashboardFactRow, { label: t('dashboard.base'), baseline: true, children: displayedBaseline ?? (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) })), _jsx(DashboardFactRow, { label: t('dashboard.source'), children: isMainWorktreeId(record.worktreeId)
468
+ : '\u00a0' })] }), _jsx("div", { className: styles.dashboardHeaderAside, children: _jsxs("dl", { className: `${styles.dashboardFacts} ${styles.dashboardHeaderFacts}`, children: [!isMain && _jsx(DashboardFactRow, { label: t(acquisitionLabel), children: acquisitionFacts.timestamp ? (_jsx("time", { dateTime: acquisitionFacts.timestamp, children: new Date(acquisitionFacts.timestamp).toLocaleString() })) : (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) }), !isMain && (persistBaseline !== undefined ? (_jsx(WorktreeBaselineEditor, { context: workspaceTitle + ' · ' + record.branch + ' · ' + record.absolutePath, value: baselineBranch, renderValue: renderBaseline, branches: branches, loading: branchesLoading, currentBranch: baselineCurrentBranch, onSave: persistBaseline, onFetch: onFetchBranches, onLoad: onLoadBranches, t: t, disabled: record.status !== 'active' || record.health === 'recovery-needed' })) : (_jsx(DashboardFactRow, { label: t('dashboard.base'), baseline: true, children: renderBaseline(displayedBaseline) }))), _jsx(DashboardFactRow, { label: t('dashboard.source'), children: isMainWorktreeId(record.worktreeId)
371
469
  ? t('worktree.main')
372
470
  : t(record.source === 'external' ? 'dashboard.external' : 'dashboard.plugin') })] }) })] }), _jsx("div", { className: styles.dashboardTabs, role: "tablist", "aria-label": t('dashboard.title'), children: TABS.map((value) => (_jsxs("button", { type: "button", id: `${id}-${value}`, role: "tab", "aria-selected": tab === value, "aria-controls": `${id}-panel`, tabIndex: tab === value ? 0 : -1, onClick: () => selectTab(value), onKeyDown: (event) => {
373
471
  const index = TABS.indexOf(value);
@@ -384,11 +482,19 @@ export function WorktreeDashboard({ manager, record, workspaceTitle, t, onClose,
384
482
  event.preventDefault();
385
483
  selectTab(next, true);
386
484
  }
387
- }, children: [_jsx(DashboardIcon, { kind: value }), tabLabel(value)] }, value))) }), _jsx("div", { id: `${id}-panel`, role: "tabpanel", "aria-labelledby": `${id}-${tab}`, tabIndex: 0, className: styles.dashboardPanel, children: tab === 'overview' ? (_jsxs("div", { className: styles.dashboardGrid, children: [_jsxs("div", { className: styles.dashboardColumn, children: [_jsxs("section", { className: styles.dashboardStart, children: [_jsxs("h2", { children: [_jsx(IconBranchOutline16, {}), t('dashboard.start')] }), _jsx("p", { children: t('dashboard.startDescription') }), _jsxs("div", { className: styles.dashboardStartActions, children: [_jsxs("button", { type: "button", disabled: actionPending || !onCreateWorktree, onClick: onCreateWorktree, "data-dashboard-action": "create-worktree", children: [_jsx(DashboardIcon, { kind: "git" }), _jsxs("span", { children: [_jsx("strong", { children: t('dashboard.newWorktree') }), _jsx("small", { children: t('dashboard.newWorktreeDescription') })] })] }), _jsxs("button", { type: "button", disabled: actionPending || !onCreateSession, onClick: onCreateSession, "data-dashboard-action": "create-session", children: [_jsx(DashboardIcon, { kind: "sessions" }), _jsxs("span", { children: [_jsx("strong", { children: t('dashboard.newSession') }), _jsx("small", { children: t('dashboard.newSessionDescription') })] })] })] })] }), _jsxs(Card, { title: t('dashboard.instructions'), icon: _jsx(DashboardIcon, { kind: "instructions" }), children: [_jsx("p", { children: t('dashboard.instructionsDescription') }), _jsx(WorktreeInstructions, { context: workspaceTitle + ' · ' + record.branch + ' · ' + record.absolutePath, value: record.instructions ?? '', onSave: onSaveInstructions, t: t, disabled: actionPending || record.health === 'recovery-needed' })] }), _jsxs(Card, { title: tabLabel('sessions'), icon: _jsx(DashboardIcon, { kind: "sessions" }), action: _jsx("span", { children: sessionIds.length }), children: [sessionList(sessionIds.slice(0, 5)), tabLink('sessions', t('dashboard.viewSessions'))] })] }), _jsxs("div", { className: styles.dashboardColumn, children: [_jsxs(Card, { title: t('dashboard.status'), icon: _jsx(DashboardIcon, { kind: "git" }), children: [_jsx("p", { children: t('dashboard.statusHint') }), _jsxs("dl", { className: styles.dashboardFacts, children: [_jsx(DashboardFactRow, { label: t('dashboard.health'), children: t(healthKey) }), _jsx(DashboardFactRow, { label: t('dashboard.branch'), children: liveBranch }), _jsx(DashboardFactRow, { label: t('dashboard.base'), children: displayedBaseline ?? (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) }), _jsx(DashboardFactRow, { label: t('dashboard.aheadBehind'), children: _jsx(WorktreeGitOverviewValue, { state: gitOverview, metric: "aheadBehind", t: t }) }), _jsx(DashboardFactRow, { label: t('dashboard.committedChanges'), children: _jsx(WorktreeGitOverviewValue, { state: gitOverview, metric: "committed", t: t }) }), _jsx(DashboardFactRow, { label: t('dashboard.workingTree'), children: _jsx(WorktreeGitOverviewValue, { state: gitOverview, metric: "workingTree", t: t }) })] }), tabLink('git', t('dashboard.viewDetails'))] }), _jsxs(Card, { title: t('dashboard.derived'), icon: _jsx(DashboardIcon, { kind: "children" }), action: placeholder, children: [_jsx("div", { className: styles.dashboardEmpty, children: _jsx("p", { children: t('dashboard.childrenHint') }) }), tabLink('children', t('dashboard.viewChildren'))] }), _jsx(Card, { title: t('dashboard.quickActions'), icon: _jsx(DashboardIcon, { kind: "actions" }), children: _jsxs("div", { className: styles.dashboardQuickActions, children: [['terminal', 'diff', 'pullRequest', 'tests', 'sync'].map((action) => (_jsx(PlaceholderButton, { t: t, children: t(`dashboard.action.${action}`) }, action))), _jsx("button", { type: "button", className: styles.dashboardButton, disabled: actionPending || !onArchiveWorktree, onClick: onArchiveWorktree, "data-dashboard-action": "archive-worktree", children: t('dashboard.action.archive') })] }) })] })] })) : tab === 'git' ? (_jsx(WorktreeGitPanel, { context: workspaceTitle + ' · ' + record.branch + ' · ' + record.absolutePath, manager: manager, workspaceId: record.workspaceId, worktreeId: record.worktreeId, defaultBaselineBranch: displayedBaseline, currentBranch: baselineCurrentBranch, capturedBaseline: record.baseCommit !== undefined, onOpenFile: (filePath) => {
485
+ }, children: [_jsx(DashboardIcon, { kind: value }), tabLabel(value)] }, value))) }), _jsx("div", { id: `${id}-panel`, role: "tabpanel", "aria-labelledby": `${id}-${tab}`, tabIndex: 0, className: styles.dashboardPanel, children: tab === 'overview' ? (_jsxs("div", { className: styles.dashboardGrid, children: [_jsxs("div", { className: styles.dashboardColumn, children: [_jsxs("section", { className: styles.dashboardStart, children: [_jsxs("h2", { children: [_jsx(IconBranchOutline16, {}), t('dashboard.start')] }), _jsx("p", { children: t('dashboard.startDescription') }), _jsxs("div", { className: styles.dashboardStartActions, children: [_jsxs("button", { type: "button", disabled: actionPending || !onCreateWorktree, onClick: onCreateWorktree, "data-dashboard-action": "create-worktree", children: [_jsx(DashboardIcon, { kind: "git" }), _jsxs("span", { children: [_jsx("strong", { children: t('dashboard.newWorktree') }), _jsx("small", { children: t('dashboard.newWorktreeDescription') })] })] }), _jsxs("button", { type: "button", disabled: actionPending || !onCreateSession, onClick: onCreateSession, "data-dashboard-action": "create-session", children: [_jsx(DashboardIcon, { kind: "sessions" }), _jsxs("span", { children: [_jsx("strong", { children: t('dashboard.newSession') }), _jsx("small", { children: t('dashboard.newSessionDescription') })] })] })] })] }), _jsxs(Card, { title: t('dashboard.instructions'), icon: _jsx(DashboardIcon, { kind: "instructions" }), children: [_jsx("p", { children: t('dashboard.instructionsDescription') }), _jsx(WorktreeInstructions, { context: workspaceTitle + ' · ' + record.branch + ' · ' + record.absolutePath, value: record.instructions ?? '', onSave: onSaveInstructions, t: t, disabled: actionPending || record.health === 'recovery-needed' })] }), _jsxs(Card, { title: tabLabel('sessions'), icon: _jsx(DashboardIcon, { kind: "sessions" }), action: _jsx("span", { children: sessionIds.length }), children: [sessionList(sessionIds.slice(0, 5)), tabLink('sessions', t('dashboard.viewSessions'))] })] }), _jsxs("div", { className: styles.dashboardColumn, children: [_jsxs(Card, { title: t('dashboard.status'), icon: _jsx(DashboardIcon, { kind: "git" }), children: [_jsx("p", { children: t('dashboard.statusHint') }), _jsxs("dl", { className: styles.dashboardFacts, children: [_jsx(DashboardFactRow, { label: t('dashboard.health'), children: t(healthKey) }), _jsx(DashboardFactRow, { label: t('dashboard.branch'), children: liveBranch }), !isMain && _jsx(DashboardFactRow, { label: t('dashboard.base'), children: displayedBaseline?.replace(/^refs\/(heads|remotes)\//u, '') ?? (_jsx("span", { className: styles.dashboardHistorical, children: t('dashboard.historicalUnavailable') })) }), _jsx(DashboardFactRow, { label: t('dashboard.aheadBehind'), children: _jsx(WorktreeGitOverviewValue, { state: gitOverview, metric: "aheadBehind", t: t }) }), _jsx(DashboardFactRow, { label: t('dashboard.committedChanges'), children: _jsx(WorktreeGitOverviewValue, { state: gitOverview, metric: "committed", t: t }) }), _jsx(DashboardFactRow, { label: t('dashboard.workingTree'), children: _jsx(WorktreeGitOverviewValue, { state: gitOverview, metric: "workingTree", t: t }) })] }), tabLink('git', t('dashboard.viewDetails'))] }), _jsxs(Card, { title: t('dashboard.derived'), icon: _jsx(DashboardIcon, { kind: "children" }), action: _jsx("span", { children: derivedWorktrees.length }), children: [_jsx("p", { children: t('dashboard.childrenHint') }), worktreeList(derivedWorktrees.slice(0, 5)), tabLink('children', t('dashboard.viewChildren'))] }), _jsx(Card, { title: t('dashboard.quickActions'), icon: _jsx(DashboardIcon, { kind: "actions" }), children: _jsxs("div", { className: styles.dashboardQuickActions, children: [_jsx("button", { type: "button", className: styles.dashboardButton, "data-dashboard-action": "sync-baseline", disabled: actionPending || !onSyncBaseline || !displayedBaseline, onClick: () => {
486
+ setSyncOpen(true);
487
+ }, children: t('dashboard.action.sync') }), _jsx("button", { type: "button", className: styles.dashboardButton, disabled: actionPending || !onArchiveWorktree, onClick: onArchiveWorktree, "data-dashboard-action": "archive-worktree", children: t('dashboard.action.archive') })] }) })] })] })) : tab === 'git' ? (_jsx(WorktreeGitPanel, { context: workspaceTitle + ' · ' + record.branch + ' · ' + record.absolutePath, manager: manager, workspaceId: record.workspaceId, worktreeId: record.worktreeId, defaultBaselineBranch: displayedBaseline, currentBranch: baselineCurrentBranch, capturedBaseline: record.baseCommit !== undefined, onOpenFile: onOpenFile === undefined ? undefined : (filePath) => {
388
488
  onOpenFile?.(filePath);
389
- setRightSidebarOpen(true);
489
+ setRightSidebarOpen(isRightSidebarExpanded?.() ?? false);
390
490
  }, t: t })) : tab === 'sessions' ? (_jsx(Card, { title: tabLabel('sessions'), icon: _jsx(DashboardIcon, { kind: "sessions" }), action: _jsx("button", { type: "button", className: styles.dashboardButton, disabled: actionPending || !onCreateSession, onClick: onCreateSession, children: t('dashboard.newSession') }), children: sessionList(sessionIds) })) : tab === 'settings' ? (_jsx(Card, { title: tabLabel('settings'), icon: _jsx(DashboardIcon, { kind: "settings" }), children: _jsx(ToolSettings, { manager: manager, scope: isMainWorktreeId(record.worktreeId)
391
491
  ? { kind: 'local', workspaceId: record.workspaceId }
392
- : { kind: 'worktree', workspaceId: record.workspaceId, worktreeId: record.worktreeId }, t: t }, JSON.stringify([record.workspaceId, record.worktreeId])) })) : (_jsxs("section", { className: styles.dashboardTabPlaceholder, children: [_jsx(DashboardIcon, { kind: tab }), _jsx("h2", { children: tabLabel(tab) }), _jsx("p", { children: t(`dashboard.hint.${tab}`) }), placeholder] })) }), _jsx("p", { className: styles.dashboardFooter, children: t('dashboard.mvpHint') })] })] }));
492
+ : { kind: 'worktree', workspaceId: record.workspaceId, worktreeId: record.worktreeId }, t: t }, JSON.stringify([record.workspaceId, record.worktreeId])) })) : (_jsxs(Card, { title: tabLabel('children'), icon: _jsx(DashboardIcon, { kind: "children" }), action: _jsx("span", { children: derivedWorktrees.length }), children: [_jsx("p", { children: t('dashboard.childrenHint') }), worktreeList(derivedWorktrees)] })) }), _jsx("p", { className: styles.dashboardFooter, children: t('dashboard.mvpHint') })] }), _jsx(Modal, { open: syncOpen, onClose: closeSync, closeLabel: t('dialog.close'), title: t('dashboard.action.sync'), description: t('dashboard.sync.description'), className: styles.dashboardBaselineModal, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", disabled: syncPending, onClick: closeSync, children: t('dashboard.cancelBase') }), syncResult ? _jsx(Button, { variant: "primary", onClick: () => onOpenSession(syncResult.sessionId), children: t('dashboard.sync.openSession') }) : _jsx(Button, { variant: "primary", disabled: syncPending, onClick: () => void startSync(), children: t(syncPending ? 'dashboard.sync.creating' : 'dashboard.sync.create') })] }), children: _jsxs("div", { className: styles.dashboardSyncOptions, children: [_jsxs("p", { children: [_jsx("code", { children: displayedBaseline }), _jsx("span", { "aria-hidden": "true", children: " \u2192 " }), _jsx("code", { children: record.currentBranch ?? record.branch })] }), ['rebase', 'merge'].map((strategy) => _jsxs("label", { children: [_jsx("input", { type: "radio", name: `${id}-sync-strategy`, value: strategy, checked: syncStrategy === strategy, disabled: syncPending || syncResult !== undefined || syncError !== undefined, onChange: () => { syncRequest.current = undefined; setSyncStrategy(strategy); } }), _jsxs("span", { children: [_jsx("strong", { children: strategy === 'rebase' ? 'Rebase' : 'Merge baseline' }), _jsx("small", { children: t(`dashboard.sync.${strategy}`) })] })] }, strategy)), partialSync && _jsxs("p", { role: "status", children: [t(`dashboard.sync.${partialSync.status}`), _jsx("br", {}), t('dashboard.sync.partial'), _jsx("br", {}), _jsx("code", { children: partialSync.sessionId })] })] }) }), _jsx(NotificationToasts, { notices: partialSync !== undefined
493
+ ? baselineSyncFailureNotices(record, syncRequest.current, partialSync, t, onOpenSession)
494
+ : syncError === undefined ? [] : [{
495
+ key: 'sync:' + record.worktreeId, error: syncError,
496
+ text: t('dashboard.sync.failed') + ' ' + formatWorktreeViewError(syncError, t),
497
+ message: (translate) => translate('dashboard.sync.failed') + ' ' + formatWorktreeViewError(syncError, translate),
498
+ }] })] }));
393
499
  }
394
500
  //# sourceMappingURL=WorktreeDashboard.js.map