@pi-chamber/web 0.9.3 → 0.9.5
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 +16 -1
- package/dist/assets/{DiagramEditor-DuGmiPZ5.js → DiagramEditor-BPDkGHsj.js} +1 -1
- package/dist/assets/DiagramView-D_EfDz2d.js +1 -0
- package/dist/assets/{DiffView-DVd1MLPB.js → DiffView-BmIVvheE.js} +2 -2
- package/dist/assets/FilesView-CJytSUAX.js +6 -0
- package/dist/assets/GitView-BNkzec7G.js +8 -0
- package/dist/assets/{JsonTreeView-Cyy0lEZR.js → JsonTreeView-C1Kzaybf.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-qmKiFVpO.js +12 -0
- package/dist/assets/PatchDiff-D9JesZL1.js +1 -0
- package/dist/assets/{SessionSwitcherContent-dr3g9DR7.js → SessionSwitcherContent-DplV_ApH.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-DdgDKT6K.js +2 -0
- package/dist/assets/SessionUnreadDot-BdSDgvhC.js +1 -0
- package/dist/assets/SettingsView-z8uf0XyM.js +2 -0
- package/dist/assets/SettingsWindow-CPDmgNg2.js +1 -0
- package/dist/assets/ToolOutputDialog-DaF1xcM0.js +8 -0
- package/dist/assets/ToolPartDiffPreview-Di6Uo0Dt.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-iqwryMNU.js → VirtualizedFileDiff-wqcrY0yr.js} +3 -3
- package/dist/assets/collapsible-DBQnXTNm.js +1 -0
- package/dist/assets/computeVirtualFileMetrics-Cr3jh0d6.js +3 -0
- package/dist/assets/contextFileOpenGuard-C_AOTYQD.js +1 -0
- package/dist/assets/gitStatusPredicates-BvPOjeOy.js +134 -0
- package/dist/assets/index-B8Wt2aN3.js +1 -0
- package/dist/assets/index-DIF8b4bh.css +1 -0
- package/dist/assets/index-jrfQYSvP.js +8 -0
- package/dist/assets/isDiffPlainText-L9uvgz2F.js +1 -0
- package/dist/assets/isFilePlainText-C4yk5BOo.js +1 -0
- package/dist/assets/main-C1OSzD-E.js +135 -0
- package/dist/assets/{main-DMyWi0qs.js → main-DCK6lLCo.js} +2 -2
- package/dist/assets/{markdownCore-BD5WkOKU.js → markdownCore-Czb_lINQ.js} +2 -2
- package/dist/assets/{miniChat-CLMNhna4.js → miniChat-CXiSlptL.js} +2 -2
- package/dist/assets/{mobile-rWMDwhtQ.js → mobile-D0HVxiyJ.js} +2 -2
- package/dist/assets/renderElectronMiniChatApp-BcG209a4.js +2 -0
- package/dist/assets/renderMobileApp-B5x_PWlc.js +11 -0
- package/dist/assets/runtimeEndpointReset-CUiPe6dQ.js +53 -0
- package/dist/assets/{runtimeSurface-CySRuLbN.js → runtimeSurface-vilE4xyj.js} +1 -1
- package/dist/assets/{useAppFontEffects-DfuJVB15.js → useAppFontEffects-BP07Vl6M.js} +102 -103
- package/dist/assets/useFilesViewSearch-oxIKk-ea.js +7 -0
- package/dist/assets/usePushVisibilityBeacon-CChMvoTL.js +10 -0
- package/dist/assets/useSwitcherItems-_RSo3F-A.js +1 -0
- package/dist/assets/{vendor-base-ui-vkqQ2P9o.js → vendor-base-ui-CdaWtC7e.js} +1 -1
- package/dist/assets/vendor-beautiful-mermaid-D3YCkKz7.js +111 -0
- package/dist/assets/{vendor-codemirror-commands-DYppkHEk.js → vendor-codemirror-commands-CNlncqrr.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CDdfwzlS.js → vendor-codemirror-language-data-BJrrV83E.js} +2 -2
- package/dist/assets/{vendor-replit-codemirror-vim-CGHHNQxC.js → vendor-replit-codemirror-vim-DaSwPsXt.js} +1 -1
- package/dist/assets/{web-components-C9wXMuCp.js → web-components-B5sMa_kC.js} +3 -3
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/lib/pi/routes.js +13 -3
- package/server/lib/pi/routes.test.js +55 -1
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +17 -6
- package/server/lib/pi/session-daemon/prompt-operations.test.js +193 -0
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +157 -0
- package/server/lib/pi/session-daemon/session-daemon.js +418 -129
- package/server/lib/pi/session-daemon/session-daemon.test.js +186 -0
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +742 -0
- package/server/lib/pi/session-daemon/session-replay.js +98 -0
- package/server/lib/pi/session-daemon/session-replay.test.js +626 -0
- package/server/lib/pi/ui-settings-store.js +16 -10
- package/server/lib/pi/ui-settings-store.test.js +91 -0
- package/server/lib/stt/DOCUMENTATION.md +1 -1
- package/server/lib/stt/local/worker-client.js +11 -3
- package/server/lib/stt/local/worker-client.test.js +255 -0
- package/dist/assets/DiagramView-CV-iReyY.js +0 -1
- package/dist/assets/FilesView-CPnW4I90.js +0 -6
- package/dist/assets/GitView-Dj_7hgX_.js +0 -8
- package/dist/assets/MarkdownRendererImpl-BXN78Wu_.js +0 -12
- package/dist/assets/PatchDiff-C7dA3U29.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-C3zdd82V.js +0 -2
- package/dist/assets/SessionUnreadDot-qeik5qtT.js +0 -1
- package/dist/assets/SettingsView-C57uV1YS.js +0 -2
- package/dist/assets/SettingsWindow-Bbay2W76.js +0 -1
- package/dist/assets/ToolOutputDialog-CRTiN1CH.js +0 -8
- package/dist/assets/ToolPartDiffPreview-CqnNcLPk.js +0 -1
- package/dist/assets/collapsible-szfZ0Syc.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-Bbugxxtp.js +0 -3
- package/dist/assets/contextFileOpenGuard-BC3ie230.js +0 -1
- package/dist/assets/gitStatusPredicates-DbThKVSf.js +0 -134
- package/dist/assets/index-DNoEeZ2U.css +0 -1
- package/dist/assets/index-KIdiBFJs.js +0 -8
- package/dist/assets/index-v6K3L94m.js +0 -1
- package/dist/assets/isDiffPlainText-Dl0RBjPZ.js +0 -1
- package/dist/assets/isFilePlainText-CbrmvrM6.js +0 -1
- package/dist/assets/main-4PkIvzf4.js +0 -135
- package/dist/assets/renderElectronMiniChatApp-BRhGNRJ8.js +0 -2
- package/dist/assets/renderMobileApp-DLy2YoQg.js +0 -11
- package/dist/assets/runtimeEndpointReset-Z9YtcHxZ.js +0 -54
- package/dist/assets/useFilesViewSearch-BZBHrZ90.js +0 -7
- package/dist/assets/usePushVisibilityBeacon-BxTkEajM.js +0 -10
- package/dist/assets/useSwitcherItems-jITqE8PV.js +0 -1
- package/dist/assets/vendor-beautiful-mermaid-DneUawHp.js +0 -119
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte- and count-bounded contiguous replay suffix for daemon events.
|
|
3
|
+
*
|
|
4
|
+
* The daemon broadcasts every event live at full fidelity and retains only a
|
|
5
|
+
* recent contiguous suffix for reconnect replay. Retention is bounded by both
|
|
6
|
+
* event count and serialized wire bytes so cumulative tool-output snapshots
|
|
7
|
+
* cannot grow replay memory without bound. Eviction removes whole oldest
|
|
8
|
+
* events first and never truncates content. A reconnect replays the retained
|
|
9
|
+
* suffix only when its cursor is contiguous with it; otherwise it must take
|
|
10
|
+
* the authoritative `session.snapshot` path.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Preserve the historical 1k-event ceiling and add an encoded-byte ceiling.
|
|
14
|
+
// 8 MiB of encoded wire bytes is a conservative initial protection: it holds
|
|
15
|
+
// thousands of small deltas/lifecycle events (typically well under 1 KiB
|
|
16
|
+
// encoded) or roughly a hundred recent 64 KiB cumulative tool snapshots,
|
|
17
|
+
// while keeping any single reconnect burst below the 16 MiB IPC frame
|
|
18
|
+
// ceiling. Older history remains available through `sessions.open` paging
|
|
19
|
+
// and `sessions.messages`; the snapshot + `sessions.open` hydrate path covers
|
|
20
|
+
// the live edge.
|
|
21
|
+
//
|
|
22
|
+
// The budget counts encoded wire bytes (Buffer.byteLength of the cached line),
|
|
23
|
+
// not heap: UTF-16 strings, JS object overhead, and shared references mean
|
|
24
|
+
// encoded bytes do not equal heap bytes, so no heap claim is made here.
|
|
25
|
+
//
|
|
26
|
+
// Snapshots assign sequence numbers without replay insertion, so numeric gaps
|
|
27
|
+
// from private snapshots are intentional: contiguity means "cursor is at or
|
|
28
|
+
// after oldest-retained - 1", not "every integer is retained". The retained
|
|
29
|
+
// suffix stays in broadcast order.
|
|
30
|
+
export const MAX_REPLAY_EVENTS = 1_024;
|
|
31
|
+
export const MAX_REPLAY_BYTES = 8 * 1024 * 1024;
|
|
32
|
+
|
|
33
|
+
export function createSessionReplayLog({ maxEvents = MAX_REPLAY_EVENTS, maxBytes = MAX_REPLAY_BYTES } = {}) {
|
|
34
|
+
const entries = [];
|
|
35
|
+
let retainedBytes = 0;
|
|
36
|
+
|
|
37
|
+
const append = (sequence, sessionId, line) => {
|
|
38
|
+
const bytes = Buffer.byteLength(line);
|
|
39
|
+
if (bytes > maxBytes) {
|
|
40
|
+
// An oversized single event still broadcasts live at full fidelity but
|
|
41
|
+
// is not retained. Retaining the prior suffix alongside later events
|
|
42
|
+
// would leave a hole at this sequence; clearing preserves the
|
|
43
|
+
// contiguous-suffix invariant so a cursor that missed this event falls
|
|
44
|
+
// back to a snapshot instead of replaying through the gap. A cursor
|
|
45
|
+
// already at/after this sequence remains contiguous with later events.
|
|
46
|
+
entries.length = 0;
|
|
47
|
+
retainedBytes = 0;
|
|
48
|
+
return { retained: false, bytes, oversized: true };
|
|
49
|
+
}
|
|
50
|
+
entries.push({ sequence, sessionId, line, bytes });
|
|
51
|
+
retainedBytes += bytes;
|
|
52
|
+
while (entries.length > maxEvents || retainedBytes > maxBytes) {
|
|
53
|
+
const evicted = entries.shift();
|
|
54
|
+
retainedBytes -= evicted.bytes;
|
|
55
|
+
}
|
|
56
|
+
if (retainedBytes < 0) retainedBytes = 0;
|
|
57
|
+
return { retained: true, bytes };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const canReplay = (fromSequence, latestSequence) => {
|
|
61
|
+
if (!Number.isSafeInteger(fromSequence) || fromSequence < 0) return false;
|
|
62
|
+
if (entries.length === 0) return false;
|
|
63
|
+
const oldest = entries[0].sequence;
|
|
64
|
+
if (!Number.isSafeInteger(oldest)) return false;
|
|
65
|
+
if (fromSequence < oldest - 1) return false;
|
|
66
|
+
// A cursor beyond the latest assigned sequence has no contiguous basis:
|
|
67
|
+
// it must resynchronize from a snapshot rather than wait on an empty replay.
|
|
68
|
+
if (Number.isSafeInteger(latestSequence) && fromSequence > latestSequence) return false;
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function* linesAfter(fromSequence, requestedSessionId) {
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (entry.sequence > fromSequence
|
|
75
|
+
&& (!requestedSessionId || entry.sessionId === requestedSessionId)) {
|
|
76
|
+
yield entry.line;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
get size() {
|
|
83
|
+
return entries.length;
|
|
84
|
+
},
|
|
85
|
+
get retainedBytes() {
|
|
86
|
+
return retainedBytes;
|
|
87
|
+
},
|
|
88
|
+
get oldestSequence() {
|
|
89
|
+
return entries[0]?.sequence;
|
|
90
|
+
},
|
|
91
|
+
get newestSequence() {
|
|
92
|
+
return entries.length > 0 ? entries[entries.length - 1].sequence : undefined;
|
|
93
|
+
},
|
|
94
|
+
append,
|
|
95
|
+
canReplay,
|
|
96
|
+
linesAfter,
|
|
97
|
+
};
|
|
98
|
+
}
|