Skip to content

fix(pi): keep archived sessions visible - #1297

Merged
tiann merged 1 commit into
tiann:mainfrom
KorenKrita:agent/fix-pi-archived-session-visibility
Aug 2, 2026
Merged

fix(pi): keep archived sessions visible#1297
tiann merged 1 commit into
tiann:mainfrom
KorenKrita:agent/fix-pi-archived-session-visibility

Conversation

@KorenKrita

Copy link
Copy Markdown
Contributor

Fixes #1296.

Summary

  • keep archived, untitled Pi sessions visible in the Web sidebar;
  • project the native session ID that matches the session's exact flavor, including piSessionId;
  • preserve piSessionId across sparse archive metadata replacements;
  • add Shared, Hub, and Web regressions for the full failure chain.

User-visible behavior

Before this change, a Pi session could be visible while active and disappear immediately after archival. The Hub row, messages, and piSessionId were still present, but the sidebar no longer exposed the session or its Reopen action.

After this change, an archived Pi session with a valid native ID remains in the sidebar with the same inactive presentation and actions used by archived Codex and Claude sessions.

Root cause

The failure required two existing behaviors to interact:

  1. toSessionSummary() flattened agent-specific native IDs into metadata.agentSessionId, but omitted piSessionId.
  2. PR fix(web): hide sidebar fake sessions for Cursor resume/archive #836 intentionally hides inactive rows that have no flattened agent ID and no name or summary, because those rows are normally abandoned empty stubs.

The resulting chain was:

Hub row contains piSessionId
  -> SessionSummary drops piSessionId
  -> Web receives agentSessionId = undefined
  -> archive makes the row inactive
  -> no name/summary means "empty stub"
  -> sidebar filters the real Pi session

Codex and Claude did not reproduce the issue because their native IDs were already included in the summary projection.

There was also a second Pi-specific gap in SIMPLE_RESUME_TOKENS. The store protects native resume identifiers when a stale or null CLI metadata cache produces a sparse archive payload, but piSessionId was absent from that carry-forward list. In that failure mode the token could be erased, turning a visibility bug into an actual Reopen failure.

Changes

Flavor-aware summary identity

shared/src/sessionSummary.ts now uses an exhaustive AgentFlavor -> Metadata field mapping and the same exact isKnownFlavor semantics used by the resume paths.

For known flavors, only the matching native ID is accepted. This avoids representing a Pi or Cursor session with a stale ID left by another agent integration.

The legacy fixed-order fallback remains limited to missing or unknown flavors. It deliberately does not infer Pi identity in that branch because Hub resume routing treats missing/unknown flavor as Claude.

Pi resume-token preservation

piSessionId is now included in SIMPLE_RESUME_TOKENS, retaining the existing semantics:

  • omitted field: carry the prior token forward;
  • explicit null: clear the token;
  • explicit new value: replace the token.

Regression coverage

  • canonical flavor: 'pi' projects piSessionId into summary agentSessionId;
  • known flavors prefer their own native ID over stale cross-agent metadata;
  • missing, unknown, and malformed flavors do not infer Pi identity;
  • an archived, untitled Pi summary survives prepareSidebarSessions();
  • sparse archive metadata replacement preserves piSessionId.

Related history

Validation

  • mise exec -- bun typecheck
  • mise exec -- bun test shared/src/sessionSummary.test.ts hub/src/store/sessions.test.ts
  • mise exec -- bun run --cwd web test src/components/SessionList.test.ts
  • mise exec -- bun run test
  • git diff --check

Full-suite result before the final rebase:

CLI:    167 files / 1654 tests passed
Hub:    693 passed / 3 existing real-agent integration tests skipped
Web:    204 files / 1765 tests passed
Shared: 158 passed

After rebasing onto the latest main, all affected tests and the full CLI/Web/Hub typecheck passed again.

AI disclosure

Root-cause analysis, implementation, tests, and PR drafting were assisted by OpenAI Codex (GPT-5.6).

@KorenKrita
KorenKrita marked this pull request as ready for review August 2, 2026 01:56

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No findings.

Questions

  • None.

Summary

  • Review mode: initial
  • No issues identified in the added or modified lines. Residual risk is limited to runtime integration behavior not exercised by this static pass; the changed paths have targeted Shared, Hub, and Web regression coverage.

Testing

  • Not run (automation). GitHub test check passed.

HAPI Bot

@tiann
tiann merged commit 1ca7af4 into tiann:main Aug 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Archived Pi sessions disappear from the Web sidebar

2 participants