fix: preserve remote session identity across session restore paths#1320
Merged
Conversation
…n tools - propagate remote workspace identity through agent turn submission and reply routing - resolve session-targeted cron and session tool actions from stored workspace bindings - keep scheduled-job reminders ordered after mode and remote file delivery reminders
- Fix remote dialog, cancel, polling, and model lookup paths to restore evicted sessions from the bound session storage directory instead of the logical remote workspace root. - Replace the ambiguous session workspace path resolver with workspace bindings that expose separate logical workspace paths and final on-disk session storage dirs. - Carry remote workspace identity through remote dialog submissions so queued or restored turns keep the correct SSH connection and host binding. - Route empty-context history reloads through the same resolved session storage path used by initial session restore. - Make session storage resolution consistent for local and remote workspaces: local roots resolve to managed project sessions dirs, remote roots resolve to SSH mirror sessions dirs, and unresolved remote sessions stay under the dedicated unresolved tree. - Teach persistence and insight/session listing paths to accept already-resolved sessions dirs without re-slugging them, while rejecting remote runtime roots that are not actual sessions dirs. - Add focused coverage for local, remote, unresolved remote, already-resolved sessions-dir, and remote dialog workspace identity behavior.
Split session restore APIs by input type so logical workspace paths, resolved session storage paths, and workspace identity requests no longer share the same Path-only entrypoint. - add storage-path and workspace-request restore variants - route cron, desktop, scheduler, and remote runtime restores through the correct API - preserve remote workspace identity during remote dialog restore - keep Path-only restore methods for local/legacy callers - add regression coverage for resolved sessions dirs and remote identity restore
Generate scheduled job ids as cron_ plus an 8-character lowercase hex suffix instead of a full UUID string. Keep creation collision-safe by checking existing jobs and retrying when a generated id is already present. Add coverage for the shortened id format.
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.
Summary
Preserve remote workspace identity across session-targeted agent flows and restore paths, and shorten generated cron job ids.
Fixes #
Type and Areas
Type:
bug fix / regression fix
Areas:
Rust core, desktop/Tauri, CLI, runtime ports, remote connect, cron, web UI tests
Motivation / Impact
Remote sessions could lose their SSH identity when restored, queued, or triggered through some internal paths, causing session history, cron/session tools,
/init, manual compaction, fork context capture, remote dialog turns, or scheduled jobs to resolve against the wrong local/slugged storage path.This PR makes remote session identity explicit across session workspace bindings, scheduler submissions, cron/session tools, remote dialog submissions, and persistence/session listing paths. It separates logical workspace paths from final on-disk session storage directories: remote sessions restore from resolved session storage paths, while tools/UI continue to receive logical workspace paths.
It also adds explicit restore APIs for three different inputs:
This avoids passing a resolved
sessionsdirectory through APIs namedworkspace_path, which previously caused double path resolution.Generated cron job ids are now shorter (
cron_+ 8 lowercase hex chars) while still checking existing jobs and retrying on collision.Verification
pnpm run fmt:rscargo test -p bitfun-core workspace_identity_ -- --nocapturecargo test -p bitfun-core restore_session_ -- --nocapturecargo test -p bitfun-core restore_session_for_workspace_uses_remote_identity -- --nocapturecargo test -p bitfun-core generate_cron_job_id_uses_short_hex_suffix -- --nocapturecargo check -p bitfun-corecargo check -p bitfun-desktoppnpm --dir src/web-ui run test:run src/app/startup/startupPerformanceContract.test.tsgit diff --checkReviewer Notes
The main compatibility-sensitive change is the distinction between logical workspace paths and final on-disk session storage directories. Remote workspaces should continue to expose remote logical paths to tools/UI, but persistence and restore paths should use the resolved SSH mirror session directory.
Restore APIs are now intentionally split by input type. Callers that already have a resolved
sessionsdirectory should use the storage-path restore APIs. Callers with a logical workspace and remote identity should use the workspace request APIs. BarePathrestore methods remain for local/legacy callers only.Unresolved remote sessions intentionally stay under the dedicated unresolved remote session tree instead of falling back to local project slug storage.
Cron job ids are intentionally shortened for readability. Creation remains collision-safe through an existing-job check and retry loop.
Checklist