@kabmo-labs/kabmo 0.53.1 → 0.53.2

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 (110) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +384 -384
  3. package/dist/client/static/js/{Body-3v975hq3.js → Body-vaa10tcd.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-8xcj58sw.js → CsvGrid-wabx4e6w.js} +1 -1
  5. package/dist/client/static/js/{DocxView-fwmfpsg7.js → DocxView-22b3mhh5.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-gdtqj2vv.js → DrawioView-e02qhkp2.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-g4bp5mgq.js → HtmlPreview-q7hwcf4s.js} +1 -1
  8. package/dist/client/static/js/{ImageView-5e3vdyc9.js → ImageView-fxb60ge7.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-ssxr6q2d.js → LayoutWrapper-cey5agsf.js} +1 -1
  10. package/dist/client/static/js/MergeDiffView-1z9mwf73.js +1 -0
  11. package/dist/client/static/js/{Modal-px8tcv9m.js → Modal-e4yq7p5f.js} +1 -1
  12. package/dist/client/static/js/{PdfView-92rx0s88.js → PdfView-pf3angsq.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-s3d9nceb.js → SessionsView-mcvhpx0b.js} +1 -1
  14. package/dist/client/static/js/{SheetView-yeg7gtf9.js → SheetView-5ha5vvsr.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-6evr72fg.js → SvgPreview-45wqjw0b.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-a6n0cab2.js → abnfDiagram-O67JEVCF-gnf6krbs.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-z9k17qfg.js → architectureDiagram-NJMV4G6O-00fd0wsg.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-63d683v3.js → blockDiagram-BEXU5L5S-9c2sm96a.js} +1 -1
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-5bk6kv13.js → c4Diagram-YGBWAQC7-pemygn0s.js} +1 -1
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-s6rmr6vt.js → classDiagram-v2-NBCMYWYE-h7r3sx3s.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-wd5v7q2m.js → cose-bilkent-JH36ORCC-krx9crwv.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-j71tvbhy.js → cynefinDiagram-VND7K2PF-5rp2btew.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-q6x3d9xb.js → dagre-6A5THRUB-q57cnz52.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-g6e427jm.js → diagram-22UHCM2B-0bptn06k.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-rg3nty46.js → diagram-3UASUU5V-60snxawz.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-m82xv6ka.js → diagram-ATOU4E4O-bb0kewfp.js} +1 -1
  27. package/dist/client/static/js/{diagram-CDSNMT55-q3aa8sv0.js → diagram-CDSNMT55-3cdkns0z.js} +1 -1
  28. package/dist/client/static/js/{diagram-MLGK6HIB-nkyd150x.js → diagram-MLGK6HIB-03mbhzeq.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-1gchkss2.js → diagram-MPIPVDR6-bcvzqqf4.js} +1 -1
  30. package/dist/client/static/js/{dockerfile-f51g7549.js → dockerfile-7kqkk4tz.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4dsm3p06.js → ebnfDiagram-ZINNZB2B-sg6kwnbx.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-d8wtwxae.js → elk-276RUBZZ-5b8v0sdv.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-bq865cmc.js → erDiagram-OPXOYQCR-xbs156j5.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-sasgvf55.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ndnqbbzn.js → ganttDiagram-FUAMR5RP-4p7pfk6c.js} +1 -1
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-d9y6fnz0.js → gitGraphDiagram-X574FWY7-3xqwr9pf.js} +1 -1
  37. package/dist/client/static/js/{index-pd4s49n5.js → index-0btbxkxf.js} +1 -1
  38. package/dist/client/static/js/{index-h9p3748x.js → index-1d8ff4t7.js} +1 -1
  39. package/dist/client/static/js/{index-z0vvdpkv.js → index-1regq9wd.js} +1 -1
  40. package/dist/client/static/js/{index-k8ks184k.js → index-26a4afcr.js} +1 -1
  41. package/dist/client/static/js/{index-9eddntv4.js → index-3amzzsdk.js} +2 -2
  42. package/dist/client/static/js/{index-0fpc1h6v.js → index-3bmn5cc5.js} +1 -1
  43. package/dist/client/static/js/{index-stfccv2r.js → index-45vcpqp9.js} +1 -1
  44. package/dist/client/static/js/{index-mttf7ej7.js → index-5qtnmn76.js} +1 -1
  45. package/dist/client/static/js/{index-w39c85k3.js → index-ayx3q8t9.js} +1 -1
  46. package/dist/client/static/js/{index-8w69r0c4.js → index-c8ta3k4g.js} +7 -7
  47. package/dist/client/static/js/{index-8k568z0z.js → index-cj8v7b50.js} +1 -1
  48. package/dist/client/static/js/{index-xakrt0sx.js → index-cy6ceab8.js} +1 -1
  49. package/dist/client/static/js/{index-rc8f8gjk.js → index-cysdvwqw.js} +1 -1
  50. package/dist/client/static/js/{index-0ccj7j87.js → index-e2esj214.js} +1 -1
  51. package/dist/client/static/js/{index-pnjnvdvb.js → index-gzz6snng.js} +1 -1
  52. package/dist/client/static/js/{index-mnadx740.js → index-hp3s5r3g.js} +1 -1
  53. package/dist/client/static/js/{index-4pwk5cjy.js → index-hwq7zgqd.js} +1 -1
  54. package/dist/client/static/js/{index-2jtkrmry.js → index-j9t5xc3y.js} +1 -1
  55. package/dist/client/static/js/{index-hn0brpdf.js → index-jf8zcg99.js} +3 -3
  56. package/dist/client/static/js/{index-5g21qv2b.js → index-jg6ecfc7.js} +2 -2
  57. package/dist/client/static/js/{index-79qddnbx.js → index-mgs5nscx.js} +1 -1
  58. package/dist/client/static/js/{index-hav1hhbr.js → index-mtjbp5ga.js} +1 -1
  59. package/dist/client/static/js/{index-xf662xsf.js → index-ng3e6k6x.js} +1 -1
  60. package/dist/client/static/js/{index-vjk01ja9.js → index-nmhwjwmt.js} +1 -1
  61. package/dist/client/static/js/{index-049xtm14.js → index-nnhs52db.js} +1 -1
  62. package/dist/client/static/js/{index-f7sssx5h.js → index-p75b7phb.js} +1 -1
  63. package/dist/client/static/js/{index-6pxh5p8g.js → index-pak6t03c.js} +1 -1
  64. package/dist/client/static/js/{index-bcns8arc.js → index-pdkt3r4r.js} +1 -1
  65. package/dist/client/static/js/{index-6775m1pa.js → index-qj9tcz44.js} +1 -1
  66. package/dist/client/static/js/{index-7fkdwm69.js → index-rtpg4t84.js} +1 -1
  67. package/dist/client/static/js/{index-v8fztm3w.js → index-ryww3xxj.js} +1 -1
  68. package/dist/client/static/js/{index-7jr49rd4.js → index-trrmbq0h.js} +1 -1
  69. package/dist/client/static/js/{index-gr5wd7hv.js → index-vwxt5ss9.js} +1 -1
  70. package/dist/client/static/js/{index-046kc8ft.js → index-x0y2c61e.js} +1 -1
  71. package/dist/client/static/js/{index-25g1ydkd.js → index-xqkcx4az.js} +1 -1
  72. package/dist/client/static/js/{index-gm9cqsqg.js → index-yf5a6t3p.js} +1 -1
  73. package/dist/client/static/js/{index-53hrj27y.js → index-z7gd7nvb.js} +1 -1
  74. package/dist/client/static/js/{index-g46qcgp8.js → index-zc3snsr9.js} +1 -1
  75. package/dist/client/static/js/{infoDiagram-VRGFBTTK-t52bsrem.js → infoDiagram-VRGFBTTK-c362sv3t.js} +1 -1
  76. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-vysv38pr.js → ishikawaDiagram-OU5B5YK6-yc8ts8wj.js} +1 -1
  77. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-7222yn0y.js → journeyDiagram-ZHPQQLJL-178c75fy.js} +1 -1
  78. package/dist/client/static/js/{kanban-definition-PNTS6WVX-9cg88rcn.js → kanban-definition-PNTS6WVX-w6g3n001.js} +1 -1
  79. package/dist/client/static/js/{mermaid.core-3qc3zvgb.js → mermaid.core-vcdgn378.js} +2 -2
  80. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hdbsk349.js → mindmap-definition-NLK3R4M7-t9e8arca.js} +1 -1
  81. package/dist/client/static/js/one-dark-pro-17hh3q12.js +1 -0
  82. package/dist/client/static/js/one-light-cntgvscy.js +1 -0
  83. package/dist/client/static/js/{pegDiagram-GJSIUBJH-jtqqcrhq.js → pegDiagram-GJSIUBJH-nehn0x9n.js} +1 -1
  84. package/dist/client/static/js/{pieDiagram-5QR66LMP-2c82jghr.js → pieDiagram-5QR66LMP-p1t3ctd4.js} +1 -1
  85. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-vp2hw2a8.js → quadrantDiagram-O4NWA36T-614rtbfe.js} +1 -1
  86. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-4168nq4f.js → railroadDiagram-XR7U4H2S-2vpr6pw8.js} +1 -1
  87. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-gwqcyxag.js → requirementDiagram-PLB6GJNP-b91s5q3p.js} +1 -1
  88. package/dist/client/static/js/{rust-6m8myprw.js → rust-jj206pb7.js} +1 -1
  89. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-y5fakn56.js → sankeyDiagram-IPEJSGJF-4101kt9r.js} +1 -1
  90. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-z140kern.js → sequenceDiagram-PO4LG4MO-yq0cxg8c.js} +1 -1
  91. package/dist/client/static/js/{sizeCapture-INFHLROL-gfez373x.js → sizeCapture-INFHLROL-jkvq39vz.js} +1 -1
  92. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1d6h03nr.js → stateDiagram-v2-GCMORJYK-y0h7w5rw.js} +1 -1
  93. package/dist/client/static/js/{swimlanes-2SLR337P-75wg3n6d.js → swimlanes-2SLR337P-1y073wzx.js} +1 -1
  94. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-18fj17m7.js → swimlanesDiagram-TC7HE7FX-8ahz3c68.js} +1 -1
  95. package/dist/client/static/js/{timeline-definition-EJHVYXUP-q750z70f.js → timeline-definition-EJHVYXUP-yjb0g0ys.js} +1 -1
  96. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-9q7tg456.js → usecaseDiagram-POWQR4AR-8xjkxrkv.js} +1 -1
  97. package/dist/client/static/js/{vennDiagram-UO4OBE2U-010nw1kd.js → vennDiagram-UO4OBE2U-18wjbwtg.js} +1 -1
  98. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-7n33n10f.js → wardleyDiagram-VNRHLVJA-xqrfsrwp.js} +1 -1
  99. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7q0n5vvd.js → xychartDiagram-PMCCYNJV-azygghkz.js} +1 -1
  100. package/package.json +2 -2
  101. package/src/client/components/workspace/git-panel/index.test.ts +56 -7
  102. package/src/client/components/workspace/git-panel/index.tsx +9 -4
  103. package/src/client/components/workspace/repo-picker/index.test.tsx +29 -2
  104. package/src/client/hooks/workspace/commit-box.ts +6 -1
  105. package/src/server/lib/fs/fs-write-git.test.ts +17 -0
  106. package/src/server/lib/fs/git-repos.ts +32 -11
  107. package/dist/client/static/js/MergeDiffView-6t5t6exc.js +0 -1
  108. package/dist/client/static/js/flowDiagram-KWPJA3E3-z01c78q6.js +0 -1
  109. package/dist/client/static/js/one-dark-pro-3570ra7e.js +0 -1
  110. package/dist/client/static/js/one-light-3v5yk200.js +0 -1
@@ -27,6 +27,8 @@ import { GitPanel } from '@/client/components/workspace/git-panel';
27
27
  import { ToastStack } from '@/client/components/common/ToastStack';
28
28
  import { resetToasts } from '@/client/hooks/ui/toasts';
29
29
  import { SessionStateProvider } from '@/client/components/common/session-state-provider/index';
30
+ import { REPO_SCOPE_STATE_KEY } from '@/client/hooks/workspace/repo-scope';
31
+ import { getSessionValue, resetSessionStateStore } from '@/shared/lib/workspace/session-state/store';
30
32
  import { resetRealtimeClient } from '@/shared/lib/realtime/client';
31
33
  import { gitTopic, reposTopic } from '@/shared/lib/realtime/protocol';
32
34
  import { startRealtimeTestServer, type RealtimeTestServer } from '@/test-support/realtime-server';
@@ -75,6 +77,9 @@ afterEach(() => {
75
77
  reads = [];
76
78
  resetRealtimeClient();
77
79
  resetToasts();
80
+ // A pick written by one case must not move the next case's panel: the slot
81
+ // is process state, keyed by session id, and every case here uses one id.
82
+ resetSessionStateStore();
78
83
  server?.stop();
79
84
  });
80
85
 
@@ -89,11 +94,30 @@ async function mount(options: {
89
94
  httpSync?: { ahead: number; behind: number };
90
95
  /** What a POST to `/api/fs/git` answers — the action channel. */
91
96
  action?: unknown;
97
+ /** Discovered repos. A list without `'.'` makes the first entry the fallback. */
98
+ repos?: string[];
99
+ /**
100
+ * Workspace root. A case that WRITES a pick needs its own: the repo discovery
101
+ * store is process state keyed by root, so a snapshot left under one root
102
+ * would answer the next case's mount.
103
+ */
104
+ root?: string;
92
105
  } = {}): Promise<void> {
93
- server = await startRealtimeTestServer(new Map<string, TopicResolver>([
94
- [TOPIC, async () => statusOf(1, options.topicSync)],
95
- [reposTopic(ROOT), async () => ({ repos: ['.'], reposPending: false })],
96
- ]));
106
+ const root = options.root ?? ROOT;
107
+ const repos = options.repos ?? ['.'];
108
+ // The panel resolves `'.'` when the list holds it, else the first repo — the
109
+ // same rule as `resolveRepoForPanel` — and subscribes to THAT scope's topic.
110
+ const fallback = repos.includes('.') ? '.' : (repos[0] ?? '.');
111
+ const rootTopic = gitTopic(`${root}\u0000.`);
112
+ const topics = new Map<string, TopicResolver>([
113
+ [rootTopic, async () => statusOf(1, options.topicSync)],
114
+ [reposTopic(root), async () => ({ repos, reposPending: false })],
115
+ ]);
116
+ for (const repo of repos) {
117
+ const topic = gitTopic(`${root}\u0000${repo}`);
118
+ if (!topics.has(topic)) topics.set(topic, async () => statusOf(0));
119
+ }
120
+ server = await startRealtimeTestServer(topics);
97
121
  const win = new Window({ url: `http://127.0.0.1:${server.port}` });
98
122
  installDomGlobals(win);
99
123
  const target = globalThis as unknown as Record<string, unknown>;
@@ -102,7 +126,7 @@ async function mount(options: {
102
126
  const url = String(input);
103
127
  const json = (body: unknown) => new Response(JSON.stringify(body), { status: 200, headers: { 'content-type': 'application/json' } });
104
128
  if (url.includes('/state')) return json({ sessionId: SESSION, state: {} });
105
- if (url.includes('reposOnly')) return json({ repos: ['.'], reposPending: false });
129
+ if (url.includes('reposOnly')) return json({ repos, reposPending: false });
106
130
  // The action channel, before the status read: a mutation and a read share
107
131
  // `/api/fs/git` and differ only by method.
108
132
  if (init?.method === 'POST' && options.action !== undefined) return json(options.action);
@@ -122,7 +146,7 @@ async function mount(options: {
122
146
  null,
123
147
  // The panel raises into the page's ONE queue; the host is mounted
124
148
  // beside it, so the assertion covers the assembled path.
125
- h(GitPanel, { rootPath: ROOT, enabled: true }),
149
+ h(GitPanel, { rootPath: root, enabled: true }),
126
150
  h(ToastStack, {}),
127
151
  ),
128
152
  }),
@@ -131,7 +155,7 @@ async function mount(options: {
131
155
  });
132
156
  // Both reads must land before the assertion: with `fetched` still undefined
133
157
  // the old precedence would accidentally pass.
134
- await server.waitForTopic(TOPIC, (value) => value !== null);
158
+ await server.waitForTopic(gitTopic(`${root}\u0000${fallback}`), (value) => value !== null);
135
159
  for (let i = 0; i < 20; i += 1) await act(async () => {});
136
160
  }
137
161
 
@@ -158,6 +182,31 @@ describe('GitPanel change list', () => {
158
182
  for (let i = 0; i < 20; i += 1) await act(async () => {});
159
183
  expect(container.textContent).toContain('file-1.txt');
160
184
  });
185
+
186
+ test('choosing the repo the panel already resolved to pins the pick', async () => {
187
+ // With no stored pick and a root that is not a repository, the panel shows
188
+ // discovery's FIRST repo. Clicking that row used to be dropped as a no-op
189
+ // (`r !== activeRepo`), so the choice was never stored: the next list change
190
+ // resolved to whichever repo came first and the panel moved to a different
191
+ // working tree — the reported "it falls back to another workspace".
192
+ await mount({ repos: ['projects/alpha'], root: '/ws-pick' });
193
+ expect(getSessionValue(SESSION, REPO_SCOPE_STATE_KEY)).toBeUndefined();
194
+
195
+ const trigger = container.querySelector('button[title="Switch git project"]') as HTMLButtonElement;
196
+ expect(trigger.textContent).toContain('alpha');
197
+ await act(async () => {
198
+ trigger.click();
199
+ });
200
+ const row = [...document.querySelectorAll('button[role="option"]')].find((b) =>
201
+ b.textContent?.includes('projects/alpha'),
202
+ ) as HTMLButtonElement | undefined;
203
+ expect(row).toBeDefined();
204
+ await act(async () => {
205
+ row?.click();
206
+ });
207
+
208
+ expect(getSessionValue(SESSION, REPO_SCOPE_STATE_KEY)).toEqual({ root: '/ws-pick', repo: 'projects/alpha' });
209
+ });
161
210
  });
162
211
 
163
212
  /**
@@ -239,10 +239,15 @@ export function GitPanel({ className = '', enabled = true, rootPath, refreshKey
239
239
  rootPath={rootPath}
240
240
  reposScanning={reposScanning}
241
241
  onSelectRepo={(r) => {
242
- // The reload is the scope effect's job: it fires on the resolved
243
- // `activeRepo` change, so selecting here would fetch the same repo
244
- // twice.
245
- if (r !== activeRepo) setActiveRepo(r);
242
+ // ALWAYS store the choice, even when it equals the repo the panel
243
+ // already resolved to. A repo shown because it is the first of an
244
+ // empty/fallback list is NOT a pick, so skipping the write left the
245
+ // selection unpinned and the next list change (a walk finishing, a
246
+ // rescan) moved the panel to whichever repo came first — the
247
+ // reported "it fell back to another workspace". The reload stays the
248
+ // scope effect's job: the resolved value does not change here, so
249
+ // nothing is fetched twice.
250
+ setActiveRepo(r);
246
251
  }}
247
252
  onRefresh={() => {
248
253
  // The list comes from the TOPIC, so refreshing it is what updates the
@@ -51,7 +51,7 @@ afterAll(() => {
51
51
  restoreDomGlobals();
52
52
  });
53
53
 
54
- async function mount(repos: string[]): Promise<void> {
54
+ async function mount(repos: string[], activeRepo = '.'): Promise<void> {
55
55
  (globalThis as unknown as Record<string, unknown>).fetch = async () =>
56
56
  new Response(JSON.stringify({ success: true, details: [] }), {
57
57
  status: 200,
@@ -64,7 +64,7 @@ async function mount(repos: string[]): Promise<void> {
64
64
  render(
65
65
  h(GitRepoPicker, {
66
66
  rootPath: ROOT,
67
- activeRepo: '.',
67
+ activeRepo,
68
68
  onSelectRepo: (repo: string) => selections.push(repo),
69
69
  repos,
70
70
  scanning: false,
@@ -95,6 +95,33 @@ describe('GitRepoPicker', () => {
95
95
  expect(trigger().textContent).toContain('Workspace');
96
96
  });
97
97
 
98
+ test('names the selected repo before discovery has listed it', async () => {
99
+ // A reload starts discovery from scratch: the topic answers `['.']` until
100
+ // the walk finishes, while the session still holds the nested pick. Looking
101
+ // the selection up from the rows alone drew the workspace root — the PARENT
102
+ // folder, labelled with the workspace's own name — as if that were the
103
+ // chosen repository, and the repo the panel was reading was not even listed.
104
+ await mount(['.'], 'projects/a/token');
105
+ expect(trigger().textContent).toContain('token');
106
+ expect(trigger().textContent).not.toContain('Workspace');
107
+
108
+ await act(async () => {
109
+ trigger().click();
110
+ });
111
+ const active = menu().querySelector('button[aria-selected="true"]') as HTMLButtonElement | null;
112
+ expect(active?.textContent).toContain('projects/a/token');
113
+ // The root row is still a real choice beside it.
114
+ const rootRow = [...document.querySelectorAll('button[role="option"]')].find(
115
+ (b) => b.textContent?.trim() === 'Workspace',
116
+ );
117
+ expect(rootRow).toBeDefined();
118
+
119
+ await act(async () => {
120
+ active?.click();
121
+ });
122
+ expect(selections).toEqual(['projects/a/token']);
123
+ });
124
+
98
125
  test('offers the root row when discovery found only nested repos', async () => {
99
126
  // A workspace root that is a folder of nested repos is not itself a repo,
100
127
  // so discovery omits `'.'`. The root is still a legitimate scope, and the
@@ -153,7 +153,12 @@ export function useCommitBox({ rootPath, repo, execute }: UseCommitBoxOptions):
153
153
 
154
154
  const params = new URLSearchParams({ headMessage: '1' });
155
155
  if (rootPath) params.set('root', rootPath);
156
- if (repo && repo !== '.') params.set('repo', repo);
156
+ // ALWAYS send the repo, including `'.'`. The route's implicit-repo
157
+ // fallback (`repos.includes('.') ? '.' : repos[0]`) exists for a request
158
+ // that names none, so omitting the root pick made amend read the FIRST
159
+ // nested repo's HEAD message while the panel was on the workspace root —
160
+ // a different repository's commit seeded into the draft.
161
+ if (repo) params.set('repo', repo);
157
162
 
158
163
  let cancelled = false;
159
164
  void fetch(`/api/fs/git?${params.toString()}`)
@@ -280,4 +280,21 @@ describe('git-repos discovery', () => {
280
280
  rescanRepos(root);
281
281
  expect((await settled(root)).repos).toContain('two');
282
282
  });
283
+
284
+ test('a rescan keeps the previous list while its walk runs', async () => {
285
+ // The topic answers whatever `discoveredRepos` holds, and every picker on
286
+ // the root renders it. Blanking the cache to `['.']` for the length of the
287
+ // walk made a refresh drop every nested row — including the selected one,
288
+ // whose absence made the picker name the workspace ROOT instead.
289
+ const root = tempDir('repos');
290
+ gitInit(join(root, 'one'));
291
+ startRepoScan(root);
292
+ const first = await settled(root);
293
+
294
+ rescanRepos(root);
295
+ expect(discoveredRepos(root)).toEqual({ repos: first.repos, pending: true });
296
+
297
+ const second = await settled(root);
298
+ expect(second.repos).toContain('one');
299
+ });
283
300
  });
@@ -86,32 +86,53 @@ interface RepoDiscovery {
86
86
 
87
87
  const repoDiscovery = new Map<string, RepoDiscovery>();
88
88
 
89
- /** Begin the background walk for `rootDir`; a no-op once one has started. */
90
- export function startRepoScan(rootDir: string): void {
91
- if (repoDiscovery.has(rootDir)) return;
92
- const d: RepoDiscovery = { repos: ['.'], done: false };
89
+ /**
90
+ * Begin a background walk for `rootDir`, seeded with the list the client should
91
+ * see while it runs.
92
+ *
93
+ * The seed is why this is not inlined into `startRepoScan`: a FORCED rescan
94
+ * answers with the previous list, so the picker keeps the rows (and the pick's
95
+ * own row) instead of collapsing to the bare root for the length of the walk.
96
+ */
97
+ function beginScan(rootDir: string, seed: string[]): void {
98
+ const d: RepoDiscovery = { repos: seed, done: false };
93
99
  repoDiscovery.set(rootDir, d);
94
100
  void getRepos(rootDir)
95
- .then(repos => { d.repos = repos; d.done = true; })
96
- .catch(() => { d.repos = ['.']; d.done = true; })
101
+ // A newer scan may have replaced this entry (two rescans in flight, or a
102
+ // walk that outlived a rescan): only the CURRENT walk owns the cache.
103
+ .then(repos => { if (repoDiscovery.get(rootDir) === d) { d.repos = repos; d.done = true; } })
104
+ .catch(() => { if (repoDiscovery.get(rootDir) === d) { d.repos = ['.']; d.done = true; } })
97
105
  // The walk is STARTED by a read, so this completion is the only moment the
98
106
  // list becomes final — the `repos:` topic is re-snapshotted from it, and a
99
107
  // client watching the root never has to poll for the answer.
100
- .finally(() => emitRealtimeSignal('repos-scanned', undefined, rootDir));
108
+ .finally(() => {
109
+ if (repoDiscovery.get(rootDir) === d) emitRealtimeSignal('repos-scanned', undefined, rootDir);
110
+ });
111
+ }
112
+
113
+ /** Begin the background walk for `rootDir`; a no-op once one has started. */
114
+ export function startRepoScan(rootDir: string): void {
115
+ if (repoDiscovery.has(rootDir)) return;
116
+ beginScan(rootDir, ['.']);
101
117
  }
102
118
 
103
119
  /**
104
- * Drop the cached result for `rootDir` and start a fresh walk. Used by the
120
+ * Start a fresh walk for `rootDir`, ignoring the cached result. Used by the
105
121
  * repo-switcher's refresh button, which must not serve the previous answer.
122
+ *
123
+ * The PREVIOUS list is published while the new walk runs: the topic would
124
+ * otherwise report `['.']` as if discovery had found one repository, and every
125
+ * picker on the root dropped its nested rows — including the selected one —
126
+ * until the walk finished.
106
127
  */
107
128
  export function rescanRepos(rootDir: string): void {
108
- repoDiscovery.delete(rootDir);
109
- startRepoScan(rootDir);
129
+ const previous = repoDiscovery.get(rootDir)?.repos ?? ['.'];
130
+ beginScan(rootDir, previous);
110
131
  }
111
132
 
112
133
  /** The discovered repos for `rootDir`, and whether the walk is still running. */
113
134
  export function discoveredRepos(rootDir: string): { repos: string[]; pending: boolean } {
114
135
  const d = repoDiscovery.get(rootDir);
115
136
  if (!d) return { repos: ['.'], pending: false };
116
- return { repos: d.done ? d.repos : ['.'], pending: !d.done };
137
+ return { repos: d.repos, pending: !d.done };
117
138
  }
@@ -1 +0,0 @@
1
- import{pg}from"./index-6775m1pa.js";import"./index-4kchzh9y.js";import"./index-hav1hhbr.js";export{pg as MergeDiffView};
@@ -1 +0,0 @@
1
- import"./index-9eddntv4.js";import"./index-k8ks184k.js";import{eb}from"./index-mttf7ej7.js";export{eb as diagram};
@@ -1 +0,0 @@
1
- import{_h}from"./index-8w69r0c4.js";export{_h as default};
@@ -1 +0,0 @@
1
- import{Ih}from"./index-8w69r0c4.js";export{Ih as default};