Skip to content

fix(desktop): persist mode and toolApprovalMode without round-trip loss, report PendingPrompt in Meta#5482

Closed
erphenheimer wants to merge 1 commit into
esengine:main-v2from
erphenheimer:fix/mode-ask-persistence
Closed

fix(desktop): persist mode and toolApprovalMode without round-trip loss, report PendingPrompt in Meta#5482
erphenheimer wants to merge 1 commit into
esengine:main-v2from
erphenheimer:fix/mode-ask-persistence

Conversation

@erphenheimer

Copy link
Copy Markdown

Summary

Fix two related desktop bugs where session switching corrupts or loses the mode (ask/auto/yolo/plan) state for non-focused tabs. Both bugs stem from the same root cause: the mode and toolApprovalMode fields in WorkspaceTab were persisted using an encoding that dropped default values ("" for "normal" and "ask"), causing round-trip information loss on every save+reload.

Changes

Bug fix: mode/toolApprovalMode round-trip loss (desktop/tabs.go)

  • persistedTabMode() now always returns the normalized mode (previously returned "" for "normal")
  • persistedToolApprovalMode() now always returns the normalized mode (previously returned "" for "ask")
  • Both functions now faithfully round-trip every value through save-load-save

Bug fix: missing PendingPrompt in Meta (desktop/app.go)

  • Added PendingPrompt bool to the Meta struct so the frontend receives pending-prompt status when loading a tab's metadata
  • MetaForTab() now populates PendingPrompt from tab.Ctrl.PendingPrompt()
  • This enables the frontend to properly restore pending approval dialogs on tab switch

Robustness: bidirectional reconciliation in loading code (desktop/app.go)

  • The existing reconciliation only handled: mode implies yolo -> upgrade toolApprovalMode
  • Added the reverse: toolApprovalMode is yolo/auto but mode is normal -> update mode
  • Added comprehensive comments explaining the dual-representation design

Verification

  • 7 new test functions in desktop/tab_profile_test.go:
    • TestPersistedTabModeAlwaysPersistsNormal, TestPersistedTabModeRoundTripsAllValues
    • TestPersistedToolApprovalModeAlwaysPersistsAsk, TestPersistedToolApprovalModeRoundTripsAllValues
    • TestSaveTabsPersistsNormalModeAndAsk, TestSaveTabsRoundTripPreservesAllModes
    • TestTabModeReconciliationHandlesOlderFormat, TestMetaForTabReportsPendingPrompt

Related Issues

Cache-impact: none (desktop module only)
Cache-guard: N/A
System-prompt-review: N/A

@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 28, 2026
@erphenheimer erphenheimer marked this pull request as draft June 28, 2026 07:14
@erphenheimer erphenheimer marked this pull request as ready for review June 28, 2026 07:18
@erphenheimer erphenheimer force-pushed the fix/mode-ask-persistence branch 2 times, most recently from a0b0ff2 to 2372891 Compare June 29, 2026 07:27
…ss, report PendingPrompt in Meta (esengine#5480 esengine#5481)

Bug 1: Session switching causes mode (ask/auto/yolo) to flicker
- persistedTabMode always persists the mode value (no longer returns ''
  for 'normal', which lost information on round-trip)
- persistedToolApprovalMode always persists (no longer returns '' for 'ask')
- Loading code now reconciles desync in BOTH directions:
  * Mode implies yolo but toolApprovalMode is ask -> upgrade to yolo
  * Mode is normal but toolApprovalMode is yolo/auto -> update mode

Bug 2: Switching to a running session loses ask/plan state in other sessions
- Added PendingPrompt bool field to Meta struct so the frontend
  receives pending-prompt status when loading a tab's metadata
- Frontend can now properly restore pending ask dialogs on tab switch

Tests: 7 new test functions covering all mode round-trips, ALL mode+toolApprovalMode
combinations, older-format backward compatibility, and PendingPrompt reporting.

Cache-impact: none (desktop module, not in cache-sensitive paths)
Cache-guard: N/A (desktop/ module, no system prompt or provider changes)
System-prompt-review: N/A
@erphenheimer erphenheimer force-pushed the fix/mode-ask-persistence branch from 2372891 to 19dcc9c Compare June 29, 2026 12:23
@erphenheimer erphenheimer deleted the fix/mode-ask-persistence branch June 30, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 切换会话时 Ask 提示和计划模式被吞掉 [Bug]: 会话切换导致 Mode(询问/自动/YOLO)反复横跳

1 participant