8000 V0-02: Complete Thinking Workspace lifecycle and recovery by kiran-brahma · Pull Request #21 · kiran-brahma/nodepad-app · GitHub
[go: up one dir, main page]

Skip to content

V0-02: Complete Thinking Workspace lifecycle and recovery - #21

Merged
kiran-brahma merged 2 commits into
mainfrom
claude/github-issue-3-f389f9
Jul 22, 2026
Merged

kiran-brahma merged 2 commits into
mainfrom
claude/github-issue-3-f389f9

Conversation

@kiran-brahma
Copy link
Copy Markdown
Owner

Closes #3.

What changed

Lifecycle is now complete on the durable foundation: create, list, select, rename, and confirm-delete Thinking Workspaces, plus a safe recovery state when the database cannot be opened.

Thinking Workspace intents (src-tauri/src/workspace.rs)

  • select_workspace, rename_workspace, and delete_workspace join create_workspace and create_note on ThinkingWorkspaceInterface. Every intent commits in a single SQLite transaction.
  • Names are trimmed, required, and bounded at 120 Unicode scalar values. Duplicates are allowed and stay distinct because identity is never derived from the name.
  • The active Workspace is persisted as an application preference in a new app_preferences table (migration 0002), not as domain content. On open, a selection that no longer exists falls back to a valid Workspace.
  • Deleting the active Workspace among several selects the deterministic survivor: most recently updated, then most recently created, then highest id. Child Notes go with it through the existing schema cascade.
  • Deleting the only Workspace empties its Notes and resets that same Workspace to the default name, so the app never has zero Workspaces.
  • create_workspace selects the Workspace it creates.

Safe open failure (src-tauri/src/lib.rs, src/App.tsx)

  • WorkspaceStore::open now returns a categorized StorageOpenFailure (unreadable, migration, initialization) instead of aborting startup. Nothing is reset, deleted, or overwritten on failure.
  • The app still starts when storage is unavailable; commands return a new unavailable outcome and the UI renders a recovery screen naming the category, with retry_storage_open and quit_application actions.

UI

  • Workspace list selects through an intent; the active Workspace can be renamed inline and deleted behind a confirmation that names it. Cancelling dispatches no intent.
  • Confirmation resolution lives in src/workspace-lifecycle.ts as pure logic so the cancel path is unit-tested.

Testing

  • Conformance suite extended for both adapters (SQLite and in-memory): duplicate names, whitespace-only names, 120- and 121-scalar Unicode names, not-found intents, active-Workspace delete, inactive-Workspace delete, and only-Workspace reset.
  • New SQLite tests: selection and rename survive reopen, dangling selection falls back, deletes stay deleted after reopen, a rejected delete leaves Workspace + Notes + selection intact, an unreadable database creates nothing, and an injected migration failure reports its category without resetting existing data.
  • npm run check passes: typecheck, lint, vitest (4), cargo test (8), and the Tauri smoke build.

Notes for review

  • src-tauri/gen/ (Tauri-generated ACL schemas) is now gitignored; it was untracked build output.
  • The repository workflow's prd-simplicity-audit, code-review, and fallow skill passes were not run in this session.

🤖 Generated with Claude Code

kiran-brahma and others added 2 commits July 22, 2026 13:16
Add select, rename, and confirm-delete to the Thinking Workspace
interface alongside create, and enforce the invariant that one valid
Workspace always exists and is selected.

- Names are trimmed, required, and bounded at 120 Unicode scalar values;
  duplicate names stay distinct because identity is never the name.
- Active Workspace identity persists as an application preference in a
  new app_preferences table, not as domain content, so the selection
  reopens when the Workspace still exists and falls back safely when it
  does not.
- Deleting the active Workspace among several selects the most recently
  updated survivor; deleting the only Workspace empties its Notes and
  resets it to the default name instead of leaving none.
- Every lifecycle intent commits in a single SQLite transaction, so a
  rejected delete leaves the Workspace, its Notes, and the selection
  untouched.
- Database open and migration failures now render a recovery screen with
  the error category plus retry and quit actions, and never reset or
  overwrite an existing database.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Addresses findings from the two-axis review of this branch.

- A failed open on a path that held no database now removes the stub
  SQLite created before the failure, so the next launch cannot mistake
  an empty stub for a legitimate fresh database. Preparation is injected
  into open so this path is covered by a test.
- Locating the app data folder no longer aborts startup. Both the
  app_data_dir lookup and the folder creation become Initialization
  recovery states, so the thinker always reaches the recovery screen.
  Retry re-resolves the path, so a fixed folder recovers without a
  restart.
- Timestamps are fixed-width UTC, so lexicographic order is chronological
  order in SQL ordering, survivor selection, and tests.
- The survivor test now picks a Workspace that is neither the newest, the
  oldest, the first, nor the last, so no weaker rule passes it. Verified
  by mutation: replacing the rule with most-recently-created fails both
  adapters.
- Added a rejected-rename rollback case, and the dangling-selection test
  now tampers through a separate connection instead of reaching into the
  adapter's private state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kiran-brahma
kiran-brahma merged commit dc95969 into main Jul 22, 2026
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.

V0-02: Complete Thinking Workspace lifecycle and recovery

1 participant

0