Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions docs/pr-context-storage-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ See the full storage ownership docs for non-PR keys:

Use this matrix as the source of truth when debugging UI/storage mismatch.

| Scenario | IDB `prContextState` | IDB `prNumber` | localStorage PR fields | Notes |
| --------------------------------------------- | -------------------- | --------------------------------- | ---------------------- | ----------------------------------------------------------- |
| A. Local workspace only, no PR context | `inactive` | `null` | none | No connected PR context. |
| B. Workspace is for an active, open PR | `active` | PR number | none | Push mode in PR controls. |
| C. Workspace is for a disconnected PR context | `disconnected` | last known PR number if available | none | PR may still be open on GitHub; reconnect can verify later. |
| D. Workspace is for a PR closed on GitHub | `closed` | closed PR number | none | Historical context retained for debugging/reference. |
| Scenario | IDB `prContextState` | IDB `prNumber` | localStorage PR fields | Notes |
| --------------------------------------------- | -------------------- | --------------------------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------- |
| A. Local workspace only, no PR context | `inactive` | `null` | none | No connected PR context. |
| B. Workspace is for an active, open PR | `active` | PR number | none | Push mode in PR controls. |
| C. Workspace is for a disconnected PR context | `disconnected` | last known PR number if available | none | Opening this workspace from Workspaces restores PR runtime context and verifies open/closed state with GitHub. |
| D. Workspace is for a PR closed on GitHub | `closed` | closed PR number | none | Historical context retained for debugging/reference. |

## Current Workspace Selection On Load

Expand Down Expand Up @@ -79,7 +79,9 @@ When the UI does not match expected PR state:
- `prNumber`
- `repo`, `head`, `prTitle`
2. Compare against the matrix above.
3. If scenario C is expected, remember GitHub-open verification is deferred until reconnect flow is invoked.
3. If scenario C is expected, open that workspace from Workspaces to restore runtime PR context.
4. If the PR is still open on GitHub, expect PR controls to return to Push mode and the workspace record to transition back to `active`.
5. If the PR is no longer open, expect Open PR mode to remain and status messaging to explain verification results.

## Console Snippets

Expand All @@ -94,6 +96,20 @@ indexedDB.open('knighted-develop-workspaces').onsuccess = event => {
}
```

## Current Limitation
## Reconnect Behavior

Reconnect behavior from the Workspaces drawer is not implemented yet. This document defines the storage contract needed to support that workflow reliably.
Reconnect behavior from the Workspaces drawer is implemented.

Opening a `disconnected` workspace record restores active PR runtime context for that repository and reinitializes editor state from the selected workspace record.

## End-Of-Session Behavior

`Disconnect` and `Close` are treated as end-of-session actions for PR-linked workspaces.

When either action is confirmed:

1. The current workspace is archived as historical (`disconnected` or `closed`).
2. The app immediately switches to a fresh local workspace (`inactive`) with a single empty entry tab.
3. Status messaging guides the user to continue locally or reopen a stored workspace from Workspaces.

In the Workspaces drawer, inactive local-only workspace options are prefixed with `local:`.
Loading
Loading