feat(protocol): carry tab, tabRank, createdAt and lastActiveAt on SessionState

List metadata the web console needs to order the chat session list like
pi2.nvim's :PiSessions: the tab handle, its 1-based visual tabline position,
and the creation/last-activity timestamps. Never emitted by the reducer; the
web normalizer and the sessions store preserve them across snapshot and live
event updates.
This commit is contained in:
yuez committed 2026-10-27 19:08:47 +08:00
1 parent c4d0057b0b
commit 92f844d694
3 files changed
+82 -1

No files matched your search

+2 -1
View File
@@ -55,7 +55,7 @@ export const useSessionsStore = create<SessionsStore>((set, get) => ({
}
// Tree metadata is list metadata: a live update (`pi2:session`,
// reducer events, a rename) carries no `parentId`/`visible`/`task`/
// `tab`/`createdAt`/`lastActiveAt` and must not orphan the row.
// `tab`/`tabRank`/`createdAt`/`lastActiveAt` and must not orphan the row.
// Explicit `undefined` is the only "not carried" marker — an explicit
// `parentId: null` means root and wins, which `??` would invert.
const previous = list[index] as SessionState;
@@ -65,6 +65,7 @@ export const useSessionsStore = create<SessionsStore>((set, get) => ({
visible: session.visible !== undefined ? session.visible : previous.visible,
task: session.task !== undefined ? session.task : previous.task,
tab: session.tab !== undefined ? session.tab : previous.tab,
tabRank: session.tabRank !== undefined ? session.tabRank : previous.tabRank,
createdAt: session.createdAt !== undefined ? session.createdAt : previous.createdAt,
lastActiveAt: session.lastActiveAt !== undefined ? session.lastActiveAt : previous.lastActiveAt,
};