@kabmo-labs/kabmo 0.53.0 → 0.53.1
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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +183 -183
- package/dist/client/static/js/{Body-sdq2yhmp.js → Body-3v975hq3.js} +3 -3
- package/dist/client/static/js/{CsvGrid-afz6vr3m.js → CsvGrid-8xcj58sw.js} +1 -1
- package/dist/client/static/js/{DocxView-xwjgt7qq.js → DocxView-fwmfpsg7.js} +1 -1
- package/dist/client/static/js/{DrawioView-7m4e8zcm.js → DrawioView-gdtqj2vv.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-tad0dezn.js → HtmlPreview-g4bp5mgq.js} +1 -1
- package/dist/client/static/js/{ImageView-7bpm4xhb.js → ImageView-5e3vdyc9.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-ehxhj6t3.js → LayoutWrapper-ssxr6q2d.js} +2 -2
- package/dist/client/static/js/MergeDiffView-6t5t6exc.js +1 -0
- package/dist/client/static/js/{Modal-5qt3v5gn.js → Modal-px8tcv9m.js} +9 -9
- package/dist/client/static/js/{PdfView-hbgnnana.js → PdfView-92rx0s88.js} +1 -1
- package/dist/client/static/js/{SessionsView-rv9jmr2e.js → SessionsView-s3d9nceb.js} +1 -1
- package/dist/client/static/js/{SheetView-55e0a8as.js → SheetView-yeg7gtf9.js} +1 -1
- package/dist/client/static/js/{SvgPreview-10fa6mj1.js → SvgPreview-6evr72fg.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-9w4p3dhe.js → abnfDiagram-O67JEVCF-a6n0cab2.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-5x6sb253.js → architectureDiagram-NJMV4G6O-z9k17qfg.js} +2 -2
- package/dist/client/static/js/{astro-m3fcq2sa.js → astro-asmathwv.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-2c6y4pkn.js → blockDiagram-BEXU5L5S-63d683v3.js} +2 -2
- package/dist/client/static/js/c-20y64hcp.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-45rtm401.js → c4Diagram-YGBWAQC7-5bk6kv13.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-rksw3aw9.js → classDiagram-v2-NBCMYWYE-s6rmr6vt.js} +2 -2
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-4hxtttt5.js → cose-bilkent-JH36ORCC-wd5v7q2m.js} +1 -1
- package/dist/client/static/js/cpp-ty6n0dg9.js +1 -0
- package/dist/client/static/js/css-ncvxaxt0.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-5dhexpf2.js → cynefinDiagram-VND7K2PF-j71tvbhy.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-1k3w4qm9.js → dagre-6A5THRUB-q6x3d9xb.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-fw76k272.js → diagram-22UHCM2B-g6e427jm.js} +2 -2
- package/dist/client/static/js/{diagram-3UASUU5V-qnb2gn31.js → diagram-3UASUU5V-rg3nty46.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-cavnxzpf.js → diagram-ATOU4E4O-m82xv6ka.js} +2 -2
- package/dist/client/static/js/{diagram-CDSNMT55-6dxaj054.js → diagram-CDSNMT55-q3aa8sv0.js} +2 -2
- package/dist/client/static/js/{diagram-MLGK6HIB-f16fv9ay.js → diagram-MLGK6HIB-nkyd150x.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-zsryj72g.js → diagram-MPIPVDR6-1gchkss2.js} +1 -1
- package/dist/client/static/js/{dockerfile-frznktsa.js → dockerfile-f51g7549.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-1zz5h7sw.js → ebnfDiagram-ZINNZB2B-4dsm3p06.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-25pehy1p.js → elk-276RUBZZ-d8wtwxae.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-ezpjhgzw.js → erDiagram-OPXOYQCR-bq865cmc.js} +2 -2
- package/dist/client/static/js/flowDiagram-KWPJA3E3-z01c78q6.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-n11hq4ag.js → ganttDiagram-FUAMR5RP-ndnqbbzn.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-3znkxh7y.js → gitGraphDiagram-X574FWY7-d9y6fnz0.js} +1 -1
- package/dist/client/static/js/{index-acpn178r.js → index-046kc8ft.js} +1 -1
- package/dist/client/static/js/{index-s78f7j47.js → index-049xtm14.js} +1 -1
- package/dist/client/static/js/{index-y79ebmam.js → index-0ccj7j87.js} +1 -1
- package/dist/client/static/js/{index-vjmy9r20.js → index-0fpc1h6v.js} +1 -1
- package/dist/client/static/js/{index-j97qmbbv.js → index-25g1ydkd.js} +1 -1
- package/dist/client/static/js/{index-4nvcwtvr.js → index-25zpywv7.js} +1 -1
- package/dist/client/static/js/{index-1qjxg7mh.js → index-2jtkrmry.js} +1 -1
- package/dist/client/static/js/{index-scmtzcv1.js → index-396g4zz4.js} +2 -2
- package/dist/client/static/js/{index-qrpx4sk1.js → index-3x88t8g9.js} +2 -2
- package/dist/client/static/js/{index-7ag37ghj.js → index-4kchzh9y.js} +8 -8
- package/dist/client/static/js/{index-5z7f6bq4.js → index-4pwk5cjy.js} +1 -1
- package/dist/client/static/js/{index-ht164kw9.js → index-53hrj27y.js} +1 -1
- package/dist/client/static/js/{index-2k6wyyds.js → index-5g21qv2b.js} +4 -4
- package/dist/client/static/js/{index-wvw70pgd.js → index-668fc1df.js} +2 -2
- package/dist/client/static/js/{index-gmea6fjd.js → index-6775m1pa.js} +5 -5
- package/dist/client/static/js/{index-5j0wejvq.js → index-6pxh5p8g.js} +2 -2
- package/dist/client/static/js/{index-4faphth3.js → index-79qddnbx.js} +1 -1
- package/dist/client/static/js/{index-tnhnysj1.js → index-7fkdwm69.js} +1 -1
- package/dist/client/static/js/index-7jr49rd4.js +2 -0
- package/dist/client/static/js/{index-ey0ckd66.js → index-8k568z0z.js} +2 -2
- package/dist/client/static/js/{index-dzp9rwy0.js → index-8w69r0c4.js} +161 -161
- package/dist/client/static/js/{index-m1hd7ska.js → index-9eddntv4.js} +25 -25
- package/dist/client/static/js/{index-zkkttvtx.js → index-bcns8arc.js} +2 -2
- package/dist/client/static/js/{index-8972fxm9.js → index-f7sssx5h.js} +1 -1
- package/dist/client/static/js/{index-1w92sjkm.js → index-g46qcgp8.js} +2 -2
- package/dist/client/static/js/{index-hqc2cazc.js → index-gm9cqsqg.js} +4 -4
- package/dist/client/static/js/{index-02skcm4d.js → index-gr5wd7hv.js} +1 -1
- package/dist/client/static/js/{index-5pbf6dcz.js → index-h9p3748x.js} +3 -3
- package/dist/client/static/js/{index-me7ag6sy.js → index-hav1hhbr.js} +1 -1
- package/dist/client/static/js/{index-58kgkwxt.js → index-hn0brpdf.js} +4 -4
- package/dist/client/static/js/{index-qj6b15r4.js → index-k8ks184k.js} +2 -2
- package/dist/client/static/js/{index-er7pj5k6.js → index-m6eh5g1q.js} +1 -1
- package/dist/client/static/js/{index-kyarw08m.js → index-mnadx740.js} +2 -2
- package/dist/client/static/js/{index-5hqjscys.js → index-mttf7ej7.js} +2 -2
- package/dist/client/static/js/{index-10cxm9ty.js → index-pd4s49n5.js} +2 -2
- package/dist/client/static/js/{index-32gh2645.js → index-pnjnvdvb.js} +1 -1
- package/dist/client/static/js/index-rc8f8gjk.js +1 -0
- package/dist/client/static/js/{index-ej1va073.js → index-rsyqf691.js} +2 -2
- package/dist/client/static/js/{index-e0h6xkpv.js → index-stfccv2r.js} +1 -1
- package/dist/client/static/js/{index-1e7fek0v.js → index-v8fztm3w.js} +1 -1
- package/dist/client/static/js/{index-z9msykm1.js → index-vjk01ja9.js} +1 -1
- package/dist/client/static/js/{index-b039ef9w.js → index-w39c85k3.js} +2 -2
- package/dist/client/static/js/{index-899yw6fh.js → index-x3g8fwkc.js} +2 -2
- package/dist/client/static/js/{index-dkz8d77n.js → index-xakrt0sx.js} +1 -1
- package/dist/client/static/js/{index-dzsjyzht.js → index-xf662xsf.js} +2 -2
- package/dist/client/static/js/{index-9n1cg95f.js → index-z0vvdpkv.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-kmv3jtrd.js → infoDiagram-VRGFBTTK-t52bsrem.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-5kp6geeh.js → ishikawaDiagram-OU5B5YK6-vysv38pr.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-6w5f1ddc.js → journeyDiagram-ZHPQQLJL-7222yn0y.js} +2 -2
- package/dist/client/static/js/json-xha2drny.js +1 -0
- package/dist/client/static/js/{julia-nwh5w343.js → julia-d18zhpyp.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-6esn6xqn.js → kanban-definition-PNTS6WVX-9cg88rcn.js} +2 -2
- package/dist/client/static/js/lua-njwwdj4s.js +1 -0
- package/dist/client/static/js/{mermaid.core-z83pf8ch.js → mermaid.core-3qc3zvgb.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-0h1nhw66.js → mindmap-definition-NLK3R4M7-hdbsk349.js} +1 -1
- package/dist/client/static/js/one-dark-pro-3570ra7e.js +1 -0
- package/dist/client/static/js/one-light-3v5yk200.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-xdcpr8my.js → pegDiagram-GJSIUBJH-jtqqcrhq.js} +1 -1
- package/dist/client/static/js/{perl-wb4wtc9x.js → perl-sns2qvmf.js} +1 -1
- package/dist/client/static/js/{php-9g594k9f.js → php-3q6v9eey.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-0210zd5b.js → pieDiagram-5QR66LMP-2c82jghr.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-j0rtvvcm.js → quadrantDiagram-O4NWA36T-vp2hw2a8.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-mzxat5g5.js → railroadDiagram-XR7U4H2S-4168nq4f.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-zq5b9ts2.js → requirementDiagram-PLB6GJNP-gwqcyxag.js} +2 -2
- package/dist/client/static/js/{ruby-c4hxsegh.js → ruby-f9k99tfq.js} +1 -1
- package/dist/client/static/js/{rust-vmn352hx.js → rust-6m8myprw.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-06s3r7bv.js → sankeyDiagram-IPEJSGJF-y5fakn56.js} +2 -2
- package/dist/client/static/js/{sass-6yxywx7t.js → sass-2syegq28.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-7s4gz4t5.js → sequenceDiagram-PO4LG4MO-z140kern.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-yensh9k2.js → sizeCapture-INFHLROL-gfez373x.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1q8p06fk.js → stateDiagram-v2-GCMORJYK-1d6h03nr.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-2mfxddzf.js → swimlanes-2SLR337P-75wg3n6d.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-k2xf0gby.js → swimlanesDiagram-TC7HE7FX-18fj17m7.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-xrk07evk.js → timeline-definition-EJHVYXUP-q750z70f.js} +2 -2
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ca9h5skn.js → usecaseDiagram-POWQR4AR-9q7tg456.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-c0y47znt.js → vennDiagram-UO4OBE2U-010nw1kd.js} +1 -1
- package/dist/client/static/js/{vue-rcdqpz7q.js → vue-e8e3q3hj.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-mfk1ck3n.js → wardleyDiagram-VNRHLVJA-7n33n10f.js} +1 -1
- package/dist/client/static/js/xml-8516fzfp.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-6f8xt89k.js → xychartDiagram-PMCCYNJV-7q0n5vvd.js} +2 -2
- package/package.json +1 -1
- package/src/client/hooks/chat/timeline/new-chat-open.ts +5 -3
- package/src/client/hooks/chat/timeline/new-chat.test.ts +18 -2
- package/src/client/hooks/chat/timeline/new-chat.ts +13 -12
- package/src/client/hooks/chat/timeline/scope.test.ts +100 -0
- package/src/client/hooks/chat/timeline/scope.ts +9 -9
- package/src/client/lib/tts/gapless.ts +205 -0
- package/src/client/lib/tts/player.test.ts +83 -64
- package/src/client/lib/tts/player.ts +48 -98
- package/src/server/lib/fs/fs-write-git.test.ts +2 -51
- package/src/server/lib/fs/git-ignore.test.ts +101 -0
- package/src/server/lib/fs/git-ignore.ts +38 -1
- package/src/server/lib/fs/listing.test.ts +19 -0
- package/src/shared/lib/workspace/active-project.test.ts +45 -0
- package/src/shared/lib/workspace/active-project.ts +21 -0
- package/dist/client/static/js/MergeDiffView-28xkyts9.js +0 -1
- package/dist/client/static/js/c-ypdp030b.js +0 -1
- package/dist/client/static/js/cpp-cxwev3gs.js +0 -1
- package/dist/client/static/js/css-6mxcqf8c.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-zh6hmn6g.js +0 -1
- package/dist/client/static/js/index-qva2vqbh.js +0 -2
- package/dist/client/static/js/index-xvh25zer.js +0 -1
- package/dist/client/static/js/json-mb8k0b1n.js +0 -1
- package/dist/client/static/js/lua-nxnqww9z.js +0 -1
- package/dist/client/static/js/one-dark-pro-wsgaqq27.js +0 -1
- package/dist/client/static/js/one-light-w8zdrvyc.js +0 -1
- package/dist/client/static/js/xml-vtrdnrn6.js +0 -1
|
@@ -12,17 +12,18 @@
|
|
|
12
12
|
* snapshot so the speaker button can follow the run it started.
|
|
13
13
|
*
|
|
14
14
|
* An answer is read as a stream. `speechChunks` cuts it at paragraph and
|
|
15
|
-
* sentence boundaries, two requests stay in flight, and each chunk
|
|
16
|
-
* soon as it lands
|
|
17
|
-
*
|
|
18
|
-
* suspends the
|
|
19
|
-
*
|
|
15
|
+
* sentence boundaries, two requests stay in flight, and each chunk is decoded
|
|
16
|
+
* into `GaplessAudio` as soon as it lands. The scheduler starts a chunk at the
|
|
17
|
+
* previous one's exact end, so a paragraph boundary is not an audio boundary.
|
|
18
|
+
* Pause suspends the shared audio context, which freezes every scheduled
|
|
19
|
+
* source at its current sample; resume continues from there.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { readKabmoSetting } from '@/shared/lib/settings/client';
|
|
23
23
|
import { ttsEngine } from '@/shared/lib/tts/engines';
|
|
24
24
|
import { normalizeTtsConfig, type TtsConfig } from '@/shared/lib/tts/settings';
|
|
25
25
|
import { speechChunks } from '@/shared/lib/tts/speakable';
|
|
26
|
+
import { GaplessAudio } from '@/client/lib/tts/gapless';
|
|
26
27
|
|
|
27
28
|
export type TtsStatus = 'idle' | 'loading' | 'playing' | 'paused' | 'error';
|
|
28
29
|
|
|
@@ -67,11 +68,8 @@ class TtsPlayer {
|
|
|
67
68
|
private snapshot: TtsSnapshot = IDLE;
|
|
68
69
|
private readonly listeners = new Set<() => void>();
|
|
69
70
|
private readonly cache = new Map<string, Blob>();
|
|
70
|
-
private
|
|
71
|
-
private objectUrl: string | null = null;
|
|
71
|
+
private playback: GaplessAudio | null = null;
|
|
72
72
|
private abort: AbortController | null = null;
|
|
73
|
-
/** Ends the chunk in flight; an argument reports it as a failure. */
|
|
74
|
-
private finishPlayback: ((message?: string) => void) | null = null;
|
|
75
73
|
private paused = false;
|
|
76
74
|
private run = 0;
|
|
77
75
|
|
|
@@ -98,35 +96,46 @@ class TtsPlayer {
|
|
|
98
96
|
return;
|
|
99
97
|
}
|
|
100
98
|
|
|
99
|
+
const playback = this.playback ??= GaplessAudio.create();
|
|
100
|
+
if (!playback) {
|
|
101
|
+
this.publish('error', key, 'This browser cannot play synthesized speech.');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
101
105
|
const run = ++this.run;
|
|
102
106
|
const controller = new AbortController();
|
|
103
107
|
this.abort = controller;
|
|
104
108
|
this.publish('loading', key, null);
|
|
105
109
|
|
|
106
|
-
void this.playChunks(chunks, config, key, run, controller);
|
|
110
|
+
void this.playChunks(playback, chunks, config, key, run, controller);
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
/** Hold the read where it is; the
|
|
113
|
+
/** Hold the read where it is; the audio context freezes every scheduled chunk. */
|
|
110
114
|
pause(): void {
|
|
111
115
|
const status = this.snapshot.status;
|
|
112
116
|
if (this.paused || (status !== 'playing' && status !== 'loading')) return;
|
|
113
117
|
this.paused = true;
|
|
114
|
-
this.
|
|
118
|
+
this.playback?.pause();
|
|
115
119
|
this.publish('paused', this.snapshot.activeKey, null);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
/** Continue a paused read from the sample
|
|
122
|
+
/** Continue a paused read from the sample where the context froze. */
|
|
119
123
|
resume(): void {
|
|
120
124
|
if (!this.paused) return;
|
|
121
125
|
this.paused = false;
|
|
122
|
-
const
|
|
126
|
+
const playback = this.playback;
|
|
123
127
|
const key = this.snapshot.activeKey;
|
|
124
|
-
if (!
|
|
125
|
-
this.publish('
|
|
128
|
+
if (!playback) {
|
|
129
|
+
this.publish('error', key, 'This browser cannot play synthesized speech.');
|
|
126
130
|
return;
|
|
127
131
|
}
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
|
|
133
|
+
const run = this.run;
|
|
134
|
+
this.publish(playback.hasAudio ? 'playing' : 'loading', key, null);
|
|
135
|
+
void playback.resume().catch((error: unknown) => {
|
|
136
|
+
if (run !== this.run || this.paused) return;
|
|
137
|
+
this.failRun(error instanceof Error ? error.message : 'The audio could not be played.');
|
|
138
|
+
});
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
stop(): void {
|
|
@@ -134,27 +143,14 @@ class TtsPlayer {
|
|
|
134
143
|
this.abort?.abort();
|
|
135
144
|
this.abort = null;
|
|
136
145
|
this.paused = false;
|
|
137
|
-
|
|
138
|
-
this.finishPlayback = null;
|
|
139
|
-
const audio = this.audio;
|
|
140
|
-
this.audio = null;
|
|
141
|
-
const url = this.objectUrl;
|
|
142
|
-
this.objectUrl = null;
|
|
143
|
-
if (audio) {
|
|
144
|
-
audio.onended = null;
|
|
145
|
-
audio.onerror = null;
|
|
146
|
-
audio.pause();
|
|
147
|
-
audio.removeAttribute('src');
|
|
148
|
-
audio.load();
|
|
149
|
-
}
|
|
150
|
-
if (url) URL.revokeObjectURL(url);
|
|
151
|
-
finish?.();
|
|
146
|
+
this.playback?.stop();
|
|
152
147
|
if (this.snapshot.status !== 'idle' || this.snapshot.activeKey !== null) {
|
|
153
148
|
this.publish('idle', null, null);
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
|
|
157
152
|
private async playChunks(
|
|
153
|
+
playback: GaplessAudio,
|
|
158
154
|
chunks: string[],
|
|
159
155
|
config: TtsConfig,
|
|
160
156
|
key: string,
|
|
@@ -168,21 +164,35 @@ class TtsPlayer {
|
|
|
168
164
|
promise.catch(() => undefined);
|
|
169
165
|
pending.set(index, promise);
|
|
170
166
|
};
|
|
171
|
-
for (let index = 0; index < PREFETCH_WINDOW; index += 1) startFetch(index);
|
|
172
167
|
|
|
173
168
|
try {
|
|
169
|
+
// A blocked autoplay must not spend a provider request before it fails.
|
|
170
|
+
await playback.ensure();
|
|
171
|
+
if (run !== this.run) return;
|
|
172
|
+
for (let index = 0; index < PREFETCH_WINDOW; index += 1) startFetch(index);
|
|
173
|
+
|
|
174
174
|
for (let index = 0; index < chunks.length; index += 1) {
|
|
175
175
|
if (run !== this.run) return;
|
|
176
176
|
const blob = await pending.get(index);
|
|
177
177
|
pending.delete(index);
|
|
178
178
|
if (!blob || run !== this.run) return;
|
|
179
179
|
startFetch(index + PREFETCH_WINDOW);
|
|
180
|
-
await
|
|
180
|
+
await playback.schedule(blob);
|
|
181
181
|
if (run !== this.run) return;
|
|
182
|
+
if (this.snapshot.status === 'loading') this.publish('playing', key, null);
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
|
|
185
|
+
await playback.finish();
|
|
185
186
|
if (run !== this.run) return;
|
|
187
|
+
playback.idle();
|
|
188
|
+
this.abort = null;
|
|
189
|
+
this.publish('idle', null, null);
|
|
190
|
+
} catch (error: unknown) {
|
|
191
|
+
if (run !== this.run) return;
|
|
192
|
+
controller.abort();
|
|
193
|
+
if (this.abort === controller) this.abort = null;
|
|
194
|
+
this.paused = false;
|
|
195
|
+
playback.stop();
|
|
186
196
|
const message = error instanceof Error ? error.message : 'Could not read the answer aloud.';
|
|
187
197
|
this.publish('error', key, message);
|
|
188
198
|
}
|
|
@@ -224,69 +234,9 @@ class TtsPlayer {
|
|
|
224
234
|
this.abort?.abort();
|
|
225
235
|
this.abort = null;
|
|
226
236
|
this.paused = false;
|
|
237
|
+
this.playback?.stop();
|
|
227
238
|
this.publish('error', this.snapshot.activeKey, message);
|
|
228
239
|
}
|
|
229
|
-
|
|
230
|
-
private startPlayback(audio: HTMLAudioElement, run: number): void {
|
|
231
|
-
void audio.play().then(() => {
|
|
232
|
-
if (run !== this.run || this.paused) return;
|
|
233
|
-
const status = this.snapshot.status;
|
|
234
|
-
if (status === 'loading' || status === 'paused') {
|
|
235
|
-
this.publish('playing', this.snapshot.activeKey, null);
|
|
236
|
-
}
|
|
237
|
-
}).catch((error: unknown) => {
|
|
238
|
-
if (run !== this.run || this.paused) return;
|
|
239
|
-
if (error instanceof Error && error.name === 'AbortError') return;
|
|
240
|
-
const blocked = error instanceof Error && error.name === 'NotAllowedError';
|
|
241
|
-
this.finishPlayback?.(
|
|
242
|
-
blocked
|
|
243
|
-
? 'The browser blocked autoplay. Press the speaker button to hear this answer.'
|
|
244
|
-
: 'The audio could not be played.',
|
|
245
|
-
);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
private playBlob(blob: Blob, run: number): Promise<void> {
|
|
250
|
-
if (run !== this.run) return Promise.resolve();
|
|
251
|
-
const audio = this.audio ?? new Audio();
|
|
252
|
-
this.audio = audio;
|
|
253
|
-
|
|
254
|
-
const url = URL.createObjectURL(blob);
|
|
255
|
-
const stale = this.objectUrl;
|
|
256
|
-
this.objectUrl = url;
|
|
257
|
-
audio.src = url;
|
|
258
|
-
if (stale) URL.revokeObjectURL(stale);
|
|
259
|
-
|
|
260
|
-
const finished = Promise.withResolvers<void>();
|
|
261
|
-
let settled = false;
|
|
262
|
-
const done = (): void => {
|
|
263
|
-
if (settled) return;
|
|
264
|
-
settled = true;
|
|
265
|
-
if (this.finishPlayback === fail) this.finishPlayback = null;
|
|
266
|
-
audio.onended = null;
|
|
267
|
-
audio.onerror = null;
|
|
268
|
-
audio.removeAttribute('src');
|
|
269
|
-
audio.load();
|
|
270
|
-
if (this.audio === audio) this.audio = null;
|
|
271
|
-
if (this.objectUrl === url) this.objectUrl = null;
|
|
272
|
-
URL.revokeObjectURL(url);
|
|
273
|
-
finished.resolve();
|
|
274
|
-
};
|
|
275
|
-
const fail = (message?: string): void => {
|
|
276
|
-
if (message) this.failRun(message);
|
|
277
|
-
done();
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
this.finishPlayback = fail;
|
|
281
|
-
audio.onended = done;
|
|
282
|
-
audio.onerror = () => {
|
|
283
|
-
if (run === this.run) fail('The audio could not be played.');
|
|
284
|
-
else done();
|
|
285
|
-
};
|
|
286
|
-
// A paused read never starts the next chunk; `resume` starts this one.
|
|
287
|
-
if (!this.paused) this.startPlayback(audio, run);
|
|
288
|
-
return finished.promise;
|
|
289
|
-
}
|
|
290
240
|
}
|
|
291
241
|
|
|
292
242
|
export const ttsPlayer = new TtsPlayer();
|
|
@@ -21,10 +21,8 @@
|
|
|
21
21
|
* `LOCK_TIMEOUT_MS`) are the one place real wall-clock time is exercised.
|
|
22
22
|
*
|
|
23
23
|
* `git-repos` walks a TEMP tree (`git init` in a couple of subdirs) to pin the
|
|
24
|
-
* pruning and depth rules that keep the walk bounded
|
|
25
|
-
*
|
|
26
|
-
* negation and directory matching, plus the "not a repository" (exit 128)
|
|
27
|
-
* non-answer.
|
|
24
|
+
* pruning and depth rules that keep the walk bounded. `git-ignore` has its own
|
|
25
|
+
* file (`git-ignore.test.ts`), next to the module whose scope it pins.
|
|
28
26
|
*/
|
|
29
27
|
|
|
30
28
|
import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
@@ -48,7 +46,6 @@ import { execFileSync } from 'node:child_process';
|
|
|
48
46
|
import { writeFileAtomic } from '@kabmo-labs/kabmo-fs/config/atomic-write';
|
|
49
47
|
import { withConfigLock } from '@kabmo-labs/kabmo-fs/config/config-lock';
|
|
50
48
|
import { discoveredRepos, rescanRepos, startRepoScan } from '@/server/lib/fs/git-repos';
|
|
51
|
-
import { collectIgnoredPaths } from '@/server/lib/fs/git-ignore';
|
|
52
49
|
import { testPosix } from '@/test-support/platform';
|
|
53
50
|
|
|
54
51
|
const tempDirs: string[] = [];
|
|
@@ -284,49 +281,3 @@ describe('git-repos discovery', () => {
|
|
|
284
281
|
expect((await settled(root)).repos).toContain('two');
|
|
285
282
|
});
|
|
286
283
|
});
|
|
287
|
-
|
|
288
|
-
describe('collectIgnoredPaths', () => {
|
|
289
|
-
test('no paths means no git call and an empty answer', async () => {
|
|
290
|
-
expect(await collectIgnoredPaths(tempDir('ignore'), [])).toEqual(new Set());
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
test('patterns, negation and directory patterns match what git refuses', async () => {
|
|
294
|
-
const dir = tempDir('ignore');
|
|
295
|
-
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
296
|
-
writeFileSync(join(dir, '.gitignore'), 'build/\n*.log\n!keep.log\n');
|
|
297
|
-
mkdirSync(join(dir, 'build'), { recursive: true });
|
|
298
|
-
writeFileSync(join(dir, 'build', 'x.txt'), '');
|
|
299
|
-
writeFileSync(join(dir, 'a.log'), '');
|
|
300
|
-
writeFileSync(join(dir, 'keep.log'), '');
|
|
301
|
-
mkdirSync(join(dir, 'src'), { recursive: true });
|
|
302
|
-
writeFileSync(join(dir, 'src', 'main.ts'), '');
|
|
303
|
-
|
|
304
|
-
const ignored = await collectIgnoredPaths(dir, ['build/x.txt', 'a.log', 'keep.log', 'src/main.ts']);
|
|
305
|
-
expect(ignored.has('build/x.txt')).toBe(true); // directory pattern
|
|
306
|
-
expect(ignored.has('a.log')).toBe(true); // extension pattern
|
|
307
|
-
expect(ignored.has('keep.log')).toBe(false); // negated
|
|
308
|
-
expect(ignored.has('src/main.ts')).toBe(false);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test('a non-repository (exit 128) is not cached as an answer', async () => {
|
|
312
|
-
const dir = tempDir('ignore');
|
|
313
|
-
writeFileSync(join(dir, 'a.log'), '');
|
|
314
|
-
expect(await collectIgnoredPaths(dir, ['a.log'])).toEqual(new Set());
|
|
315
|
-
// Same path, now inside a repository with a rule that matches it: had the
|
|
316
|
-
// 128 answer been cached, this would still be empty.
|
|
317
|
-
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
318
|
-
writeFileSync(join(dir, '.gitignore'), '*.log\n');
|
|
319
|
-
expect((await collectIgnoredPaths(dir, ['a.log'])).has('a.log')).toBe(true);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
test('an answer is cached for the TTL, so a just-edited rule is briefly stale', async () => {
|
|
323
|
-
const dir = tempDir('ignore');
|
|
324
|
-
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
325
|
-
writeFileSync(join(dir, '.gitignore'), '*.log\n');
|
|
326
|
-
writeFileSync(join(dir, 'a.log'), '');
|
|
327
|
-
expect((await collectIgnoredPaths(dir, ['a.log'])).has('a.log')).toBe(true);
|
|
328
|
-
rmSync(join(dir, '.gitignore'));
|
|
329
|
-
// Within the 5s TTL the memoized "ignored" answer is still returned.
|
|
330
|
-
expect((await collectIgnoredPaths(dir, ['a.log'])).has('a.log')).toBe(true);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `git check-ignore` as the Files panel's dim rule.
|
|
8
|
+
*
|
|
9
|
+
* Every case drives a REAL git against a temp tree: the question is what git
|
|
10
|
+
* refuses to track, so a hand-written pattern matcher would pin a second
|
|
11
|
+
* implementation instead of the authority. What is pinned is the scope of the
|
|
12
|
+
* answer — per-directory `.gitignore`, negation and directory patterns, the
|
|
13
|
+
* "not a repository" (exit 128) non-answer, the 5 s memo, and the ceiling that
|
|
14
|
+
* stops an enclosing repository from answering for a root it does not own.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterAll, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import { execFileSync } from 'node:child_process';
|
|
20
|
+
import { tmpdir } from 'node:os';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
import { collectIgnoredPaths } from '@/server/lib/fs/git-ignore';
|
|
23
|
+
|
|
24
|
+
const tempDirs: string[] = [];
|
|
25
|
+
|
|
26
|
+
function tempDir(prefix: string): string {
|
|
27
|
+
const dir = mkdtempSync(join(tmpdir(), `kabmo-${prefix}-`));
|
|
28
|
+
tempDirs.push(dir);
|
|
29
|
+
return dir;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
afterAll(() => {
|
|
33
|
+
for (const dir of tempDirs) rmSync(dir, { recursive: true, force: true });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('collectIgnoredPaths', () => {
|
|
37
|
+
test('no paths means no git call and an empty answer', async () => {
|
|
38
|
+
expect(await collectIgnoredPaths(tempDir('ignore'), [])).toEqual(new Set());
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('patterns, negation and directory patterns match what git refuses', async () => {
|
|
42
|
+
const dir = tempDir('ignore');
|
|
43
|
+
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
44
|
+
writeFileSync(join(dir, '.gitignore'), 'build/\n*.log\n!keep.log\n');
|
|
45
|
+
mkdirSync(join(dir, 'build'), { recursive: true });
|
|
46
|
+
writeFileSync(join(dir, 'build', 'x.txt'), '');
|
|
47
|
+
writeFileSync(join(dir, 'a.log'), '');
|
|
48
|
+
writeFileSync(join(dir, 'keep.log'), '');
|
|
49
|
+
mkdirSync(join(dir, 'src'), { recursive: true });
|
|
50
|
+
writeFileSync(join(dir, 'src', 'main.ts'), '');
|
|
51
|
+
|
|
52
|
+
const ignored = await collectIgnoredPaths(dir, ['build/x.txt', 'a.log', 'keep.log', 'src/main.ts']);
|
|
53
|
+
expect(ignored.has('build/x.txt')).toBe(true); // directory pattern
|
|
54
|
+
expect(ignored.has('a.log')).toBe(true); // extension pattern
|
|
55
|
+
expect(ignored.has('keep.log')).toBe(false); // negated
|
|
56
|
+
expect(ignored.has('src/main.ts')).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('an enclosing repository above the browsed root does not answer for it', async () => {
|
|
60
|
+
const outer = tempDir('ignore-nested');
|
|
61
|
+
execFileSync('git', ['init', '-q'], { cwd: outer });
|
|
62
|
+
writeFileSync(join(outer, '.gitignore'), 'projects/\n');
|
|
63
|
+
const root = join(outer, 'projects');
|
|
64
|
+
mkdirSync(join(root, 'child-one'), { recursive: true });
|
|
65
|
+
mkdirSync(join(root, 'child-two'), { recursive: true });
|
|
66
|
+
execFileSync('git', ['init', '-q'], { cwd: join(root, 'child-one') });
|
|
67
|
+
|
|
68
|
+
// `projects/` is ignored by the repository ABOVE the browsed root — the
|
|
69
|
+
// folder-of-repositories layout (`projects/<name>/.git`) that Kabmo opens
|
|
70
|
+
// as a workspace. Every row used to come back dimmed from those rules.
|
|
71
|
+
expect(await collectIgnoredPaths(root, ['child-one', 'child-two'])).toEqual(new Set());
|
|
72
|
+
|
|
73
|
+
// The root's OWN repository still answers: the ceiling is its parent, not
|
|
74
|
+
// the root itself (git treats a ceiling equal to the start as no ceiling).
|
|
75
|
+
writeFileSync(join(root, 'child-one', '.gitignore'), '*.log\n');
|
|
76
|
+
writeFileSync(join(root, 'child-one', 'a.log'), '');
|
|
77
|
+
expect((await collectIgnoredPaths(join(root, 'child-one'), ['a.log'])).has('a.log')).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('a non-repository (exit 128) is not cached as an answer', async () => {
|
|
81
|
+
const dir = tempDir('ignore');
|
|
82
|
+
writeFileSync(join(dir, 'a.log'), '');
|
|
83
|
+
expect(await collectIgnoredPaths(dir, ['a.log'])).toEqual(new Set());
|
|
84
|
+
// Same path, now inside a repository with a rule that matches it: had the
|
|
85
|
+
// 128 answer been cached, this would still be empty.
|
|
86
|
+
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
87
|
+
writeFileSync(join(dir, '.gitignore'), '*.log\n');
|
|
88
|
+
expect((await collectIgnoredPaths(dir, ['a.log'])).has('a.log')).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('an answer is cached for the TTL, so a just-edited rule is briefly stale', async () => {
|
|
92
|
+
const dir = tempDir('ignore');
|
|
93
|
+
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
94
|
+
writeFileSync(join(dir, '.gitignore'), '*.log\n');
|
|
95
|
+
writeFileSync(join(dir, 'a.log'), '');
|
|
96
|
+
expect((await collectIgnoredPaths(dir, ['a.log'])).has('a.log')).toBe(true);
|
|
97
|
+
rmSync(join(dir, '.gitignore'));
|
|
98
|
+
// Within the 5s TTL the memoized "ignored" answer is still returned.
|
|
99
|
+
expect((await collectIgnoredPaths(dir, ['a.log'])).has('a.log')).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -16,6 +16,20 @@
|
|
|
16
16
|
* Paths must be relative to `dir` and must exist on disk: git resolves
|
|
17
17
|
* directory-only patterns (`build/`) by stat-ing the path.
|
|
18
18
|
*
|
|
19
|
+
* Repository DISCOVERY stops at `dir`'s parent (`GIT_CEILING_DIRECTORIES`), so
|
|
20
|
+
* the rules that answer are the ones of a repository rooted at `dir` — never an
|
|
21
|
+
* enclosing repository's. Without the ceiling git walks up from `dir` and a
|
|
22
|
+
* workspace that is merely a subdirectory of some other repository answers with
|
|
23
|
+
* that repository's rules: measured on `~/JatisMobile/Workspace/projects`
|
|
24
|
+
* (a folder OF repositories, `.git` only in its children) whose parent repo
|
|
25
|
+
* ignores `projects/` — every row, the nested repositories included, came back
|
|
26
|
+
* `ignored: true` and the whole tree rendered faded. The ceiling is the parent
|
|
27
|
+
* rather than `dir` itself because git treats a ceiling equal to the starting
|
|
28
|
+
* directory as no ceiling at all (verified on git 2.56: `dir` still discovered
|
|
29
|
+
* the repository above, `dirname(dir)` exited 128), while a repository rooted
|
|
30
|
+
* AT `dir` is still found with the ceiling there — so a real workspace root
|
|
31
|
+
* keeps its own `.gitignore`, `.git/info/exclude` and global excludes.
|
|
32
|
+
*
|
|
19
33
|
* Answers are memoized per path: the panel asks again every time a folder is
|
|
20
34
|
* re-listed or re-expanded, and each question costs a `git` subprocess
|
|
21
35
|
* (measured 5.6 ms). The TTL is short because a `.gitignore` the user just
|
|
@@ -24,6 +38,8 @@
|
|
|
24
38
|
* nothing at all.
|
|
25
39
|
*/
|
|
26
40
|
|
|
41
|
+
import fs from 'node:fs';
|
|
42
|
+
import path from 'node:path';
|
|
27
43
|
import { GIT_ENV } from '@kabmo-labs/kabmo-git/runner/git-run';
|
|
28
44
|
|
|
29
45
|
const CACHE_TTL_MS = 5_000;
|
|
@@ -41,6 +57,25 @@ function cacheKey(dir: string, rel: string): string {
|
|
|
41
57
|
return `${dir}\0${rel}`;
|
|
42
58
|
}
|
|
43
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Where git's repository discovery must stop: the parent of the browsed root.
|
|
62
|
+
*
|
|
63
|
+
* Resolved first, because git compares the ceiling against the real path of its
|
|
64
|
+
* working directory — a workspace root reached through a symlink would other-
|
|
65
|
+
* wise name a ceiling that is not an ancestor of `dir` and the walk would leak
|
|
66
|
+
* the enclosing repository back in.
|
|
67
|
+
*/
|
|
68
|
+
function discoveryCeiling(dir: string): string {
|
|
69
|
+
let real = dir;
|
|
70
|
+
try {
|
|
71
|
+
real = fs.realpathSync(dir);
|
|
72
|
+
} catch {
|
|
73
|
+
// Vanished between `readdir` and here: the unresolved path is still
|
|
74
|
+
// absolute, and the listing is about to fail anyway.
|
|
75
|
+
}
|
|
76
|
+
return path.dirname(real);
|
|
77
|
+
}
|
|
78
|
+
|
|
44
79
|
export async function collectIgnoredPaths(dir: string, relPaths: string[]): Promise<Set<string>> {
|
|
45
80
|
if (relPaths.length === 0) return new Set();
|
|
46
81
|
|
|
@@ -68,7 +103,9 @@ export async function collectIgnoredPaths(dir: string, relPaths: string[]): Prom
|
|
|
68
103
|
// The same three variables every other git spawn gets — `GIT_ENV` in
|
|
69
104
|
// `lib/fs/git-run.ts` names what each prevents. This call site spawns
|
|
70
105
|
// directly rather than through `runGit`/`runShell`, so it has to opt in.
|
|
71
|
-
|
|
106
|
+
// The ceiling is this module's own rule: only the repository rooted at
|
|
107
|
+
// the browsed root may answer (see the header).
|
|
108
|
+
env: { ...Bun.env, ...GIT_ENV, GIT_CEILING_DIRECTORIES: discoveryCeiling(dir) },
|
|
72
109
|
});
|
|
73
110
|
|
|
74
111
|
// Drain stdout while the listing is written: a directory big enough to
|
|
@@ -133,6 +133,25 @@ describe('single-child chains', () => {
|
|
|
133
133
|
expect(pair.map((entry) => entry.name)).toEqual(['one', 'two']);
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
+
test('a root that is not a repository does not inherit the repository above it', async () => {
|
|
137
|
+
const outer = makeRoot();
|
|
138
|
+
Bun.spawnSync({ cmd: ['git', 'init', '-q'], cwd: outer });
|
|
139
|
+
fs.writeFileSync(path.join(outer, '.gitignore'), 'projects/\n');
|
|
140
|
+
const root = path.join(outer, 'projects');
|
|
141
|
+
mkdirs(root, ['child-one', 'child-two']);
|
|
142
|
+
// A file in each child keeps the single-child collapse from folding them.
|
|
143
|
+
fs.writeFileSync(path.join(root, 'child-one', 'README.md'), 'x\n');
|
|
144
|
+
fs.writeFileSync(path.join(root, 'child-two', 'README.md'), 'x\n');
|
|
145
|
+
Bun.spawnSync({ cmd: ['git', 'init', '-q'], cwd: path.join(root, 'child-one') });
|
|
146
|
+
|
|
147
|
+
const entries = await listDirectoryEntries(root, root);
|
|
148
|
+
|
|
149
|
+
expect(entries.map((entry) => entry.name)).toEqual(['child-one', 'child-two']);
|
|
150
|
+
// One child is a repository, the other is not; neither is ignored. The
|
|
151
|
+
// parent's rules belong to a repository this workspace root is not part of.
|
|
152
|
+
expect(entries.some((entry) => entry.ignored)).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
|
|
136
155
|
test('a git-ignored chain is dimmed from its deepest directory', async () => {
|
|
137
156
|
const root = makeRoot();
|
|
138
157
|
fs.mkdirSync(path.join(root, 'a/b/c'), { recursive: true });
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The ONE resolution of "which workspace does a new chat run in".
|
|
8
|
+
*
|
|
9
|
+
* The prewarm fires for it, the pending chat's `?folderId=` carries it, and the
|
|
10
|
+
* first send spawns in it. When those disagreed the prompt landed in another
|
|
11
|
+
* workspace than the warmed child: measured as the previous right-panel scope
|
|
12
|
+
* surviving a New Chat opened from a session in a different folder.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
|
|
17
|
+
import { newChatFolderId } from '@/shared/lib/workspace/active-project';
|
|
18
|
+
import type { WorkspaceFolderData } from '@/shared/types';
|
|
19
|
+
|
|
20
|
+
const FOLDERS = [
|
|
21
|
+
{ id: 7, name: 'alpha', project_path: '/work/alpha', sessions: [{ id: 'omp-a' }] },
|
|
22
|
+
{ id: 9, name: 'beta', project_path: '/work/beta', sessions: [{ id: 'omp-b' }] },
|
|
23
|
+
{ id: 11, name: 'unbound', project_path: null, sessions: [] },
|
|
24
|
+
] as unknown as WorkspaceFolderData[];
|
|
25
|
+
|
|
26
|
+
describe('newChatFolderId', () => {
|
|
27
|
+
test('the folder owning the source session wins over the right-panel scope', () => {
|
|
28
|
+
expect(newChatFolderId(FOLDERS, 'omp-a', 9)).toBe(7);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('the composer pick is the fallback when the session is under no folder', () => {
|
|
32
|
+
expect(newChatFolderId(FOLDERS, 'omp-unknown', 9)).toBe(9);
|
|
33
|
+
expect(newChatFolderId(FOLDERS, null, 11)).toBe(11);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('a pick the sidebar has not listed yet is kept verbatim', () => {
|
|
37
|
+
// The id is the user's choice; the send resolves it against the list later.
|
|
38
|
+
expect(newChatFolderId(FOLDERS, null, 42)).toBe(42);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('nothing to resolve is null, never a guessed workspace', () => {
|
|
42
|
+
expect(newChatFolderId(FOLDERS, 'omp-unknown', null)).toBeNull();
|
|
43
|
+
expect(newChatFolderId([], null, undefined)).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -46,6 +46,27 @@ export function effectiveRootFor(
|
|
|
46
46
|
return folder.project_path ?? null;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The workspace a NEW chat started from `sessionId` will run in: the folder
|
|
51
|
+
* owning that session, else the composer's pick.
|
|
52
|
+
*
|
|
53
|
+
* Stated once because three places must name the same folder — the prewarm's
|
|
54
|
+
* cwd, the pending chat's `?folderId=`, and its first send's spawn — and they
|
|
55
|
+
* did not: `useNewChatSubmit` wrote a folder only when the URL carried none, so
|
|
56
|
+
* the right panel's scope survived and the prompt spawned in the PREVIOUS
|
|
57
|
+
* workspace while the warmed child waited in the one the chat was started from.
|
|
58
|
+
*
|
|
59
|
+
* The raw pick is returned even when the sidebar's list has not loaded that
|
|
60
|
+
* folder yet: the id is the user's choice, and the send resolves it later.
|
|
61
|
+
*/
|
|
62
|
+
export function newChatFolderId(
|
|
63
|
+
folders: WorkspaceFolderData[],
|
|
64
|
+
sessionId: string | number | null | undefined,
|
|
65
|
+
selectedFolderId: number | string | null | undefined,
|
|
66
|
+
): number | string | null {
|
|
67
|
+
return activeProjectForSession(folders, sessionId).folder?.id ?? selectedFolderId ?? null;
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
/**
|
|
50
71
|
* Resolve the workspace root the composer should scope `@` file mentions to:
|
|
51
72
|
* the active session's bound project first, then the explicitly selected
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pg}from"./index-gmea6fjd.js";import"./index-7ag37ghj.js";import"./index-me7ag6sy.js";export{pg as MergeDiffView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mi}from"./index-scmtzcv1.js";export{mi as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ec}from"./index-er7pj5k6.js";import"./index-scmtzcv1.js";export{Ec as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{np,Ps,tb,nb,rb,ab}from"./index-wvw70pgd.js";export{tb as css,ab as gss,Ps as keywords,rb as less,np as mkCSS,nb as sCSS};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-m1hd7ska.js";import"./index-qj6b15r4.js";import{eb}from"./index-5hqjscys.js";export{eb as diagram};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n,N,se,ys,aA}from"./index-dzp9rwy0.js";var r={left:aA.left,right:aA.right},a="omp:mobile-panel-nav-changed";function s(e,t){return ys(N(r[e],t))}function ug(e,t){if(typeof window>"u")return;window.dispatchEvent(new CustomEvent(a,{detail:{side:e,style:ys(t)}}))}function rp(e){let[t,i]=n(()=>s(e));return se(a,(l)=>{let o=l.detail;if(o?.side!==e)return;i(ys(o.style))}),t}
|
|
2
|
-
export{ug,rp};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{zn,ho,fp,Oi,ai,el,Ku,tl,dg,Vu,gp,Ap,hp,bp,NA,nl,Yu,QA,Ju,Er,RA}from"./index-gmea6fjd.js";import"./index-7ag37ghj.js";export{tl as IndentContext,RA as StreamLanguage,Ju as bracketMatching,nl as codeFolding,hp as foldAll,gp as foldCode,Yu as foldGutter,NA as foldKeymap,Vu as foldService,ai as getIndentUnit,Ku as getIndentation,QA as highlightingFor,dg as indentOnInput,fp as indentService,el as indentString,Oi as indentUnit,ho as language,Er as matchBrackets,zn as syntaxTree,bp as unfoldAll,Ap as unfoldCode};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ri}from"./index-qrpx4sk1.js";export{Ri as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{qg}from"./index-4nvcwtvr.js";import"./index-scmtzcv1.js";export{qg as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_h}from"./index-dzp9rwy0.js";export{_h as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ih}from"./index-dzp9rwy0.js";export{Ih as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{fi}from"./index-ej1va073.js";import"./index-0prwdwyb.js";export{fi as default};
|