GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): attribute migrated V1 sessions to the project of their directory by argszero · Pull Request #51935 · anomalyco/opencode

Conversation

@argszero

@argszero argszero commented Sep 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #51176

Type of change

  • Bug fix

What does this PR do?

The V1 to V2 migration copies legacy sessions as they are, and parks a session under the global pseudo-project whenever its project_id is not in the destination project table. V1 showed sessions by directory, so those rows stayed reachable there; V2 lists sessions per project, so after the migration they disappear from the directory that owns them. The transcript is intact, only the attribution is wrong.

The runtime already knows how to re-own such a row: SessionProjector adopts a session whose project is global (or the directory's previous identity) when Worktree.Event.Resolved fires for its directory. The migration never did the same, so a session copied after its directory had already been resolved stayed under global for good.

The migration now attributes a global session to the most specific known project directory containing it, using project.worktree together with the directories in the worktree table, and stores the subpath that directory implies. A session whose directory no project owns still falls back to global exactly as before, and the existing warning for a missing project is unchanged.

A database whose migration already completed is repaired the same way on the next start, so an existing install recovers without the session move workaround from the report.

The repair only touches rows this migration parked: a row whose project was already corrected by hand is left alone, including one that stays hidden because its path was never filled in. That state is only reachable by editing the database directly, so it is a note rather than a code path — SELECT id, project_id, directory, path FROM session_v2 WHERE path IS NULL lists the rows and they need the subpath their project implies ('' at the project root; NULL does not match) or a session move.

How did you verify your code works?

packages/core/test/v1-migration.test.ts gains two cases, both going through the real migration entry point (V1Migration.run), not a helper:

  • a legacy session under global whose directory belongs to a project is attributed to that project, with the longest matching directory winning and the recorded subpath following the matched directory; a session whose directory no project owns still lands under global
  • a database already at {"phase":"completed"} with a stranded global row has that row attributed

The existing reassignment test (missing project and no owner directory, so global) passes unchanged. bun run test in packages/core: 5566 tests, the new ones pass, and the failures are the same set as on a clean checkout of this base (shell, ripgrep, watcher, and two Session.create adoption tests that need a real git environment). bun run typecheck (tsgo) and oxlint are clean.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@argszero
fix(core): attribute migrated sessions to the project of their directory
da24c2b
V1 listed sessions by directory and left the ones without a registered
project under the `global` pseudo-project. V2 lists per project, so a
migrated row that keeps `global` never shows up in the directory V1 showed
it in, even though its transcript migrated intact.

The runtime already re-owns such a row once the directory's project is
known: SessionProjector adopts sessions whose project is `global` or the
directory's previous identity when Worktree.Event.Resolved fires. The
migration never applied that ownership, so a session copied after its
directory was already resolved stayed under `global` forever.

Attribute a `global` session to the most specific known project directory
containing it (project worktrees and the worktree directory table), with
the matching subpath, and keep `global` only when no project owns the
directory. Rows an earlier migration already wrote are attributed the same
way on the next start, so existing databases recover without the
session move workaround.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@feiiiiii5 feiiiiii5 mentioned this pull request Sep 29, 2026
fix(ci): recognize closing keywords for non-default-base PRs #51971
Closed
3 of 6 tasks
@Veld101 Veld101 mentioned this pull request Sep 29, 2026
[FEATURE]: AGENTS.md: state the linked-issue rule for fix/chore/test PRs; scope the import rules #52022
Closed
1 task done
This was referenced Oct 9, 2026
sessions: V1 sessions from non-git directories hidden from the project session list #53450
Closed
fix(core): restore legacy sessions in markerless projects #54048
Closed
@Frey-Fu Frey-Fu mentioned this pull request Oct 10, 2026
tui: V1→V2 migration stores stripped absolute dir in session.path, hiding sessions from /sessions #53709
Closed
@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:22
@github-actions github-actions Bot removed the needs:issue label Oct 10, 2026
This was referenced Oct 11, 2026
migrate-v1: sessions created in V1 (global+subpath) hidden from V2 session list #54521
Closed
sessions: V1-migrated sessions are orphaned in the global project and hidden after upgrading to V2 #54640
Closed
session: V1 to V2 migration hides legacy sessions from the default cwd-scoped list #54679
Closed
@psno psno mentioned this pull request Oct 12, 2026
migrate-v1: non-git sessions in "global" project hidden after V1→V2 upgrade #49827
Open
This was referenced Oct 12, 2026
sessions: V1 legacy session rows unfindable in V2 /sessions because session.path is not normalized to project-root-relative form #54774
Closed
sessions: non-git directories orphan all pre-upgrade sessions after V1→V2 upgrade #54815
Closed
@rodbarnard

rodbarnard commented Oct 12, 2026

Copy link
Copy Markdown

Confirming this fixes the reported case on 2.0.25, plus one edge worth deciding on.

The subpath handling is correct: target === root ? "" : target.slice(root.length + 1) produces exactly what the listing expects, and a root session landing on path = "" matches the rows that already exist in git-backed projects. That value is load-bearing — I first repaired by hand with path = NULL, and the sessions stayed hidden despite having the correct project_id, because subpath='' does not match NULL.

The edge: attributeDirectories selects WHERE project_id = 'global'. An install where a user has already hand-repaired rows off global (following a workaround for this bug) no longer matches that filter, so those rows are never re-attributed and stay hidden if their path is missing or NULL. Untouched installs are repaired correctly on the next start; partially repaired ones are not.

That may not be worth handling in code, since hand-editing the database is not a supported path — but it seems like a note worth carrying wherever the workaround is documented.

Numbers if they are useful: 225 stranded rows in one non-git directory and 87 in another, in a 373-session database. After correcting project_id and path, the UI filter project=<p>&subpath= returned 112 and 39 root sessions, against 1 and 0 before.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@argszero

argszero commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for taking the time to run it on 2.0.25 — and for the numbers, they are the most useful part of this. "225 and 87 stranded rows in a 373-session database" against "1 and 0 root sessions before, 112 and 39 after" is a much better argument for the change than the test suite is.

On the edge: I agree it should not be handled in code, and I would rather not widen the repair.

attributeDirectories deliberately only touches rows this migration parked — SELECT ... FROM session_v2 WHERE project_id = 'global' AND workspace_id IS NULL. A row that a user has already moved to a real project has been claimed by that project; re-attributing it would mean rewriting rows the migration never wrote, on every start, for a state that only a hand-edited database can be in. Keying the repair on path IS NULL instead is not a safe substitute: path is nullable for V2-native sessions too (pathColumn() is not notNull, and the projector writes event.data.subpath, which is absent for a session created at the project root), so that selector would drag in rows that are perfectly correct as they are. A hand-repaired database stays hand-repaired.

For anyone reading this in the same partially-repaired state, the affected rows are the ones still hidden:

SELECT id, project_id, directory, path FROM session_v2 WHERE path IS NULL;

Those need path set to the subpath their project implies — '' at the project root, since as you found NULL does not match — or a session move for the directory, which is the supported path.

I will carry the note in the PR description so it travels with the change rather than living only here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 13, 2026
migration: v1 sessions imported into "global" project, hidden from TUI session lists #55069
Closed
migration: V1 sessions stay in the synthetic 'global' project after upgrading to V2 and vanish from the session list #55081
Closed
/sessions empty after 1.x → 2.x migration in non-git directory (sessions orphaned under global project) #55142
Closed
migrate-v1: sessions invisible after upgrade (left on 'global' project) #55253
Closed
migration: V1 "global" project sessions invisible in V2 session list after upgrade #55275
Closed
db migration: v1→v2 leaves pre-upgrade sessions invisible in session list (project_id/path not remapped) #55381
Closed
tui: pre-upgrade sessions hidden from session list (stuck under "global" project) #55596
Closed
session: V1 sessions in non-git directories hidden after V2 migration (project_id stays 'global') #55633
Closed
This was referenced Oct 15, 2026
V1→V2 migration: one off-format message ID aborts it; migrated sessions stay invisible (stale project_id + path) #55663
Closed
migration: V1 sessions under the global project disappear from the session list after upgrading to V2 #55671
Closed
sessions: V1 sessions under "global" project hidden after upgrading to 2.0 #56030
Closed
@627-hub 627-hub mentioned this pull request Oct 16, 2026
V2: V1 session history is never imported into session_v2 — old sessions invisible in OpenCode 2 #41217
Closed
This was referenced Oct 17, 2026
migration: V1 sessions in non-git directories are unreachable in the V2 session list #56312
Closed
Migrated non-git sessions stay under project_id 'global', so the V2 TUI shows 0 sessions while the desktop app lists them #56760
Closed
session list dialog empty #57068
Closed
[V2 compat] All legacy v1 session avatars render as "/" (sessions bound to project_id "global") #57067
Open
migrate: V1 sessions invisible in V2 (kept on legacy "global" project id) #57145
Closed
@argszero

argszero commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Closing this to stay within GitHub's 3-open-pull-request limit for contributors without write access, which currently blocks every new pull request here. The branch remains on my fork, so I can reopen it on request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@argszero argszero closed this Oct 20, 2026
@opencode-agent opencode-agent Bot mentioned this pull request Oct 21, 2026
sessions: pre-project-row sessions stranded in global project are hidden from session lists #57629
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

session: v1 "global" sessions stay unattributed after migration and are hidden from v2's session list

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@argszero @rodbarnard
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.