@@ -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+
5154Selection order:
5255
53561 . Load candidate records using the scope above.
@@ -59,14 +62,33 @@ Selection order:
59623 . If preferred-by-id or preferred-by-key exists and is ` active ` , select it.
60634 . Otherwise select the first ` active ` record in candidates.
61645 . 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
6467Notes:
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
7294PR 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