Skip to content

Fix desktop long-history lag and cancellation state / 修复桌面端长历史卡顿与取消状态#5512

Merged
SivanCola merged 2 commits into
esengine:main-v2from
SivanCola:fix/desktop-performance-5306
Jun 28, 2026
Merged

Fix desktop long-history lag and cancellation state / 修复桌面端长历史卡顿与取消状态#5512
SivanCola merged 2 commits into
esengine:main-v2from
SivanCola:fix/desktop-performance-5306

Conversation

@SivanCola

@SivanCola SivanCola commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add paged desktop history APIs so long-session hydration loads the latest visible user-turn window first and fetches older history on demand.
  • Keep and extend the cached-transcript reuse path from fix(desktop): skip cached transcript history reloads #5495, including the session identity guard, so repeat tab/topic opens do not reload the same transcript.
  • Avoid full-history checkpoint refreshes after turn_done, move BalanceForTab out of the blocking hydrate path, and coalesce transcript resize repinning into animation frames.
  • Return an explicit cancelled shell tool result for desktop RunShell cancellation so Stop can reconcile the foreground turn cleanly.
  • Run foreground/background shell processes through the existing tracked process-tree runner where cleanup is required, so Windows bash/PowerShell child processes are assigned to a Job Object and reaped on cancel, timeout, or normal shell exit.
  • Stop idle active goal/todo runs when Desktop Stop has no foreground turn to cancel, and clear the active goal from the Composer Stop path.
  • Preserve the real user prompt on explicit cancellation while stripping partial assistant/tool/todo remnants, so follow-up turns and resumes do not lose user context after Ctrl+C.
  • Persist an in-flight turn marker in session sidecar metadata and clear stale partial assistant/tool/todo tails on resume after a force quit, crash, or kill during a turn.

Fixes #5306
Fixes #5200
Fixes #5499
Fixes #4986
Refs #5355
Refs #5495
Refs #5210

Consolidation notes

Kept/adapted:

Reviewed but not adopted:

Repository Contributor Credits

Cache impact

Cache-impact: none for provider prompt caching. This changes desktop/Wails history hydration, frontend state handling, controller shell cancellation, shell process-tree cleanup, idle-goal cancellation, post-cancel transcript cleanup, and session sidecar recovery metadata; it does not change system prompts, provider request serialization, tool schemas, memory prefixes, or compaction behavior.
Cache-guard: N/A for provider cache; focused desktop/frontend and Go tests are listed below.
System-prompt-review: N/A.

Verification

  • PASS git diff --check origin/main-v2...HEAD
  • PASS go test ./...
  • PASS go test ./internal/control
  • PASS go test ./internal/agent
  • PASS go test ./internal/tool/builtin
  • PASS go test ./internal/proc
  • PASS go test ./internal/agent -run 'TestSessionInFlightTurnMetaRoundTrip|TestRunCancelledMidStreamLeavesResumableSession|TestCancelDuring(StuckProviderStreamReturnsPromptly|ToolExecutionBreaksOutPromptly|BatchStopsRemainingTools)|TestCancelBeforeParallelBatchSkipsTheWholeRemainingBatch|TestCancelInsideLargeParallelBatchStopsSchedulingNewTools'
  • PASS go test ./internal/control -run 'TestResumeClearsStale(Visible|Synthetic)InFlightTurn|TestTurnOrchestratorCancelPreservesVisibleUserPrompt|TestTurnOrchestratorCancelFlushesCleanTranscriptToDisk|TestCancelStopsIdleGoalWithIncompleteTodos|TestRunShell_CancelStopsCommand'
  • PASS go test ./internal/tool/builtin -run 'TestBash(CancelReturnsPromptly|ForegroundTimeoutConfig|ExplicitZeroTimeoutDoesNotCapForeground)|TestWorkspacePassesBashTimeout|TestShouldReapAfterRunHonorsExplicitPreserveOnlyOnCompletion|TestReapTreeKillsBackgroundProcess|TestBackgroundKill'
  • PASS GOOS=windows GOARCH=amd64 go test -c ./internal/tool/builtin
  • PASS GOOS=windows GOARCH=amd64 go test -c ./internal/proc
  • PASS go test . -run 'TestHistory(Page|Checkpoint|Preview|Resume)' from the desktop module
  • PASS pnpm --dir desktop/frontend typecheck
  • PASS pnpm --dir desktop/frontend check:css
  • PASS pnpm --dir desktop/frontend exec tsx src/__tests__/composer-goal-toggle.test.tsx
  • PASS pnpm --dir desktop/frontend exec tsx src/__tests__/use-controller-meta.test.ts
  • PASS pnpm --dir desktop/frontend exec tsx src/__tests__/tab-switch-hydration.test.tsx
  • PASS pnpm --dir desktop/frontend exec tsx src/__tests__/new-session-load-race.test.tsx
  • PASS pnpm --dir desktop/frontend exec tsx src/__tests__/use-controller-cancel-reconcile.test.tsx
  • PASS pnpm --dir desktop/frontend exec tsx src/__tests__/resize-drag.test.ts

@SivanCola SivanCola requested a review from esengine as a code owner June 28, 2026 15:17
@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 28, 2026
@SivanCola SivanCola force-pushed the fix/desktop-performance-5306 branch from fdc204a to 5f79395 Compare June 28, 2026 15:37
@SivanCola SivanCola changed the title Fix desktop long-history lag / 修复桌面端长历史卡顿 Fix desktop long-history lag and cancellation state / 修复桌面端长历史卡顿与取消状态 Jun 28, 2026
@SivanCola SivanCola force-pushed the fix/desktop-performance-5306 branch from 5f79395 to f331c5b Compare June 28, 2026 16:02
@SivanCola SivanCola force-pushed the fix/desktop-performance-5306 branch from f331c5b to c9a358c Compare June 28, 2026 16:16
@github-actions github-actions Bot added the skills Skill system (internal/skill, internal/tool) label Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) desktop Wails desktop app (desktop/**) skills Skill system (internal/skill, internal/tool) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

1 participant