feat: make idb source of truth for pr context.#87
Conversation
There was a problem hiding this comment.
Pull request overview
This PR shifts GitHub PR “active context” ownership away from repo-scoped localStorage and toward the workspace/IndexedDB model, updating the PR drawer to hydrate active context from the current workspace state and removing the legacy storage implementation.
Changes:
- Removed the PR drawer
localStorageconfig module and updated drawer controllers to use an in-memory active-context map plus agetPersistedActivePrContexthook. - Added app-core helpers to (a) expose the persisted active PR context from current workspace/UI state and (b) clear legacy
knighted:develop:github-pr-config:*keys. - Added/updated documentation describing storage ownership (PR context in IDB only; localStorage limited to lightweight bootstrap keys).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/github/pr/drawer/controller/run-submit.js | Writes active PR context via setRepositoryActivePrContext after opening a PR. |
| src/modules/github/pr/drawer/controller/repository-form.js | Stops persisting repo-scoped draft PR config; syncs form fields from active context only. |
| src/modules/github/pr/drawer/controller/public-actions.js | Updates disconnect/clear/close flows to clear active context without localStorage config updates. |
| src/modules/github/pr/drawer/controller/create-controller.js | Introduces in-memory active-context storage and loads persisted context via getPersistedActivePrContext. |
| src/modules/github/pr/drawer/controller/context-sync.js | Verifies active PR state using active context; updates/clears in-memory context accordingly. |
| src/modules/github/pr/drawer/config.js | Deleted legacy localStorage-backed PR drawer config implementation. |
| src/modules/github/byot-controls.js | Removes auto-select behavior based on legacy localStorage PR context. |
| src/modules/app-core/persisted-active-pr-context.js | New helper for providing “persisted” active PR context from workspace/UI state. |
| src/modules/app-core/legacy-pr-config-storage.js | New helper to clear legacy PR config localStorage keys. |
| src/modules/app-core/github-workflows.js | Wires getPersistedActivePrContext into PR drawer construction. |
| src/modules/app-core/github-workflows-setup.js | Passes runtime getPersistedActivePrContext through setup. |
| src/modules/app-core/github-pr-icons.js | Extracts PR icon definitions from app.js into a dedicated module. |
| src/app.js | Clears legacy PR config storage on boot; provides getPersistedActivePrContext; moves icons to module. |
| docs/pr-context-storage-matrix.md | Updates matrix/docs to reflect IDB-only PR context ownership. |
| docs/localstorage-state.md | New doc defining allowed localStorage keys and explicitly forbidding PR context. |
| docs/idb-workspace-state.md | New doc defining IDB workspace record ownership, including PR context state. |
Comments suppressed due to low confidence (1)
src/modules/github/pr/drawer/controller/context-sync.js:226
- When PR verification determines the saved PR is no longer open on GitHub, this branch now only clears the in-memory active context. That causes the runtime
onActivePrContextChangehandler to persist the workspace PR context asinactive, losing the ability to record aclosed(ordisconnected) state in IndexedDB as described by the new IDB-as-source-of-truth docs. Consider propagating the verified outcome to the runtime layer (e.g., via a dedicated callback or return value) so the workspace record can be updated toclosedwhile preserving the PR number/head/base metadata, instead of treating it as a generic inactive state.
clearRepositoryActivePrContext(repositoryFullName)
setSubmitButtonLabel()
emitActivePrContextChange()
state.lastActiveContentSyncKey = ''
abortPendingActiveContentSyncRequest()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.