@hyperdreamer/pi-webui 1.26.2 → 1.27.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/README.md +1 -1
- package/dist/client/assets/CodeViewer-sU_VxkJa.js +4 -0
- package/dist/client/assets/UnifiedDiffViewer-CPyC9e0o.js +39 -0
- package/dist/client/assets/decorate-85DywWfW.js +2 -0
- package/dist/client/assets/index-RPVQJ86w.js +7874 -0
- package/dist/client/assets/mathjaxEngine-dxhgEVSy.js +19 -0
- package/dist/client/assets/vendor-editor-core-DHpQKRa6.js +12 -0
- package/dist/client/assets/vendor-editor-languages-D-ZESBBF.js +46 -0
- package/dist/client/assets/vendor-terminal-BEifzAF_.js +16 -0
- package/dist/client/index.html +6 -50
- package/dist/server/sessions/piSessionService.js +137 -41
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionArchiveStore.js +48 -16
- package/dist/server/sessions/sessionArchiveStore.js.map +1 -1
- package/dist/server/sessions/sessionCommandService.js +2 -0
- package/dist/server/sessions/sessionCommandService.js.map +1 -1
- package/dist/server/sessions/sessionForkCommit.js +27 -0
- package/dist/server/sessions/sessionForkCommit.js.map +1 -0
- package/dist/shared/apiTypes.d.ts +4 -1
- package/package.json +8 -8
- package/dist/client/assets/CodeViewer-BuDJYy5A.js +0 -4
- package/dist/client/assets/UnifiedDiffViewer-YYb3YzhR.js +0 -39
- package/dist/client/assets/index-a3D73S5c.js +0 -7875
- package/dist/client/assets/mathjaxEngine-KJsBPlWp.js +0 -19
- package/dist/client/assets/vendor-editor-core-vyMPzMNA.js +0 -12
- package/dist/client/assets/vendor-editor-languages-DlEQaRIv.js +0 -46
- package/dist/client/assets/vendor-terminal-D8k4UKM2.js +0 -35
package/dist/client/index.html
CHANGED
|
@@ -8,56 +8,12 @@
|
|
|
8
8
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
9
9
|
<link rel="apple-touch-icon" href="./apple-touch-icon.png" />
|
|
10
10
|
<link rel="manifest" href="./manifest.webmanifest" />
|
|
11
|
-
<style>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
--pi-bg: #0d1117;
|
|
18
|
-
--pi-surface: #161b22;
|
|
19
|
-
--pi-surface-hover: #21262d;
|
|
20
|
-
--pi-terminal-bg: #05070a;
|
|
21
|
-
--pi-terminal-text: #e6edf3;
|
|
22
|
-
--pi-border: #30363d;
|
|
23
|
-
--pi-border-muted: #21262d;
|
|
24
|
-
--pi-hierarchy-border: #5c6b80;
|
|
25
|
-
--pi-text: #e6edf3;
|
|
26
|
-
--pi-text-secondary: #c9d1d9;
|
|
27
|
-
--pi-text-bright: #f0f6fc;
|
|
28
|
-
--pi-muted: #8b949e;
|
|
29
|
-
--pi-dim: #6e7681;
|
|
30
|
-
--pi-accent: #58a6ff;
|
|
31
|
-
--pi-accent-border: #2f81f7;
|
|
32
|
-
--pi-selection-bg: #0d2847;
|
|
33
|
-
--pi-success: #3fb950;
|
|
34
|
-
--pi-success-border: #238636;
|
|
35
|
-
--pi-success-bg: #0f1b12;
|
|
36
|
-
--pi-success-surface: #0f2a16;
|
|
37
|
-
--pi-success-ring: #3fb95055;
|
|
38
|
-
--pi-warning: #d29922;
|
|
39
|
-
--pi-warning-border: #6e5200;
|
|
40
|
-
--pi-warning-surface: #1f1a10;
|
|
41
|
-
--pi-danger: #ff7b72;
|
|
42
|
-
--pi-purple: #d2a8ff;
|
|
43
|
-
--pi-purple-border: #a371f7;
|
|
44
|
-
--pi-purple-surface: #21132f;
|
|
45
|
-
--pi-overlay: #0008;
|
|
46
|
-
--pi-shadow-soft: #0006;
|
|
47
|
-
--pi-shadow: #0008;
|
|
48
|
-
--pi-shadow-strong: #000b;
|
|
49
|
-
--pi-bg-overlay-soft: #0d1117dd;
|
|
50
|
-
--pi-bg-overlay: #0d1117e6;
|
|
51
|
-
--pi-success-bg-overlay: #0f1b12ee;
|
|
52
|
-
--pi-terminal-selection: #264f78;
|
|
53
|
-
}
|
|
54
|
-
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--pi-bg); color: var(--pi-text); }
|
|
55
|
-
body { min-height: 100dvh; }
|
|
56
|
-
</style>
|
|
57
|
-
<script type="module" crossorigin src="./assets/index-a3D73S5c.js"></script>
|
|
58
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-editor-core-vyMPzMNA.js">
|
|
59
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-editor-languages-DlEQaRIv.js">
|
|
60
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-terminal-D8k4UKM2.js">
|
|
11
|
+
<style>:root{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--pi-control-font-size:16px;--pi-control-font-family:system-ui, sans-serif;--pi-control-monospace-font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--pi-bg:#0d1117;--pi-surface:#161b22;--pi-surface-hover:#21262d;--pi-terminal-bg:#05070a;--pi-terminal-text:#e6edf3;--pi-border:#30363d;--pi-border-muted:#21262d;--pi-hierarchy-border:#5c6b80;--pi-text:#e6edf3;--pi-text-secondary:#c9d1d9;--pi-text-bright:#f0f6fc;--pi-muted:#8b949e;--pi-dim:#6e7681;--pi-accent:#58a6ff;--pi-accent-border:#2f81f7;--pi-selection-bg:#0d2847;--pi-success:#3fb950;--pi-success-border:#238636;--pi-success-bg:#0f1b12;--pi-success-surface:#0f2a16;--pi-success-ring:#3fb95055;--pi-warning:#d29922;--pi-warning-border:#6e5200;--pi-warning-surface:#1f1a10;--pi-danger:#ff7b72;--pi-purple:#d2a8ff;--pi-purple-border:#a371f7;--pi-purple-surface:#21132f;--pi-overlay:#0008;--pi-shadow-soft:#0006;--pi-shadow:#0008;--pi-shadow-strong:#000b;--pi-bg-overlay-soft:#0d1117dd;--pi-bg-overlay:#0d1117e6;--pi-success-bg-overlay:#0f1b12ee;--pi-terminal-selection:#264f78}html,body{background:var(--pi-bg);height:100%;color:var(--pi-text);margin:0;overflow:hidden}body{min-height:100dvh}</style>
|
|
12
|
+
<script type="module" crossorigin src="./assets/index-RPVQJ86w.js"></script>
|
|
13
|
+
<link rel="modulepreload" crossorigin href="./assets/decorate-85DywWfW.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="./assets/vendor-editor-core-DHpQKRa6.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="./assets/vendor-editor-languages-D-ZESBBF.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="./assets/vendor-terminal-BEifzAF_.js">
|
|
61
17
|
<link rel="stylesheet" crossorigin href="./assets/vendor-terminal-BrP-ENHg.css">
|
|
62
18
|
</head>
|
|
63
19
|
<body>
|
|
@@ -6,11 +6,12 @@ import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentS
|
|
|
6
6
|
import { projectBrowserMessage } from "../browserMessageProjection.js";
|
|
7
7
|
import { pageMessagesAtSafeBoundary } from "./messagePaging.js";
|
|
8
8
|
import { sessionExtensionEntriesFromBranch, sessionExtensionEntry } from "./extensionEntries.js";
|
|
9
|
+
import { captureDurableForkCommit } from "./sessionForkCommit.js";
|
|
9
10
|
import { exportSessionHistoryHtml } from "./sessionHistoryExport.js";
|
|
10
11
|
import { BUILTIN_COMMANDS } from "./builtinCommands.js";
|
|
11
12
|
import { SessionCommandService, clientSessionFromRuntime, } from "./sessionCommandService.js";
|
|
12
13
|
import { projectSessionTree, } from "./sessionTreeProjection.js";
|
|
13
|
-
import { SessionArchiveStore, } from "./sessionArchiveStore.js";
|
|
14
|
+
import { SessionArchiveStore, SessionArchiveMutationError, } from "./sessionArchiveStore.js";
|
|
14
15
|
import { SessionMetadataStore, SessionMetadataOrderConflictError } from "./sessionMetadataStore.js";
|
|
15
16
|
import { findArchiveCandidateByIdOrPrefix, planSessionArchiveTree, } from "./sessionArchiveTree.js";
|
|
16
17
|
import { deterministicSessionName, fallbackSessionName, generateShortSessionName, } from "./sessionNameGenerator.js";
|
|
@@ -419,6 +420,9 @@ export class PiSessionService {
|
|
|
419
420
|
constructor(events, deps) {
|
|
420
421
|
this.events = events;
|
|
421
422
|
this.active = new Map();
|
|
423
|
+
// SDK starts may remain memory-only until the first message. Keep only
|
|
424
|
+
// published creates visible in authoritative lists, not in-progress runtimes.
|
|
425
|
+
this.transientCreatedSessions = new Map();
|
|
422
426
|
/**
|
|
423
427
|
* Read ordering for extension entries, monotonic for this service lifetime.
|
|
424
428
|
*
|
|
@@ -612,7 +616,7 @@ export class PiSessionService {
|
|
|
612
616
|
},
|
|
613
617
|
hasActiveWork: (session) => this.hasActiveWork(session),
|
|
614
618
|
isTreeNavigationActive: (session) => this.treeNavigations.has(session),
|
|
615
|
-
runSessionReplacement: (session, operation) => this.runTreeExclusiveOperation([{ sessionId: session.sessionId, session }], "Stop current session activity before replacing the session", operation),
|
|
619
|
+
runSessionReplacement: (session, operation) => this.runTreeExclusiveOperation([{ sessionId: session.sessionId, session }], "Stop current session activity before replacing the session", () => this.runSessionFork(session, operation)),
|
|
616
620
|
}, { listSessionNames: (cwd) => this.listSessionNames(cwd) });
|
|
617
621
|
}
|
|
618
622
|
activeCount() {
|
|
@@ -687,7 +691,7 @@ export class PiSessionService {
|
|
|
687
691
|
readyDeleteRecords.push(record);
|
|
688
692
|
}
|
|
689
693
|
await this.ensureArchivedRecordsMoved(readyDeleteRecords);
|
|
690
|
-
const deletedSessionIds = new Set(await this.archiveStoreDeleteArchivedMany(readyDeleteRecords
|
|
694
|
+
const deletedSessionIds = new Set(await this.archiveStoreDeleteArchivedMany(readyDeleteRecords));
|
|
691
695
|
deleteRecords.push(...readyDeleteRecords.filter((record) => deletedSessionIds.has(record.sessionId)));
|
|
692
696
|
await this.forgetUnreadSessions(deleteRecords);
|
|
693
697
|
return summarizeSessionCleanupExecution({
|
|
@@ -723,7 +727,7 @@ export class PiSessionService {
|
|
|
723
727
|
readyDeleteRecords.push(record);
|
|
724
728
|
}
|
|
725
729
|
await this.ensureArchivedRecordsMoved(readyDeleteRecords);
|
|
726
|
-
const deletedSessionIds = new Set(await this.archiveStoreDeleteArchivedMany(readyDeleteRecords
|
|
730
|
+
const deletedSessionIds = new Set(await this.archiveStoreDeleteArchivedMany(readyDeleteRecords));
|
|
727
731
|
const deleteRecords = readyDeleteRecords.filter((record) => deletedSessionIds.has(record.sessionId));
|
|
728
732
|
await this.forgetUnreadSessions(deleteRecords);
|
|
729
733
|
return summarizeForceCleanupExecution({
|
|
@@ -744,6 +748,7 @@ export class PiSessionService {
|
|
|
744
748
|
for (const active of activeSessions)
|
|
745
749
|
this.forgetUnreadActivity(active.runtime.session);
|
|
746
750
|
this.active.clear();
|
|
751
|
+
this.transientCreatedSessions.clear();
|
|
747
752
|
this.pendingSessionOpens.clear();
|
|
748
753
|
this.activities.clear();
|
|
749
754
|
this.compactionPromptQueues.clear();
|
|
@@ -844,6 +849,22 @@ export class PiSessionService {
|
|
|
844
849
|
const unarchivedSessions = sessions
|
|
845
850
|
.filter((session) => !archivedById.has(session.id))
|
|
846
851
|
.map((entry) => mergeSessionMetadata(clientSessionFromListEntry(entry), metadata));
|
|
852
|
+
for (const [id, created] of this.transientCreatedSessions) {
|
|
853
|
+
const active = this.active.get(id);
|
|
854
|
+
if (active === undefined || sessionsById.has(id)) {
|
|
855
|
+
this.transientCreatedSessions.delete(id);
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
if (canonicalizeStoredCwd(created.cwd) !== canonicalizeStoredCwd(cwd) || archivedById.has(id))
|
|
859
|
+
continue;
|
|
860
|
+
const session = active.runtime.session;
|
|
861
|
+
unarchivedSessions.push(mergeSessionMetadata({
|
|
862
|
+
...created,
|
|
863
|
+
persisted: sessionFileExists(session.sessionFile),
|
|
864
|
+
messageCount: session.messages.length,
|
|
865
|
+
...(session.sessionName === undefined ? {} : { name: session.sessionName }),
|
|
866
|
+
}, metadata));
|
|
867
|
+
}
|
|
847
868
|
const reconcilableSessionIds = this.reconcilableSessionIds(cwd, unarchivedSessions.map((session) => session.id), archivedById);
|
|
848
869
|
this.workspaceActivity?.reconcileSessionActivity(cwd, reconcilableSessionIds);
|
|
849
870
|
await this.publishUnreadMutations(this.unreadStore.reconcileCwd(canonicalizeStoredCwd(cwd), reconcilableSessionIds));
|
|
@@ -915,9 +936,13 @@ export class PiSessionService {
|
|
|
915
936
|
: { parentSessionPath: options.parentSession }),
|
|
916
937
|
...(creationSource === undefined ? {} : { creationSource }),
|
|
917
938
|
};
|
|
939
|
+
// The SDK's disk catalog omits starts without a first message. They are
|
|
940
|
+
// nevertheless valid published sessions, including for non-creator clients.
|
|
941
|
+
this.rememberPublishedSession(created);
|
|
918
942
|
// Broadcast so other clients (and the spawning agent's UI) can add the new
|
|
919
943
|
// session to their list without a manual reload.
|
|
920
944
|
this.events.publishGlobal({ type: "session.created", session: created });
|
|
945
|
+
this.publishSessionsChanged([created.cwd]);
|
|
921
946
|
return created;
|
|
922
947
|
}
|
|
923
948
|
/**
|
|
@@ -1796,18 +1821,21 @@ export class PiSessionService {
|
|
|
1796
1821
|
await this.assertWritable(ref);
|
|
1797
1822
|
const active = await this.getActive(ref);
|
|
1798
1823
|
const sourceSession = active.runtime.session;
|
|
1799
|
-
|
|
1824
|
+
return this.runTreeExclusiveOperation([
|
|
1800
1825
|
{
|
|
1801
1826
|
sessionId: sourceSession.sessionId,
|
|
1802
1827
|
session: sourceSession,
|
|
1803
1828
|
runtime: active.runtime,
|
|
1804
1829
|
},
|
|
1805
|
-
], "Stop current session activity before replacing the session", () =>
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1830
|
+
], "Stop current session activity before replacing the session", () => this.runSessionFork(sourceSession, async () => {
|
|
1831
|
+
const result = await active.runtime.fork(entryId);
|
|
1832
|
+
if (result.cancelled)
|
|
1833
|
+
return { cancelled: true };
|
|
1834
|
+
const session = clientSessionFromRuntime(active.runtime);
|
|
1835
|
+
this.rememberPublishedSession(session);
|
|
1836
|
+
this.events.publishGlobal({ type: "session.created", session });
|
|
1837
|
+
return { cancelled: false, session };
|
|
1838
|
+
}));
|
|
1811
1839
|
}
|
|
1812
1840
|
async navigateToTreeEntry(ref, targetId, options, expectedLeafId) {
|
|
1813
1841
|
if (targetId.trim() === "")
|
|
@@ -1926,7 +1954,7 @@ export class PiSessionService {
|
|
|
1926
1954
|
kind: "clear",
|
|
1927
1955
|
reason: "archive",
|
|
1928
1956
|
});
|
|
1929
|
-
await this.
|
|
1957
|
+
await this.archiveStoreArchive(archiveInput);
|
|
1930
1958
|
await this.forgetUnreadSessions([archiveInput]);
|
|
1931
1959
|
});
|
|
1932
1960
|
});
|
|
@@ -2088,7 +2116,7 @@ export class PiSessionService {
|
|
|
2088
2116
|
kind: "clear",
|
|
2089
2117
|
reason: "restore",
|
|
2090
2118
|
});
|
|
2091
|
-
await this.archiveStore.restore(archived.sessionId);
|
|
2119
|
+
await this.publishArchiveMutation(() => this.archiveStore.restore(archived.sessionId), () => [archived.cwd]);
|
|
2092
2120
|
await this.forgetUnreadSessions([archived]);
|
|
2093
2121
|
});
|
|
2094
2122
|
}
|
|
@@ -2104,7 +2132,7 @@ export class PiSessionService {
|
|
|
2104
2132
|
});
|
|
2105
2133
|
if (record.archivePath === undefined)
|
|
2106
2134
|
await this.ensureArchivedRecordMoved(record);
|
|
2107
|
-
await this.
|
|
2135
|
+
await this.archiveStoreDeleteArchivedMany([record]);
|
|
2108
2136
|
await this.forgetUnreadSessions([record]);
|
|
2109
2137
|
}
|
|
2110
2138
|
async deleteArchivedMany(refs) {
|
|
@@ -2161,7 +2189,8 @@ export class PiSessionService {
|
|
|
2161
2189
|
.filter((sessionId) => !moveFailureIds.has(sessionId));
|
|
2162
2190
|
let deletedSessionIds = [];
|
|
2163
2191
|
try {
|
|
2164
|
-
|
|
2192
|
+
const deleteIdSet = new Set(deleteIds);
|
|
2193
|
+
deletedSessionIds = await this.archiveStoreDeleteArchivedMany(readyRecords.filter((record) => deleteIdSet.has(record.sessionId)));
|
|
2165
2194
|
}
|
|
2166
2195
|
catch (error) {
|
|
2167
2196
|
for (const sessionId of deleteIds)
|
|
@@ -2338,26 +2367,60 @@ export class PiSessionService {
|
|
|
2338
2367
|
const entries = await Promise.all(uniqueCwds.map(async (cwd) => [cwd, await this.sessionManager.list(cwd)]));
|
|
2339
2368
|
return new Map(entries);
|
|
2340
2369
|
}
|
|
2370
|
+
rememberPublishedSession(session) {
|
|
2371
|
+
if (session.persisted === false && !this.transientCreatedSessions.has(session.id)) {
|
|
2372
|
+
this.transientCreatedSessions.set(session.id, session);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
publishSessionsChanged(cwds) {
|
|
2376
|
+
for (const cwd of new Set(cwds.map(canonicalizeStoredCwd)))
|
|
2377
|
+
this.events.publishGlobal({ type: "sessions.changed", cwd });
|
|
2378
|
+
}
|
|
2379
|
+
async publishArchiveMutation(operation, changedCwds) {
|
|
2380
|
+
let result;
|
|
2381
|
+
try {
|
|
2382
|
+
result = await operation();
|
|
2383
|
+
}
|
|
2384
|
+
catch (error) {
|
|
2385
|
+
// A rejected operation may already have changed durable history. Closing
|
|
2386
|
+
// a runtime alone is not evidence of a list mutation.
|
|
2387
|
+
if (error instanceof SessionArchiveMutationError)
|
|
2388
|
+
this.publishSessionsChanged(error.changedCwds);
|
|
2389
|
+
throw error;
|
|
2390
|
+
}
|
|
2391
|
+
this.publishSessionsChanged(changedCwds(result));
|
|
2392
|
+
return result;
|
|
2393
|
+
}
|
|
2394
|
+
async archiveStoreArchive(input) {
|
|
2395
|
+
return this.publishArchiveMutation(() => this.archiveStore.archive(input), (record) => [record.cwd]);
|
|
2396
|
+
}
|
|
2341
2397
|
async archiveStoreArchiveMany(inputs) {
|
|
2342
2398
|
if (inputs.length === 0)
|
|
2343
2399
|
return [];
|
|
2344
|
-
|
|
2345
|
-
|
|
2400
|
+
const archiveMany = this.archiveStore.archiveMany?.bind(this.archiveStore);
|
|
2401
|
+
if (archiveMany !== undefined)
|
|
2402
|
+
return this.publishArchiveMutation(() => archiveMany(inputs), (records) => records.map((record) => record.cwd));
|
|
2346
2403
|
const records = [];
|
|
2347
2404
|
for (const input of inputs)
|
|
2348
|
-
records.push(await this.
|
|
2405
|
+
records.push(await this.archiveStoreArchive(input));
|
|
2349
2406
|
return records;
|
|
2350
2407
|
}
|
|
2351
|
-
async archiveStoreDeleteArchivedMany(
|
|
2352
|
-
if (
|
|
2408
|
+
async archiveStoreDeleteArchivedMany(records) {
|
|
2409
|
+
if (records.length === 0)
|
|
2353
2410
|
return [];
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
if (
|
|
2411
|
+
const sessionIds = records.map((record) => record.sessionId);
|
|
2412
|
+
const deleteMany = this.archiveStore.deleteArchivedMany?.bind(this.archiveStore);
|
|
2413
|
+
if (deleteMany !== undefined)
|
|
2414
|
+
return this.publishArchiveMutation(() => deleteMany(sessionIds), (deletedIds) => {
|
|
2415
|
+
const deleted = new Set(deletedIds);
|
|
2416
|
+
return records.filter((record) => deleted.has(record.sessionId)).map((record) => record.cwd);
|
|
2417
|
+
});
|
|
2418
|
+
const deleteOne = this.archiveStore.deleteArchived?.bind(this.archiveStore);
|
|
2419
|
+
if (deleteOne === undefined)
|
|
2357
2420
|
throw new Error("Archive store does not support deletion");
|
|
2358
|
-
for (const
|
|
2359
|
-
await this.
|
|
2360
|
-
return
|
|
2421
|
+
for (const record of records)
|
|
2422
|
+
await this.publishArchiveMutation(() => deleteOne(record.sessionId), () => [record.cwd]);
|
|
2423
|
+
return sessionIds;
|
|
2361
2424
|
}
|
|
2362
2425
|
async moveLegacyArchivedRecordsForDelete(records) {
|
|
2363
2426
|
const legacyRecords = records.filter((record) => record.archivePath === undefined);
|
|
@@ -2433,7 +2496,7 @@ export class PiSessionService {
|
|
|
2433
2496
|
if (session === undefined || this.active.has(record.sessionId))
|
|
2434
2497
|
return record;
|
|
2435
2498
|
try {
|
|
2436
|
-
return await this.
|
|
2499
|
+
return await this.archiveStoreArchive(archiveInputFromListEntry(session));
|
|
2437
2500
|
}
|
|
2438
2501
|
catch {
|
|
2439
2502
|
return record;
|
|
@@ -2549,23 +2612,34 @@ export class PiSessionService {
|
|
|
2549
2612
|
return;
|
|
2550
2613
|
this.forgetUnreadActivity(active.runtime.session);
|
|
2551
2614
|
this.active.delete(sessionId);
|
|
2552
|
-
this.
|
|
2553
|
-
|
|
2554
|
-
this.
|
|
2555
|
-
this.clearCompactionPromptQueue(sessionId);
|
|
2556
|
-
// Disarm subsession notification before teardown so the abort below cannot
|
|
2557
|
-
// emit a "stopped working" event that notifies the parent (e.g. on archive).
|
|
2558
|
-
// The parent/children link is kept so the parent can still see the child.
|
|
2559
|
-
if (this.subsessionLinkForActiveChild(active.runtime.session) !== undefined)
|
|
2560
|
-
this.subsessionNotifyArmed.delete(sessionId);
|
|
2561
|
-
clearSessionQueue(active.runtime.session);
|
|
2562
|
-
active.unsubscribe();
|
|
2563
|
-
active.runtime.setRebindSession(undefined);
|
|
2615
|
+
const transient = this.transientCreatedSessions.get(sessionId);
|
|
2616
|
+
const removedMemoryOnly = transient !== undefined && !sessionFileExists(active.runtime.session.sessionFile);
|
|
2617
|
+
this.transientCreatedSessions.delete(sessionId);
|
|
2564
2618
|
try {
|
|
2565
|
-
|
|
2619
|
+
this.activities.delete(sessionId);
|
|
2620
|
+
this.workspaceActivity?.removeSession(sessionId, active.runtime.session.sessionManager.getCwd());
|
|
2621
|
+
this.clearAuthLossWarningsForSession(sessionId);
|
|
2622
|
+
this.clearCompactionPromptQueue(sessionId);
|
|
2623
|
+
// Disarm subsession notification before teardown so the abort below cannot
|
|
2624
|
+
// emit a "stopped working" event that notifies the parent (e.g. on archive).
|
|
2625
|
+
// The parent/children link is kept so the parent can still see the child.
|
|
2626
|
+
if (this.subsessionLinkForActiveChild(active.runtime.session) !== undefined)
|
|
2627
|
+
this.subsessionNotifyArmed.delete(sessionId);
|
|
2628
|
+
clearSessionQueue(active.runtime.session);
|
|
2629
|
+
active.unsubscribe();
|
|
2630
|
+
active.runtime.setRebindSession(undefined);
|
|
2631
|
+
try {
|
|
2632
|
+
await this.abortSessionOperations(active.runtime.session);
|
|
2633
|
+
}
|
|
2634
|
+
finally {
|
|
2635
|
+
await active.runtime.dispose();
|
|
2636
|
+
}
|
|
2566
2637
|
}
|
|
2567
2638
|
finally {
|
|
2568
|
-
|
|
2639
|
+
// Removing published memory-only membership changes the catalog even if
|
|
2640
|
+
// teardown fails. Notify after teardown so any final SDK writes are visible.
|
|
2641
|
+
if (removedMemoryOnly)
|
|
2642
|
+
this.publishSessionsChanged([transient.cwd]);
|
|
2569
2643
|
}
|
|
2570
2644
|
}
|
|
2571
2645
|
async abortSessionOperations(session) {
|
|
@@ -3305,6 +3379,28 @@ export class PiSessionService {
|
|
|
3305
3379
|
this.isTreeExclusiveOperationActive(session) ||
|
|
3306
3380
|
sessionHasActiveWork(session, this.compactionQueuedMessages(session.sessionId).length));
|
|
3307
3381
|
}
|
|
3382
|
+
async runSessionFork(source, operation) {
|
|
3383
|
+
// Called inside the tree-exclusive lock. A rejected SDK fork may already
|
|
3384
|
+
// have committed history, even if teardown prevented createRuntime running.
|
|
3385
|
+
const hasDurableCommit = await captureDurableForkCommit(source.sessionManager);
|
|
3386
|
+
const active = this.active.get(source.sessionId);
|
|
3387
|
+
let result;
|
|
3388
|
+
try {
|
|
3389
|
+
result = await operation();
|
|
3390
|
+
// Forking before the first user message succeeds with a new live runtime
|
|
3391
|
+
// but no JSONL yet. Commands return that identity too, so it must join the
|
|
3392
|
+
// same authoritative live catalog as starts before broadcasting invalidation.
|
|
3393
|
+
if (!result.cancelled && active !== undefined) {
|
|
3394
|
+
this.rememberPublishedSession(clientSessionFromRuntime(active.runtime));
|
|
3395
|
+
}
|
|
3396
|
+
return result;
|
|
3397
|
+
}
|
|
3398
|
+
finally {
|
|
3399
|
+
if (result?.cancelled === false ||
|
|
3400
|
+
(result === undefined && await hasDurableCommit()))
|
|
3401
|
+
this.publishSessionsChanged([source.sessionManager.getCwd()]);
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3308
3404
|
async runTreeExclusiveOperation(targets, activeError, operation) {
|
|
3309
3405
|
const sessionIds = new Set();
|
|
3310
3406
|
const runtimes = new Set();
|