Skip to content

feat(import): show imported sessions in entire session list#1699

Merged
computermode merged 12 commits into
mainfrom
feat/imported-sessions-in-session-list
Jul 10, 2026
Merged

feat(import): show imported sessions in entire session list#1699
computermode merged 12 commits into
mainfrom
feat/imported-sessions-in-session-list

Conversation

@computermode

@computermode computermode commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/813

What

Makes sessions brought in by entire import appear in entire session list. Today import writes only read-only, commit-less checkpoints, so checkpoint list shows imported work but session list returns "No sessions." — the gap behind #1697 (and the read-only-import request in #1336).

Now each imported session also gets a local session.State, tagged Kind: imported, and is clearly marked read-only wherever it surfaces.

How

  • entire import writes one session.State per imported session (agentimport.writeSessionState): reuses the transcript SessionID, aggregates real transcript timestamps + tokens, sets Phase: ended.
  • Staleness: State.IsStale() exempts KindImported (historical timestamps would otherwise auto-purge imports on the first session list).
  • Lifecycle purge paths gated on KindImported so a commit-less, shadow-branch-less imported state isn't deleted: listAllSessionStates orphan cleanup and ListOrphanedSessionStates (entire clean).

Read-only UX (so unsupported writes don't look like breakage)

Imported sessions are read-only — not resumable or rewindable. This is now surfaced instead of failing silently or cryptically:

  • session list card shows imported (read-only)
  • session info text adds a read-only note; session info --json and session list --json expose kind + read_only
  • resume picker excludes imported sessions and, when the only sessions present are imports, explains why
  • rewind already refuses imported checkpoints with a clear message (refuseIfImportedCheckpoint)

Forward-compat

Imported checkpoints are still local-only and not yet linked to commits or shown in the web UI. This PR is deliberately constrained so that a future change which links imports to commit SHAs (and pushes them for web-UI visibility) is purely additive:

  • reuse the transcript SessionID as the join key
  • gate capability on Kind, never on commit-presence
  • never set BaseCommit (no HEAD pin, unlike entire attach)
  • preserve real transcript timestamps (staleness handled via the Kind exemption, not faked recency)
  • untouched: the entire/imports/v1 ref and push semantics — this PR writes only local .git/entire-sessions/*.json

Out of scope (intentionally)

Pushing imports / web-UI visibility, commit-SHA capture from transcripts (no importer parses one today), entire attach behavior, making imports rewindable.

Tests

  • IsStale imported exemption (+ control)
  • writeSessionState: field mapping, no-clobber of a live session, 30-day-old import survives strategy.ListSessionStates
  • Run wiring: writes state on real import, skips on --dry-run
  • lifecycle guards: listAllSessionStates keeps imported; ListOrphanedSessionStates skips imported
  • read-only UX: list card, info text + JSON, resume picker exclusion + count helper

Full suite green (mise run lint + mise run test).

Refs #1697, #1336

🤖 Generated with Claude Code

computermode and others added 7 commits July 9, 2026 13:36
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX49J5WC1AG5KBYG7D9SZ8G6
Kind-gated (KindImported), never sets BaseCommit (no HEAD pin), uses real
transcript timestamps — keeps a future commit-SHA link additive.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX49MZY55PJYNTEPSMG6VF9G
…cleanup

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX49T0BNT7NAW9TJXFE7DSYB
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX49VPTETHKDW2GD7PGCMMKY
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX49WZ0AZJ8SXK6ES8YVQ7XZ
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4A7FWMRWXSXX2D10WTVEYH
…y-run)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4AC6WT3Q13C5AZW284CR85
Copilot AI review requested due to automatic review settings July 9, 2026 20:52
@computermode computermode changed the title feat(import): show imported sessions in entire session list (Track A) feat(import): show imported sessions in entire session list Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes sessions imported via entire import visible in entire session list by writing a local session.State for each imported transcript and ensuring imported states aren’t removed by existing staleness/orphan-cleanup paths.

Changes:

  • Write session.State entries for imported transcripts (Kind: imported, Phase: ended) so they appear in session listing.
  • Exempt imported sessions from staleness deletion and from orphan cleanup/cleaner discovery.
  • Exclude imported sessions from the resume picker (imports remain read-only).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cmd/entire/cli/strategy/manual_commit_session.go Keeps imported session states during shadow-branch orphan cleanup.
cmd/entire/cli/strategy/manual_commit_session_test.go Adds regression test ensuring imported states are not purged by listing cleanup.
cmd/entire/cli/strategy/cleanup.go Prevents imported sessions from being offered as orphaned cleanup items.
cmd/entire/cli/strategy/cleanup_imported_test.go Adds test confirming imported sessions are skipped by orphan cleanup listing.
cmd/entire/cli/session/state.go Exempts imported sessions from IsStale() auto-purge behavior.
cmd/entire/cli/session/state_test.go Tests IsStale() behavior for imported vs non-imported sessions.
cmd/entire/cli/resume_picker.go Filters imported sessions out of the resumable-session picker.
cmd/entire/cli/resume_picker_test.go Tests that imported sessions are excluded from resumable sessions.
cmd/entire/cli/agentimport/agentimport.go Writes imported session.State best-effort after importing checkpoints; adds token aggregation + state writer.
cmd/entire/cli/agentimport/session_state_test.go Adds unit tests for imported session state creation and Run wiring (including --dry-run).

Comment thread cmd/entire/cli/agentimport/agentimport.go
computermode and others added 5 commits July 9, 2026 14:06
Imported sessions are read-only (not resumable/rewindable). Label them so
users don't mistake unsupported writes for breakage:
- session list card shows "imported (read-only)"
- session info text adds a read-only note; --json/list --json expose
  kind + read_only
- resume picker explains when the only sessions present are imports

Rewind already refuses imported checkpoints (refuseIfImportedCheckpoint).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4B7QPKJ5NFBCE8C0XMW0QM
Trail 813 finding: LastPrompt is documented as the most recent user prompt
and rendered as such for every session kind; imported sessions were showing
the opening prompt instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4C5TK0RKT5CZAVBY9KC1DV
Addresses the PR review point that imported sessions stored an un-collapsed,
un-truncated prompt in the LastPrompt display field (bloating state JSON and
diverging from every other session kind). The full prompt remains in the
transcript, which is unchanged and still stored complete per checkpoint.

Moves the shared formatter to session.TruncatePromptForStorage (colocated
with State.LastPrompt) so imports and live sessions format it identically,
avoiding an agentimport->strategy dependency. Simplifies the import
session-state tests with shared helpers and readable session IDs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4D9VZ10V46ER1P01XHNS0V
- Merge the two strategy cleanup tests into one TestImportedSessions_SurviveCleanup
  with a shared saveImportedState helper.
- Merge the list/info read-only tests into one TestImportedSession_MarkedReadOnly
  with a run helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4DTCMV8EMWKYCKMBASNVBA
- Add Kind.IsImported() alongside IsReview/IsInvestigate and route all
  imported special-cases (staleness, orphan cleanup, resume filter, list/info
  labels, JSON field) through it, killing the scattered string-literal checks.
- Add types.AddTokenUsage (canonical, nil-safe, recursive) and use it in the
  importer instead of a hand-rolled fold.
- Drop the single-use pluralizeImportedSessions helper and a redundant local.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 01KX4F2HAMHPF9FYCTD17VN18R
@computermode computermode marked this pull request as ready for review July 9, 2026 23:10
@computermode computermode requested a review from a team as a code owner July 9, 2026 23:10
@computermode computermode requested a review from Soph July 9, 2026 23:10
@computermode computermode merged commit 62a79dc into main Jul 10, 2026
10 checks passed
@computermode computermode deleted the feat/imported-sessions-in-session-list branch July 10, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants