Goal: Make forked sessions appear in v4 sessions-index with their persisted Fork of <parent title> title and parent session relation.
Architecture: Runtime resume will publish persisted session title into the current session event stream, so ProductProjection.meta becomes the single live title source. Bootstrap live records will preserve parentSessionId and expose it through getSessionIndexMeta, allowing sessions-index summaries to retain fork identity.
Tech Stack: TypeScript, Vitest, ZCode runtime event store, v4 ProductProjection, sessions-index publisher.
docs/.desktop-continuous and web remote web-remote-replayable semantics.pnpm typecheck and pnpm lint before completion.Files:
apps/zcode-cli/packages/core/tests/runtime-persistence.test.tsapps/zcode-cli/packages/bootstrap/tests/v4-cold-resume.test.tsInterfaces:
AgentRuntime.resumeFromStore(), ZCodeProtocolAgentServer v4 cold subscribe, sessions-index subscribe.Produces: failing tests proving persisted fork title must become a runtime event and live sessions-index summaries must include parentSessionId.
[x] Step 1: Write the failing core resume test
Add a test that creates a persisted fork child with title: "Fork of Checkpoint复现目标" and titleSource: "generated", calls resumeFromStore(), and asserts SessionTitleUpdated appears before SessionResumed.
Run:
pnpm --filter @zcode/core exec vitest run tests/runtime-persistence.test.ts -t "emits persisted generated title before SessionResumed"
Expected before implementation: failure because titleEventIndex === -1.
Extend v4-cold-resume.test.ts so the persisted session has parentID. Assert the resumed sessions-index summary includes parentSessionId.
Run:
pnpm --filter @zcode/bootstrap exec vitest run tests/v4-cold-resume.test.ts -t "重启后冷订阅"
Expected before implementation: failure because resumedSummary.parentSessionId is undefined.
Files:
apps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-types.tsapps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-operations.tsapps/zcode-cli/packages/bootstrap/src/zcode-protocol/v4-bridge.tsInterfaces:
params.parentSessionId from create/fork record params and persisted session.parentID from resume.Produces: ZCodeProtocolSessionRecord.parentSessionId?: string and getSessionIndexMeta(...).parentSessionId.
[x] Step 1: Implement record parent propagation
Add parentSessionId?: string to ZCodeProtocolSessionRecord. In createRecord, set it when params.parentSessionId exists. In resumeSession, after loading persisted session, set record.parentSessionId = String(session.parentID) when present. In forkSession, pass parentSessionId: fork.parentSessionId into createRecord.
Change getSessionIndexMeta to return:
return {
createdAt: record.createdAt,
lastActivityAt: record.updatedAt,
...(record.parentSessionId ? { parentSessionId: record.parentSessionId } : {}),
};
Run:
pnpm --filter @zcode/bootstrap exec vitest run tests/v4-cold-resume.test.ts -t "重启后冷订阅"
Expected: the parent relation assertion passes.
Files:
apps/zcode-cli/packages/core/src/runtime/methods/resume.tsInterfaces:
SessionInfo.title and SessionInfo.titleSource.Produces: SessionTitleUpdated in the current runtime event stream, before SessionResumed.
[x] Step 1: Add title sync during resume
After this.sessionPersisted = true and before SessionResumed, if session.title.trim() is non-empty, append:
SessionEventType.SessionTitleUpdated
with previousTitle: "", title: session.title, and source: session.titleSource ?? "generated".
Document that session store title was already correct, but v4 live projection only consumes SessionTitleUpdated; without this event, fork child sessions appear as empty-title fallbacks.
Run:
pnpm --filter @zcode/core exec vitest run tests/runtime-persistence.test.ts -t "emits persisted generated title before SessionResumed"
pnpm --filter @zcode/bootstrap exec vitest run tests/v4-cold-resume.test.ts -t "重启后冷订阅"
Expected: both pass.
Files:
Interfaces:
Produces: verified bug fix and Conventional Commit.
[x] Step 1: Run required checks
Run:
pnpm typecheck
pnpm lint
Expected: exit code 0 for both.
Run:
git diff -- docs/superpowers/specs/2026-07-08-fork-session-title-design.md docs/superpowers/plans/2026-07-08-fork-session-title.md apps/zcode-cli/packages/core/tests/runtime-persistence.test.ts apps/zcode-cli/packages/core/src/runtime/methods/resume.ts apps/zcode-cli/packages/bootstrap/tests/v4-cold-resume.test.ts apps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-types.ts apps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-operations.ts apps/zcode-cli/packages/bootstrap/src/zcode-protocol/v4-bridge.ts
Expected: only scoped fork title / parent meta changes.
Run:
git add docs/superpowers/specs/2026-07-08-fork-session-title-design.md docs/superpowers/plans/2026-07-08-fork-session-title.md apps/zcode-cli/packages/core/tests/runtime-persistence.test.ts apps/zcode-cli/packages/core/src/runtime/methods/resume.ts apps/zcode-cli/packages/bootstrap/tests/v4-cold-resume.test.ts apps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-types.ts apps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-operations.ts apps/zcode-cli/packages/bootstrap/src/zcode-protocol/v4-bridge.ts
git commit -m "fix(v4): preserve fork session titles"