Skip to content

Commit 437097b

Browse files
docs: align with current implementation.
1 parent 68f20ce commit 437097b

2 files changed

Lines changed: 34 additions & 10 deletions

File tree

docs/idb-workspace-state.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ If a value is required to accurately restore PR/workspace behavior after reload,
4646

4747
`localStorage` should only mirror user preferences and lightweight bootstrap values.
4848

49+
PR metadata boundary:
50+
51+
- PR drawer form edits are draft-only input.
52+
- Persisted PR metadata in workspace records is updated on successful workflow outcomes
53+
(Open PR, Push Commit, Close/verified closed updates), not on each form edit.
54+
4955
## Post-Push Baseline Invariant
5056

5157
After a successful Push Commit action for an active PR workspace:

docs/pr-context-storage-matrix.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ When the app loads, workspace restore scope depends on whether a repository is s
4848
- If a repository is selected: use repository-scoped records only (`repo` match).
4949
- If no repository is selected: evaluate all stored workspace records.
5050

51+
If a repository is selected and no repository-scoped records are found, restore falls back
52+
to evaluating all stored workspace records.
53+
5154
Selection order:
5255

5356
1. Load candidate records using the scope above.
@@ -59,14 +62,33 @@ Selection order:
5962
3. If preferred-by-id or preferred-by-key exists and is `active`, select it.
6063
4. Otherwise select the first `active` record in candidates.
6164
5. Otherwise select preferred-by-id or preferred-by-key if present.
62-
6. Otherwise fall back to the first record returned by IDB ordering.
65+
6. Otherwise fall back to the first candidate by recency (`lastModified` descending).
6366

6467
Notes:
6568

6669
- No `active workspace` pointer is stored in `localStorage`.
6770
- Restore behavior is intentionally derived from IDB workspace records + in-memory runtime state.
6871
- This avoids cross-storage drift between `localStorage` and IndexedDB.
6972

73+
## PR Drawer Persistence Boundary
74+
75+
PR drawer field edits are treated as draft input.
76+
77+
- Editing PR base/head/title in the drawer does not persist workspace record metadata by itself.
78+
- Workspace PR metadata is committed by explicit successful workflow outcomes (for example:
79+
successful Open PR, successful Push Commit, or successful Close PR/verified closed updates).
80+
81+
This keeps workspace records aligned to verified workflow outcomes instead of intermediate
82+
form state.
83+
84+
## Active Record Model
85+
86+
Multiple `active` PR workspaces may exist for the same repository.
87+
88+
- The model does not enforce a single-active-record-per-repository invariant.
89+
- Restore selection still follows the algorithm above and picks one workspace to load into
90+
the current runtime.
91+
7092
## Why PR Context Lives In IDB Only
7193

7294
PR workflow state is part of workspace state.
@@ -101,14 +123,10 @@ indexedDB.open('knighted-develop-workspaces').onsuccess = event => {
101123
}
102124
```
103125

104-
## End-Of-Session Behavior
105-
106-
`Close` is the end-of-session action for PR-linked workspaces.
107-
108-
When close is confirmed:
126+
## Close Behavior
109127

110-
1. The current workspace is archived as historical (`closed`).
111-
2. The app immediately switches to a fresh local workspace (`inactive`) with a single empty entry tab.
112-
3. Status messaging guides the user to continue locally or reopen a stored workspace from Workspaces.
128+
`Close` archives PR-linked context in IDB and clears active PR context in runtime.
113129

114-
In the Workspaces drawer, inactive local-only workspace options are prefixed with `local:`.
130+
- Matching workspace records for that PR context are persisted as `closed`.
131+
- Close does not force an automatic fresh-local-workspace handoff.
132+
- Workspace switching remains an explicit Workspaces action.

0 commit comments

Comments
 (0)