Skip to content

fix(migrate): route legacy v0.x sessions into their workspace session dirs#3944

Merged
esengine merged 1 commit into
main-v2from
fix/legacy-session-routing
Jun 11, 2026
Merged

fix(migrate): route legacy v0.x sessions into their workspace session dirs#3944
esengine merged 1 commit into
main-v2from
fix/legacy-session-routing

Conversation

@esengine

Copy link
Copy Markdown
Owner

Fixes the headline complaint from every 0.53→1.x upgrade thread: sessions import "successfully" and then nobody can see them.

Root cause (from #3937)

The flat import (#3247) reconstructs v0.x sessions into the global config session dir, but the desktop sidebar only lists the per-workspace projects/<slug>/sessions dirs, and nothing reads the v0.x sidecar (<name>.meta.json) that says which workspace a session belonged to.

What this does

  • Layout helper moves down: the per-workspace session-dir layout is now config.ProjectSessionDir / config.WorkspaceSlug; the desktop helper delegates to it. Two consumers (sidebar + importer) → the concept lives in the root module.
  • Meta-aware routing: the importer reads each session's sidecar. A live workspace routes the session into that workspace's sessions dir and carries the summary into .titles.json (the map the sidebar reads) so imported sessions are labeled. Dead or missing workspaces fall back to the global dir as before.
  • One-time re-home pass for existing upgraders: the routed pass runs once even where the flat-import markers are already present, moving stranded global-dir sessions into their workspace dirs. A file is only moved when its mtime matches the legacy event log (the flat import stamped it), so a same-named native v1+ session is never touched. The pass stamps the flat markers too, so a downgrade doesn't re-run the flat import over routed sessions.

Trade-off, stated plainly

A session the user deliberately deleted after the flat import reappears once (in its workspace) during the routed pass — there is no record distinguishing "deleted by user" from "never imported". Recovering every stranded upgrade beats protecting against one resurrection.

Tests

  • routing by sidecar workspace + title carry-over
  • dead-workspace fallback to global
  • re-home moves the flat import (content preserved, not re-reconstructed)
  • mtime mismatch keeps a native same-named session intact
  • routed pass ignores flat markers, gates on its own
  • all existing migrate/boot/desktop session tests updated and green

Closes #3937

… dirs

The flat import (#3247) reconstructed v0.x sessions into the global
config session dir, but the desktop sidebar only lists the per-workspace
projects/<slug>/sessions dirs — so for desktop users the import
"succeeded" into a directory nothing reads, and upgraders kept reporting
their history gone (#3937).

- the per-workspace session-dir layout moves to config.ProjectSessionDir
  (the desktop helper now delegates), so the importer can route to it
- the importer reads each session's v0.x sidecar (<name>.meta.json):
  a live workspace routes the session into that workspace's dir, the
  summary becomes its display title; dead/missing workspaces fall back
  to the global dir as before
- a new one-time routed pass deliberately ignores the flat-import
  markers so existing upgraders get their stranded sessions re-homed;
  a global-dir file is only moved when its mtime matches the legacy
  event log (the flat import stamped it), so a same-named native v1+
  session is never touched

Trade-off: sessions a user deleted after the flat import reappear once
(in their workspace) during the routed pass; there is no record that
distinguishes "deleted by user" from "never imported", and recovering
every stranded upgrade is worth one resurrection.

Closes #3937
@esengine esengine requested a review from SivanCola as a code owner June 11, 2026 04:25
@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 11, 2026
@esengine esengine merged commit 2f45fb2 into main-v2 Jun 11, 2026
14 checks passed
@esengine esengine deleted the fix/legacy-session-routing branch June 11, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy v0.53 sessions import into the global session dir, invisible to per-workspace desktop sidebar

1 participant