Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(desktop): restore primary app state#578

Open
pascalandr wants to merge 5 commits into
NeuralNomadsAI:devfrom
pascalandr:feat/restore-primary-app-state
Open

feat(desktop): restore primary app state#578
pascalandr wants to merge 5 commits into
NeuralNomadsAI:devfrom
pascalandr:feat/restore-primary-app-state

Conversation

@pascalandr

Copy link
Copy Markdown
Contributor

Summary

  • Restore the primary desktop client's window bounds, zoom, workspace tabs, active sessions, drafts, bounded attachments, scroll positions, and panel layout across launches.
  • Keep additional Electron and Tauri processes independent: they still start normally but do not read or write the shared native snapshot.
  • Add translated settings to disable startup restoration or clear the saved state.

Implementation

  • Persist a versioned, bounded snapshot atomically in Electron and Tauri, preserving unknown future envelopes until an explicit clear.
  • Elect one primary process with stale-owner recovery and process identity checks, then protect renderer access with per-document capability tokens.
  • Flush renderer state before close, quit, reload, and app-owned navigation with bounded failure handling and fresh token rotation.
  • Reconcile partial or timed-out workspace hydration without losing unsent prompt state or resurrecting explicitly cleared drafts, attachments, sessions, or tabs.
  • Correlate restore-created workspaces so cancellation and delayed SSE events cannot produce ghost tabs.
  • Harden workspace launch cancellation and cross-platform process cleanup so failed starts cannot orphan detached POSIX, WSL, or Windows children; incomplete shutdown exits nonzero.

The restored shell state remains local to the desktop client. Durable semantic session properties continue to use OpenCode session metadata separately.

Validation

pm run typecheck

pm run typecheck --workspace @neuralnomads/codenomad

  • Electron native suite: 43 passed
  • Tauri suite: 54 passed
  • Focused UI restore, reconciliation, attachment, authority, and race suites passed
  • Focused server workspace runtime, manager, process identity, route, and shutdown suites passed

pm run build

pm run build:tauri

  • git diff --check
  • 16-pass adversarial review loop completed with final No findings

Platform notes

  • Native menu reloads and app-owned navigation have awaited durability guarantees. Browser-engine crashes or forced process termination remain inherently best effort.
  • Process cleanup uses identity-guarded platform adapters and fails conservatively when target ownership cannot be proven.

Restore the primary Electron or Tauri client's window, zoom, workspace tabs, active sessions, drafts, bounded attachments, scroll positions, and panel layout across launches. Secondary processes continue to start normally without reading or writing the shared snapshot.

Add versioned atomic native persistence, process ownership election, renderer capability tokens, bounded flush handshakes for shutdown and navigation, and translated settings to disable or clear restored state. Preserve future snapshot envelopes and merge partial or timed-out workspace hydration without resurrecting explicit user deletions.

Correlate restore-created workspaces and harden startup cancellation and shutdown so late events cannot create ghost tabs or orphan child processes. Verify process identities before platform-specific cleanup, bound retries and shutdown, and report incomplete cleanup with a nonzero exit.

Cover UI reconciliation and persistence races, Electron election and lifecycle behavior, Tauri navigation and shutdown, and server workspace process cleanup. Validated typechecks, native and focused regression suites, Electron build, and Tauri release build.
@pascalandr

Copy link
Copy Markdown
Contributor Author

@CodeNomadBot

I want you to perform the gatekeeper checks for latest PR state

check for regressions
check for better possible implementations
Be the PR gatekeeper
Be ruthless about code quality

@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/29092029490

Artifacts expire in 7 days.
Artifacts:

  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-tauri-macos
  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-tauri-linux
  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-electron-macos
  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-tauri-windows
  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-tauri-macos-arm64
  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-electron-windows
  • pr-578-119dbc6fa19c1a071b9e9bcba9a2792ae6e26a04-electron-linux

Resolve bare Windows commands such as the npm-installed opencode shim through PATH and PATHEXT, then launch cmd, PowerShell, and native executables through the matching spawn path.

Manage direct executables through their owned ChildProcess and stop script wrappers with bounded taskkill tree cleanup instead of repeated all-process CIM queries. Preserve incomplete cleanup state when taskkill fails so retries and shutdown cannot silently accept orphaned descendants or target a reused PID.

Add regression coverage for the observed opencode.cmd timeout, direct executables, taskkill escalation and failure, wrapper exit races, retry behavior, and shutdown reporting.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/29098938563

Artifacts expire in 7 days.
Artifacts:

  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-tauri-macos
  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-tauri-linux
  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-tauri-windows
  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-electron-macos
  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-tauri-macos-arm64
  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-electron-windows
  • pr-578-bb5e0e843ff7e55b108ae01fd80214b66550f511-electron-linux

Keep virtualized message anchors under bounded stabilization until their measured offset settles, and prevent content growth from overwriting a valid restored position. Cancel restoration on explicit user navigation and guard callbacks across session changes.

Restore the persisted Tauri zoom-in shortcut using the actual Ctrl/Cmd+Plus accelerator chord instead of Ctrl/Cmd+Equal.

Add regression coverage for delayed and unstable anchor mounts, content churn, bounded fallback, cancellation, stale generations, and top-crossing anchor selection.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/29103593207

Artifacts expire in 7 days.
Artifacts:

  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-tauri-macos
  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-tauri-linux
  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-tauri-windows
  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-electron-macos
  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-tauri-macos-arm64
  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-electron-windows
  • pr-578-55b5c7697d7a5bb8d39a40639a060a61c798c9ff-electron-linux

Re-enable WebView zoom hotkeys and restore the original Windows View-menu labels for Ctrl++ and Ctrl+-. Remove the replacement menu accelerators that did not match the user's keyboard behavior.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/29105202649

Artifacts expire in 7 days.
Artifacts:

  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-tauri-linux
  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-tauri-windows
  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-tauri-macos
  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-tauri-macos-arm64
  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-electron-macos
  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-electron-windows
  • pr-578-3ae7cd22377f51835a707d71aaa410dc49127f23-electron-linux

Observe WebView2 zoom-factor changes so native keyboard and wheel controls update the cached window zoom without replacing the existing shortcuts or menu labels.

Primary windows capture and debounce the updated native factor into client state, while secondary windows keep only their local zoom cache current. Invalid native values are rejected and valid values use the existing clamp policy.

Add normalization coverage and pin the Windows WebView2 callback dependency to the version used by the current Tauri runtime.
@github-actions

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/29106447067

Artifacts expire in 7 days.
Artifacts:

  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-tauri-macos
  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-tauri-linux
  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-tauri-windows
  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-tauri-macos-arm64
  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-electron-macos
  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-electron-windows
  • pr-578-53d4ad8cbc55faf381d4c6d59cee1e5c55202d77-electron-linux

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