Skip to content

fix: isolate desktop sessions by workspace#3029

Merged
esengine merged 1 commit into
esengine:main-v2from
GTC2080:GTC/issue-2813-workspace-sessions
Jun 10, 2026
Merged

fix: isolate desktop sessions by workspace#3029
esengine merged 1 commit into
esengine:main-v2from
GTC2080:GTC/issue-2813-workspace-sessions

Conversation

@GTC2080

@GTC2080 GTC2080 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Store desktop session history under per-workspace project state instead of the shared global session directory.
  • Pass the desktop session directory through startup, workspace switches, model switches, and settings rebuilds so new sessions, history actions, and display sidecars stay scoped.
  • Reject resume paths outside the active workspace session directory.

Fixes #2813

Validation

  • D:\Go\go\bin\go.exe test ./...
  • D:\Go\go\bin\go.exe test ./... from desktop/
  • D:\Go\go\bin\go.exe vet ./...
  • D:\Go\go\bin\go.exe vet ./... from desktop/
  • D:\Go\go\bin\go.exe test . -run ^$ -bench "BenchmarkDesktop(SessionDir|ListSessionsScoped)$" -benchmem -benchtime=2s -count=3 from desktop/

Performance benchmark on Windows 10-class desktop path:

  • BenchmarkDesktopListSessionsScoped: 7.53-8.54 ms/op for 120 current-workspace sessions while another workspace also had 120 sessions.
  • BenchmarkDesktopSessionDir: 1.86-2.09 us/op.

No screenshots: this changes desktop session storage and backend path validation only; no UI surface changed.

@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 4, 2026
@GTC2080 GTC2080 force-pushed the GTC/issue-2813-workspace-sessions branch from a562658 to 2a66774 Compare June 5, 2026 06:19
@GTC2080 GTC2080 requested a review from SivanCola as a code owner June 5, 2026 06:19
@GTC2080 GTC2080 force-pushed the GTC/issue-2813-workspace-sessions branch from 2a66774 to c2cd5d4 Compare June 5, 2026 06:27
@esengine

esengine commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Thanks for this — isolating desktop sessions by workspace is a good improvement. Rebasing against the latest main-v2 hits conflicts in desktop/app.go (3 hunks) and a large ~68-line one in internal/boot/boot_test.go, since session path handling and its tests have changed since this was opened (e.g. legacy session import landed via #3247). Could you rebase onto the latest main-v2 and reconcile the session path logic? Thank you!

@GTC2080 GTC2080 force-pushed the GTC/issue-2813-workspace-sessions branch from c2cd5d4 to cc0fe3b Compare June 6, 2026 13:22
@GTC2080 GTC2080 requested a review from esengine as a code owner June 6, 2026 13:22
@GTC2080 GTC2080 force-pushed the GTC/issue-2813-workspace-sessions branch from cc0fe3b to 50d9710 Compare June 6, 2026 13:36
@GTC2080

GTC2080 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main-v2 and reconciled the session path changes with the legacy session import path from #3247.

Summary:

  • Global/imported topics now resolve an existing known session directory before booting the tab controller, so imported legacy sessions continue in place instead of starting a fresh workspace-scoped transcript.
  • Trash, restore, purge, and preview now resolve paths across known session dirs while still rejecting paths outside those dirs.
  • Added a shutdown fix for background lazy MCP startup so Windows teardown does not leave workspace temp directories locked during tests.

Validation:

  • go test ./internal/boot -run TestBuildMigratesLegacySessionsFromConfigSessionDir -count=50
  • go test ./internal/plugin -run TestLazyBackgroundCloseCancelsInFlightKick -count=50
  • go test ./... -p 1 -count=1
  • cd desktop && go test ./... -count=1
  • go vet ./...
  • cd desktop && go vet ./...
  • desktop benchmarks: ListSessionsScoped 12.0-13.3ms/op for the fixture, desktopSessionDir 1.84-1.95us/op
  • CI run 27063762931 is green, including windows-latest and race

@esengine

Copy link
Copy Markdown
Owner

Thanks for this — workspace-scoped session isolation is a solid improvement. main-v2 has moved on quite a bit and this now conflicts in a few files, including core boot wiring, so it needs a rebase before we can take it:

desktop/app.go
desktop/sessions.go
desktop/tabs.go
desktop/workspace_test.go
internal/boot/boot.go
internal/boot/boot_test.go

Could you rebase onto the latest main-v2 and resolve those? The boot.go / boot_test.go conflicts are the ones to look at most carefully since that path changed recently. Once it's rebased and CI is green I'll review and merge. Thanks!

@esengine

Copy link
Copy Markdown
Owner

Sorry for the churn — main-v2 moved again after your rebase (a few session-display and bash-process changes landed), so this conflicts once more. Most of it is mechanical (struct fields in boot.go, the sessions.go import block), but two spots overlap with a recent refactor and are worth your eyes since they touch your feature:

  • app.go SubmitDisplayToTab: display recording was refactored to a SetDisplayRecorder callback (bindControllerDisplayRecorder) that already reads ctrl.SessionDir(). Your inline recordSessionDisplay(controllerSessionDir(ctrl), …) likely becomes redundant once your SessionDir plumbing feeds ctrl.SessionDir() — please reconcile so recording stays workspace-scoped without double-recording.
  • app.go ResumeSessionForTab: HEAD now calls a.rememberTabSessionPath(tab, path) after ctrl.Resume; keep that but feed it your validated sessionPath.

Could you rebase onto the latest main-v2 once more and resolve those two? Everything else is just keep-both. CI was green on your last push, so it should be quick. Thanks for sticking with it.

@GTC2080 GTC2080 force-pushed the GTC/issue-2813-workspace-sessions branch from 50d9710 to 8dead11 Compare June 10, 2026 03:49
@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) mcp MCP servers / plugins (internal/plugin, codegraph) config Configuration & setup (internal/config) labels Jun 10, 2026
@GTC2080

GTC2080 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main-v2 (1fe5f2c6) and force-pushed the branch.

I reconciled the two overlapping spots you called out:

  • SubmitDisplayToTab now keeps the upstream ctrl.SubmitDisplay(...) path and relies on bindControllerDisplayRecorder, so display recording stays tied to ctrl.SessionDir() without double-recording.
  • ResumeSessionForTab now validates the requested path against the controller session dir, resumes with that sessionPath, and stores the validated sessionPath via rememberTabSessionPath.

Validation:

  • go test ./internal/boot -run TestBuildMigratesLegacySessionsFromConfigSessionDir -count=50
  • go test ./internal/plugin -run TestLazyBackgroundCloseCancelsInFlightKick -count=50
  • go test ./... -p 1 -count=1
  • go vet ./...
  • cd desktop && go test . -run "TestDesktopSessionAPIsUseControllerSessionDir|TestResumeSessionRejectsPathOutsideControllerSessionDir|TestDesktopSessionDirIsScopedByWorkspace|TestOpenProjectTabUsesWorkspaceSessionDir|TestWorkspace" -count=1
  • cd desktop && go vet ./...

PR checks are green now, including desktop, windows-latest, and race.

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice — sessions are now scoped per workspace (own history + trash per project) via a boot SessionDir override, and the Host gains a closed-guard (beginDeferredSpawn) so a lazy/background MCP spawn can't race a controller Close during a workspace switch. Good tests, including the close-cancels-kick race. Merging.

@esengine esengine merged commit 54531f3 into esengine:main-v2 Jun 10, 2026
13 checks passed
SuMuxi66 pushed a commit to SuMuxi66/DeepSeek-Reasonix that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration & setup (internal/config) desktop Wails desktop app (desktop/**) mcp MCP servers / plugins (internal/plugin, codegraph) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 会话记录异常复制+不同工作区会话重叠+每次点开程序都要输入api密钥

2 participants