Skip to content

fix(tui): allow custom destination path in move session - #49560

Closed
mavasbel wants to merge 3 commits into
anomalyco:devfrom
mavasbel-devtools:cross-project-move
Closed

mavasbel wants to merge 3 commits into
anomalyco:devfrom
mavasbel-devtools:cross-project-move

Conversation

@mavasbel

@mavasbel mavasbel commented Sep 17, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #49212
Closes #40200
Closes #43938
Closes #35306

Type of change

  • Bug fix

What does this PR do?

The /move session command currently only surfaces worktrees of the current project and rejects destinations outside the project's worktree (DestinationProjectMismatchError). Searching for nested projects returns "No results found" (#49212), previously visited project directories never appear (#40200), the footer directory indicator stays stale after moving (#43938), and the palette description duplicates the command title (#35306).

This PR:

  • Enables cross-project relocation: Extends moveSession to allow moving sessions to arbitrary directories and across distinct projects, updating SessionTable.project_id, persisting projectID on SessionEvent.Moved, and registering the destination in ProjectTable.
  • Auto-creates missing directories: Destination paths are automatically created on disk via fs.ensureDir.
  • Guards git patch transfer: Uncommitted git working-copy patch transfer is only applied within the same git repository, preventing cross-repo patch errors.
  • Discovers all registered projects (Closes TUI "Move session" picker can't reach nested project directories; Search returns "No results found" #49212, Project dirs are not being recognized, nothing is listed under /move #40200): Queries sdk.client.project.list() and sdk.client.project.directories() to surface all registered project directories across the database under the "Other" section, allowing nested projects (e.g. /work/repos/HomeLab) and sibling projects to appear and match fuzzy search.
  • Live directory autocompletion: Adds live directory autocompletion under a unified "Directories" section with root at the top and subdirectories sorted alphabetically, supporting Left/Right arrow directory traversal (➔ to drill down, ⬅ to move to parent) while preserving Tab navigation for footer action buttons.
  • Path prompt via ctrl+m: Pressing ctrl+m ("new") opens DialogPrompt allowing the user to enter any target path directly, while falling back to automatic git worktree creation if left blank.
  • Canonical casing & ~ expansion: Normalizes paths against true filesystem casing on disk via fs.realpathSync.native and expands ~ to the home directory.
  • Fixes stale footer indicator (Closes tui: directory indicator stays stale after /move in a new session #43938): Updates useDirectory() in packages/tui/src/context/directory.ts to inspect the active session's directory. (Credit to @timrichardson for the earlier investigation in fix(tui): refresh directory after move [v2] #44829; this PR provides the active-session resolution for the current dev architecture in context/directory.ts).
  • Palette description cleanup (Closes TUI move session command description is unclear #35306): Cleans up the command palette registration, removing redundant description text.

How did you verify your code works?

  • Added schema contract tests in packages/schema/test/session-event.test.ts.
  • Added live integration tests in packages/core/test/move-session.test.ts:
    moves session across distinct project repositories without transferring git changes.
    All 4 move-session tests pass (bun test test/move-session.test.ts).
  • Added TUI component and context unit tests in packages/tui/test/component/dialog-move-session.test.ts (including mergeProjectDirectories) and packages/tui/test/context/directory.test.ts.
  • Verified full monorepo typecheck: bun turbo typecheck passes cleanly across all 30 workspace packages.

Checklist

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

@timrichardson

Copy link
Copy Markdown

/move no longer exists in opencode2. behaviour has changed a lot. We have /worktrees: upon selecting a worktree, we get a new session, so this no longer moves the existing session, and there is /cd which sees to move the session to a new directory, which can be a worktree I think, but it doesn't do smart things like reading direnv in the new worktree. So in my opinion this is a regression in opencode2, which won't benefit from this PR.

@mavasbel
mavasbel force-pushed the cross-project-move branch 2 times, most recently from bdd1b0e to 63941e3 Compare September 21, 2026 03:02
@mavasbel

Copy link
Copy Markdown
Author

Thanks so much for the helpful context on the v2 direction, @timrichardson!

This PR targets the default dev branch (1.18.x) to address active issues like #49212 where /move is still in daily use. That said, I'd be more than happy to help adapt the underlying core engine to v2 as well if useful, and look forward to whatever @kommander and the maintainers recommend! 🙏

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 2026
@mavasbel
mavasbel deleted the cross-project-move branch October 21, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants