Repository navigation
fix: restart restores savedAt as lastSeen instead of fabricating boot-time activity (#404) - #487
Merged
Conversation
…-time activity (#404) - buildSession: lastSeen = parsed.savedAt ?? Date.now(); restored sessions flagged in-memory `restored: true` until their first real request - getSession touch (existing + memory-miss reload) clears the flag - initSessions boot truncation keys on max(createdAt, savedAt) so an active-but-old session keeps its slot over a newer-created idle one - handlePluginStatus fallback=latest only considers sessions with post-boot activity; exhausted fallback 404s explicitly instead of resolving the readdir-order tie to an unrelated old session - panel stats expose `restored`; web sessions table marks restored rows
Closed
3 tasks
Contributor
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-487Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr487.tgz
npm install -g packageThis comment is automatically updated on each push. |
Owner
Author
[bot] 🏷 PR #487 reviewed — verified independently on Pre-flight re-run (my environment)
Branch hygiene: merge-base is 37ecfce (post-#486 master), so the PR is exactly one commit ahead of master — no stacked/unmerged commits riding along. Triage verdict: bug is real, fix hits the root causeReproduced the failure mode by reading the code paths, not just the report:
Minor notes (non-blocking)
LGTM — ship it. The one-line test addition above is optional polish you can fold in or skip. |
This was referenced Sep 3, 2026
Merged
This was referenced Sep 15, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #404.
What
Every boot used to stamp every disk-restored session with
lastSeen: Date.now(), so all restored sessions shared one millisecond — the panel's "最后活动" column showed the boot time for every row, andhandlePluginStatus'sfallback=latestbroke the N-way tie by readdir order, attaching a fresh client (dsh / opencode status bar) to an unrelated old session. Boot-load truncation keyed oncreatedAtonly, so an active-but-old session could lose its slot to a newer-created idle one.buildSession(src/persist.ts):lastSeen = parsed.savedAt ?? Date.now(); restored sessions flagged in-memoryrestored: true(not persisted, no schema change)getSession(src/session.ts): both touch paths (existing-session hit and memory-miss reload — a reload IS a real request) clear the flag and stamp fresh activityinitSessions: truncation keymax(createdAt, savedAt)handlePluginStatus(src/plugin.ts):fallback=latestfiltersrestored !== true; when only restored sessions exist it 404s with an explicit "no session with activity since boot" instead of guessingsendStatsexposesrestored; web sessions table marks restored rows "(恢复,开机后未活动)"Side benefits:
evictOldestandlistSessionsnow order by true activity (restored sessions sink first), since they consume the samelastSeen.Pre-flight
tests/issue404-restore-timestamps.test.ts3/3 (boot truncation by freshness + savedAt restore + fallback skip + exhausted fallback + memory-miss touch)plugin-agent.test.tsenv failures, reproduce on clean master