@pi-chamber/web 0.9.7 → 0.9.8-rc.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/assets/{DiagramView-BvrCkm_z.js → DiagramView-BMBrrFLy.js} +1 -1
- package/dist/assets/{DiffView-DMvRLRN1.js → DiffView-yVBxHkBI.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-DGa9u43J.js → FileSaveConflictDialog-D0siEm8l.js} +1 -1
- package/dist/assets/{FilesView-CNHu4RnC.js → FilesView-CkcKBKkT.js} +4 -4
- package/dist/assets/{GitView-Cbepz-bR.js → GitView-CfuhQOfc.js} +3 -3
- package/dist/assets/{JsonTreeView-C2X5oXQm.js → JsonTreeView-6kRdE1BO.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BanSCkPy.js → MarkdownRendererImpl-CRWbN_Jc.js} +1 -1
- package/dist/assets/{PatchDiff-i_9BIlgo.js → PatchDiff-B0ssv8Aw.js} +1 -1
- package/dist/assets/{SessionSwitcherContent-DxS_rFuS.js → SessionSwitcherContent-NmfI4B0Z.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-AVghToww.js → SessionSwitcherDropdown-DmE2hYTN.js} +2 -2
- package/dist/assets/SessionUnreadDot-LDTswryg.js +1 -0
- package/dist/assets/SettingsView-D0iw6y_H.js +2 -0
- package/dist/assets/{SettingsWindow-BfPUzBbq.js → SettingsWindow-BT2TzUBK.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CJ87b80H.js → ToolOutputDialog-Bnl51bva.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-bF486Lz1.js → ToolPartDiffPreview-DgPtLS_h.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-CFpvcZ1g.js → VirtualizedFileDiff-D3zBpYIS.js} +4 -4
- package/dist/assets/collapsible-_urywMu5.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-CsAu9rOt.js → computeVirtualFileMetrics-y2AJzpKw.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-rILslsBJ.js → contextFileOpenGuard-DYUFkrPT.js} +1 -1
- package/dist/assets/{gitStatusPredicates-D_31YElh.js → gitStatusPredicates-CbFfOlbV.js} +1 -1
- package/dist/assets/index-CrqlVJXp.js +8 -0
- package/dist/assets/{index-CXLVW_GG.js → index-DwJJarzh.js} +1 -1
- package/dist/assets/{isDiffPlainText-BX609Lau.js → isDiffPlainText-kXPOivsq.js} +1 -1
- package/dist/assets/{isFilePlainText-FgBWqu9b.js → isFilePlainText-BBIPqnLo.js} +1 -1
- package/dist/assets/{main-tv2uysSs.js → main-BshSYpnV.js} +3 -3
- package/dist/assets/{main-C_pL2r_k.js → main-RrPyfmCA.js} +2 -2
- package/dist/assets/{markdownCore-D3Ibaffd.js → markdownCore-BxXmpZtB.js} +1 -1
- package/dist/assets/{miniChat-B0xQlBzZ.js → miniChat-DRNgmC-q.js} +2 -2
- package/dist/assets/{mobile-BmSlVuhn.js → mobile-CdmgVKW4.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-C4xZzAnn.js → renderElectronMiniChatApp-B80Jqq8b.js} +2 -2
- package/dist/assets/{renderMobileApp-Bi8wTGd5.js → renderMobileApp-CLcBvRiy.js} +3 -3
- package/dist/assets/{runtimeEndpointReset-B6_gFvBD.js → runtimeEndpointReset-DHHCemOu.js} +6 -6
- package/dist/assets/{runtimeSurface-egSD9pqj.js → runtimeSurface-C9kx2zfD.js} +1 -1
- package/dist/assets/{useAppFontEffects-C9QQrBIx.js → useAppFontEffects-Dp6vM-Zr.js} +83 -83
- package/dist/assets/{useFilesViewSearch-BTZutbn-.js → useFilesViewSearch-Bc8PTYrg.js} +2 -2
- package/dist/assets/{usePushVisibilityBeacon-BZcHxSo-.js → usePushVisibilityBeacon-DMcKyNtE.js} +1 -1
- package/dist/assets/{useSwitcherItems-Dw5tHQh8.js → useSwitcherItems-DEvsORZ_.js} +1 -1
- package/dist/assets/{vendor-base-ui-CdaWtC7e.js → vendor-base-ui-C60wdVnS.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-0f_rLdj_.js → vendor-codemirror-language-data-DLimsiRH.js} +2 -2
- package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-Bkw82kL9.js} +1 -1
- package/dist/assets/{vendor-floating-ui-react-dom-BZOGXAGe.js → vendor-floating-ui-react-dom-KLmnYDaG.js} +1 -1
- package/dist/assets/{web-components-CYngz9Ml.js → web-components-05Oa3k7a.js} +3 -3
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/pi/routes.js +12 -6
- package/server/lib/pi/routes.test.js +44 -16
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +5 -1
- package/server/lib/pi/session-daemon/send-operation-dedup.test.js +15 -5
- package/server/lib/pi/session-daemon/send-operation-registry.js +26 -23
- package/server/lib/pi/session-daemon/send-operation-registry.test.js +26 -20
- package/server/lib/pi/session-daemon/session-daemon.js +24 -12
- package/server/lib/pi/ui-settings-store.js +6 -0
- package/server/lib/pi/ui-settings-store.test.js +16 -0
- package/dist/assets/SessionUnreadDot-CDRZswx-.js +0 -1
- package/dist/assets/SettingsView-hyAGp836.js +0 -2
- package/dist/assets/collapsible-DesjbW8a.js +0 -1
- package/dist/assets/index-BZpvAhrX.js +0 -8
|
@@ -38,6 +38,7 @@ import { createSessionReplayLog } from './session-replay.js';
|
|
|
38
38
|
import {
|
|
39
39
|
createSendOperationRegistry,
|
|
40
40
|
isValidSendOperationId,
|
|
41
|
+
isValidStreamEpoch,
|
|
41
42
|
stableFingerprint,
|
|
42
43
|
} from './send-operation-registry.js';
|
|
43
44
|
import { resolveEffectiveRetryLimitFromDataDir as resolveEffectiveRetryLimit } from './session-retry-limits.js';
|
|
@@ -322,14 +323,11 @@ export function createSessionDaemon({
|
|
|
322
323
|
const activeSessionInputs = new Map();
|
|
323
324
|
// Send-intent deduplication (finding #3): one stable operation id per send
|
|
324
325
|
// intent; the registry is the authoritative execution boundary before Pi.
|
|
325
|
-
// Identity is `kind + sessionId + operationId
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
// per-session config/acceptance lock; every claim settles so pending
|
|
331
|
-
// duplicates never hang.
|
|
332
|
-
const sendOperations = createSendOperationRegistry({ ttlMs: sendOperationTtlMs });
|
|
326
|
+
// Identity is `kind + sessionId + operationId + streamEpoch`. The epoch is
|
|
327
|
+
// checked before activation, so an intent captured before a daemon restart
|
|
328
|
+
// cannot execute in the replacement process. Retention remains bounded and
|
|
329
|
+
// in-memory; every claim settles so pending duplicates never hang.
|
|
330
|
+
const sendOperations = createSendOperationRegistry({ streamEpoch, ttlMs: sendOperationTtlMs });
|
|
333
331
|
const pendingResourceReloads = new Set();
|
|
334
332
|
const resourceReloadsByRuntime = new Map();
|
|
335
333
|
let resourceReloadQueue = Promise.resolve();
|
|
@@ -2760,7 +2758,15 @@ export function createSessionDaemon({
|
|
|
2760
2758
|
}
|
|
2761
2759
|
if (payload.thinking !== undefined) validateThinking(payload.thinking);
|
|
2762
2760
|
const kind = delivery ?? 'prompt';
|
|
2763
|
-
|
|
2761
|
+
if (payload.operationId !== undefined || payload.streamEpoch !== undefined) {
|
|
2762
|
+
if (!isValidStreamEpoch(payload.streamEpoch)) {
|
|
2763
|
+
throw new SessionDaemonProtocolError('INVALID_ARGUMENT', 'The send stream epoch is invalid.');
|
|
2764
|
+
}
|
|
2765
|
+
if (payload.streamEpoch !== streamEpoch) {
|
|
2766
|
+
throw new SessionDaemonProtocolError('STALE_STREAM_EPOCH', 'The send belongs to a retired daemon stream epoch.');
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
// Claim the stable operation id at the authoritative
|
|
2764
2770
|
// execution boundary — before Pi activation and before any attachment
|
|
2765
2771
|
// side effect. A duplicate returns the original receipt; a payload
|
|
2766
2772
|
// mismatch (same kind + session + id, different text/model/thinking/
|
|
@@ -2777,8 +2783,12 @@ export function createSessionDaemon({
|
|
|
2777
2783
|
kind,
|
|
2778
2784
|
sessionId: payload.sessionId,
|
|
2779
2785
|
operationId: payload.operationId,
|
|
2786
|
+
streamEpoch: payload.streamEpoch,
|
|
2780
2787
|
fingerprint: stableFingerprint(sendOperationFingerprint({ kind, payload })),
|
|
2781
2788
|
});
|
|
2789
|
+
if (claimed.outcome === 'stale') {
|
|
2790
|
+
throw new SessionDaemonProtocolError('STALE_STREAM_EPOCH', 'The send belongs to a retired daemon stream epoch.');
|
|
2791
|
+
}
|
|
2782
2792
|
if (claimed.outcome === 'mismatch') {
|
|
2783
2793
|
throw new SessionDaemonProtocolError('OPERATION_PAYLOAD_MISMATCH', 'This operation id was already used with a different payload.');
|
|
2784
2794
|
}
|
|
@@ -3782,7 +3792,7 @@ export function createSessionDaemon({
|
|
|
3782
3792
|
}
|
|
3783
3793
|
case 'sessions.sendReceipt': {
|
|
3784
3794
|
// Exact read-only receipt lookup for an uncertain send. Requires the
|
|
3785
|
-
// full `kind + sessionId + operationId` identity; never invokes Pi,
|
|
3795
|
+
// full `kind + sessionId + operationId + streamEpoch` identity; never invokes Pi,
|
|
3786
3796
|
// never mutates the registry except bounded expiry eviction inside
|
|
3787
3797
|
// `query()`. Returns `accepted` (retained receipt), `pending`
|
|
3788
3798
|
// (still-accepting claim), `expired` (seen but retention gone —
|
|
@@ -3793,12 +3803,14 @@ export function createSessionDaemon({
|
|
|
3793
3803
|
const kind = payload.kind;
|
|
3794
3804
|
const sessionId = payload.sessionId;
|
|
3795
3805
|
const operationId = payload.operationId;
|
|
3806
|
+
const requestedEpoch = payload.streamEpoch;
|
|
3796
3807
|
if ((kind !== 'prompt' && kind !== 'steer' && kind !== 'followUp')
|
|
3797
3808
|
|| typeof sessionId !== 'string' || sessionId.length === 0
|
|
3798
|
-
|| !isValidSendOperationId(operationId)
|
|
3809
|
+
|| !isValidSendOperationId(operationId)
|
|
3810
|
+
|| (requestedEpoch !== undefined && !isValidStreamEpoch(requestedEpoch))) {
|
|
3799
3811
|
throw new SessionDaemonProtocolError('INVALID_ARGUMENT', 'The send receipt lookup is invalid.');
|
|
3800
3812
|
}
|
|
3801
|
-
const lookup = sendOperations.query({ kind, sessionId, operationId });
|
|
3813
|
+
const lookup = sendOperations.query({ kind, sessionId, operationId, streamEpoch: requestedEpoch });
|
|
3802
3814
|
if (lookup.status === 'accepted') {
|
|
3803
3815
|
writeFrame(socket, {
|
|
3804
3816
|
protocolVersion: PROTOCOL_VERSION,
|
|
@@ -55,6 +55,7 @@ const LOCAL_FIELDS = new Set([
|
|
|
55
55
|
'terminalShell', 'terminalLoginShells', 'desktopLanAccessEnabled',
|
|
56
56
|
'desktopKeepAwakeEnabled', 'desktopProcessPerformanceRecordingEnabled',
|
|
57
57
|
'desktopMinimizeToTrayEnabled', 'desktopCloseToTrayEnabled', 'desktopMacMenuBarEnabled',
|
|
58
|
+
'desktopUpdateChannel',
|
|
58
59
|
'desktopWindowState', 'desktopLocalPort', 'desktopInstallId', 'desktopHosts',
|
|
59
60
|
'desktopDefaultHostId', 'desktopInitialHostChoiceCompleted',
|
|
60
61
|
'pwaAppName', 'pwaOrientation', 'mobileKeyboardMode',
|
|
@@ -157,6 +158,11 @@ export const createPiUiSettingsStore = ({
|
|
|
157
158
|
|
|
158
159
|
const write = async (changes) => {
|
|
159
160
|
validateRecord(changes);
|
|
161
|
+
if (Object.hasOwn(changes, 'desktopUpdateChannel')
|
|
162
|
+
&& changes.desktopUpdateChannel !== 'stable'
|
|
163
|
+
&& changes.desktopUpdateChannel !== 'rc') {
|
|
164
|
+
throw new Error('UI_SETTINGS_INVALID');
|
|
165
|
+
}
|
|
160
166
|
return runMutation(async () => {
|
|
161
167
|
const current = await readLocked();
|
|
162
168
|
const portableChanges = selectFields(changes, PORTABLE_FIELDS);
|
|
@@ -85,6 +85,22 @@ describe('Pi UI settings store', () => {
|
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
+
it('persists the desktop update subscription locally and rejects unknown channels', async () => {
|
|
89
|
+
const { file, runtimeFile, store } = await makeStore();
|
|
90
|
+
|
|
91
|
+
await expect(store.write({ themeId: 'dark', desktopUpdateChannel: 'rc' })).resolves.toMatchObject({
|
|
92
|
+
themeId: 'dark',
|
|
93
|
+
desktopUpdateChannel: 'rc',
|
|
94
|
+
});
|
|
95
|
+
await expect(readJson(file)).resolves.toEqual({
|
|
96
|
+
__pichamberSettingsScope: 'portable-v1',
|
|
97
|
+
themeId: 'dark',
|
|
98
|
+
});
|
|
99
|
+
await expect(readJson(runtimeFile)).resolves.toEqual({ desktopUpdateChannel: 'rc' });
|
|
100
|
+
await expect(store.write({ desktopUpdateChannel: 'beta' })).rejects.toThrow('UI_SETTINGS_INVALID');
|
|
101
|
+
await expect(store.read()).resolves.toMatchObject({ desktopUpdateChannel: 'rc' });
|
|
102
|
+
});
|
|
103
|
+
|
|
88
104
|
it('rejects prototype-polluting keys', async () => {
|
|
89
105
|
const { store } = await makeStore();
|
|
90
106
|
const changes = JSON.parse('{"__proto__":{"polluted":true}}');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as m,n as h}from"./index-BZpvAhrX.js";import{j as g}from"./vendor-react-B5Z1Mdn3.js";import{cN as y,cO as D,cP as w}from"./useAppFontEffects-C9QQrBIx.js";const S="Awaiting first prompt";function F(e,t="Untitled Session"){const o=e?.title?.trim();return o||(e?.messageCount===0?S:t)}const I=(e,t,o)=>{const a=`${o}:`,r=new Set([...t].filter(s=>s.startsWith(a)));return e.size===r.size&&[...r].every(s=>e.has(s))?e:r},R=(e,t)=>{const o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o},b=e=>{const t=new Date(e),o=new Date,a=(n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate(),r=new Date(o);return r.setDate(o.getDate()-1),a(t,o)?"Today":a(t,r)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},T=e=>{const t=new Date,o=new Date(e);if(((r,s)=>r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()&&r.getDate()===s.getDate())(o,t)){const r=Date.now()-e;return r<6e4?"Just now":r<36e5?`${Math.floor(r/6e4)}min ago`:`${Math.floor(r/36e5)}h ago`}return b(e)},k=e=>{const t=Math.max(0,Date.now()-e),o=6e4,a=60*o,r=24*a,s=7*r,n=30*r,i=365*r;return t<a?`${Math.max(1,Math.floor(t/o))}m`:t<r?`${Math.floor(t/a)}h`:t<s?`${Math.floor(t/r)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<i?`${Math.floor(t/n)}mo`:`${Math.floor(t/i)}y ago`},d=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),E=(e,t)=>e?d(e)!==d(t):!1,P=e=>{const t=new Map;return e.forEach(o=>{t.set(o.id,o)}),Array.from(t.values())},z=e=>`__archived__:${e}`,U=(e,t)=>{const o=m(e.directory??null),a=m(e.project?.worktree??null),r=o??a;if(!r)return"unassigned";if(t&&r===t)return"project root";const n=(t&&r.startsWith(`${t}/`)?r.slice(t.length+1):r).split("/").filter(Boolean);return n[n.length-1]??"unassigned"},j=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase()),B="0.75rem",M="size-4 shrink-0",p="min-w-0 truncate typography-ui-label font-normal",x=M,v=p,$="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Y=$,K=e=>e?x:M,O=e=>e?v:p,u=1e3,c=60*u,l=60*c,C=e=>{const t=Math.max(0,e);return t<c?`${Math.floor(t/u)}s`:t<l?`${Math.floor(t/c)}m ${Math.floor(t%c/u)}s`:`${Math.floor(t/l)}h ${Math.floor(t%l/c)}m`},A=1e3,W=({sessionId:e,running:t,className:o})=>{const a=y(e),r=D(e),s=w(t,A),n=t?Math.max(0,s-(a??s)):r;if(n===void 0)return null;const i=C(n),f=t?`Active for ${i}`:`Last turn took ${i}`;return g.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",o),"aria-label":f,title:f,children:i})};function G({label:e,className:t}){return g.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{G as S,W as a,T as b,z as c,P as d,p as e,k as f,F as g,K as h,O as i,Y as j,$ as k,E as l,B as m,j as n,I as o,U as r,M as s,R as t};
|