Repository navigation
Date imported agent sessions by their last message instead of file mtime, and allow importing after onboarding #21764
SriCharanK2002
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Follow-up to #21755. The 30-day import window stays as it is; this is about two things around it.
1. Date imported sessions by their last message, not the file's modified time
Session import treats a transcript's file mtime as its last activity (
lastActiveAtMs = transcript.mtimeMsinAgentSessionScanner.ts). That one value decides three things:updatedAt/settledAt, which is how it's sorted and dated in the sidebar.Agent CLIs keep writing to transcripts after the conversation ends, so mtime often drifts from real activity. On one machine (Claude Code 2.1.303, codex-cli 0.162.1):
cost-state,last-prompt,ai-title,mode,permission-mode, and similar bookkeeping..jsonl.zst), so their conversations are never discovered #21755), so mtime reflects when the file was last opened rather than when the user last worked in it.A concrete approach
lastActivityAtfrom the transcript itself: the newesttimestampon a conversational record. For Claude that'suser/assistantrecords that aren't sidechain, meta or compact summaries. For Codex it'sevent_msg(user_message) andresponse_itemmessagerecords. These are the same recordsparseAgentSessionRecordsalready keeps.readCwduses, until the first complete conversational record with a timestamp, under a small per-file byte cap. Bookkeeping records sit at the tail and are small, so this usually takes one or two reads. If the cap runs out, fall back to mtime as today.lastActivityAteverywhere mtime is used as activity: window eligibility, budget ordering, candidatelastActiveAtin the onboarding picker, and the imported thread'supdatedAt/settledAt. Keep mtime and file identity for what they're good at, which is detecting a changed file between scan and read (sameTranscriptIdentity).cost-state/last-promptrecords (dated by the last message).2. Import history after onboarding
The import step is only reachable in the welcome wizard. After onboarding, the only way back on desktop is
location.hash = '#/welcome'in DevTools (see #10961). Re-running the import is already safe to repeat: thread IDs are deterministic, completed transcripts are skipped by file identity, and existing threads are left alone. On this machine, a second run recovered 42 Claude Code sessions the first run had dropped, without touching the 147 existing threads.A per-project Import agent history action (in the project menu and the command palette) that calls
agentSessions.importfor that project would cover:It would also help if the result said why threads were skipped: "N had no user message, N hit the import limit (run again), N couldn't be read". Today it's just "N threads could not be imported".
Prepared by Claude Code (claude-opus-5-5) via
t3 triage.All reactions