feat(desktop): persist last project + base branch in v2 new-workspace modal

Merged
KI
6mo ago
+139-11

Summary

  • Remember the user's most recent project and per-project base branch in localStorage so the v2 new-workspace modal pre-fills them on next open.
  • New renderer/lib/v2-workspace-create-defaults.ts follows the same plain-localStorage pattern as useAgentLaunchPreferences — no zustand store.
  • Two write sites (project select, branch select), one read site (modal init for last project; PromptGroup's existing reset-on-project-change effect picks up the per-project base branch default).

Test plan

  • Open the new-workspace modal: first open with no history shows the most recent project, no base branch default.
  • Pick project A, pick base branch X, submit. Reopen modal → project A pre-selected, base branch X pre-filled.
  • Switch to project B from the picker → base branch resets to its own remembered default (or null if none).
  • Pre-selected project (e.g. opened via context menu on a specific project) still wins over the persisted last project.

Summary by cubic

Persist the last selected project, per-project base branch, and device (host target) in the v2 new-workspace modal so it pre-fills on next open and reduces setup steps.

  • New Features

    • Persist last project ID, per-project base branch (name + source), and last host target in a zustand-persisted store (v2-workspace-create-defaults).
    • On open, restore a valid host target and preselect the last project if still available; otherwise use the most recent. External preselection still wins.
    • On project or host change, default the base branch to that project's saved value; selecting a branch updates the saved default, and clearing the picker removes it.
  • Bug Fixes

    • Validate the persisted lastHostTarget shape before applying.

Summary by CodeRabbit

  • New Features
    • The New Workspace modal now persistently remembers per-project base branch and its source, last selected host device, and last selected project. Preferences are restored when reopening the modal, preserved across project/host changes, and updated whenever you pick a different branch, device, or project. Fallbacks ensure a sensible default if no saved preference exists.