Skip to content

fix: preserve remote session identity across session restore paths#1320

Merged
wsp1911 merged 4 commits into
GCWing:mainfrom
wsp1911:fix/cron
Jun 26, 2026
Merged

fix: preserve remote session identity across session restore paths#1320
wsp1911 merged 4 commits into
GCWing:mainfrom
wsp1911:fix/cron

Conversation

@wsp1911

@wsp1911 wsp1911 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

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:

  • logical workspace path plus remote identity
  • already resolved session storage directory
  • legacy/local workspace path

This avoids passing a resolved sessions directory through APIs named workspace_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:rs
  • cargo test -p bitfun-core workspace_identity_ -- --nocapture
  • cargo test -p bitfun-core restore_session_ -- --nocapture
  • cargo test -p bitfun-core restore_session_for_workspace_uses_remote_identity -- --nocapture
  • cargo test -p bitfun-core generate_cron_job_id_uses_short_hex_suffix -- --nocapture
  • cargo check -p bitfun-core
  • cargo check -p bitfun-desktop
  • pnpm --dir src/web-ui run test:run src/app/startup/startupPerformanceContract.test.ts
  • git diff --check

Reviewer 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 sessions directory should use the storage-path restore APIs. Callers with a logical workspace and remote identity should use the workspace request APIs. Bare Path restore 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

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

wsp1911 added 4 commits June 26, 2026 11:35
…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.
@wsp1911 wsp1911 marked this pull request as ready for review June 26, 2026 14:44
@wsp1911 wsp1911 merged commit cdb2695 into GCWing:main Jun 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant