mirror of
https://github.com/github/awesome-copilot.git
synced 2026-10-15 08:11:44 +00:00
fix(canvas): start board state fresh in the session workspace
Drop the legacy extension-folder state import; boards now start empty in session.workspacePath. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 545df520-6557-4211-a110-53c60f4b9f3a
This commit is contained in:
co-authored by
Copilot App
parent
f4319559ab
commit
758f4382db
@@ -30,10 +30,8 @@ This is Copilot's session-state workspace, not the repository checkout. It store
|
||||
metadata, AI reviews, manual bucket overrides, and a history of decisions made from the board.
|
||||
State survives extension reloads and resuming the same session; a new session has its own board.
|
||||
Infinite sessions must be enabled to provide the workspace. Keeping writes outside the extension
|
||||
folder avoids invalidating its safety fingerprint.
|
||||
|
||||
If no session state exists, the board imports the legacy `state/board.json` next to this file when
|
||||
present, without modifying it. Existing session state always takes precedence.
|
||||
folder avoids invalidating its safety fingerprint. State previously stored in the extension folder is
|
||||
not imported; boards start fresh.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -47,4 +45,4 @@ present, without modifying it. Existing session state always takes precedence.
|
||||
## Regression tests
|
||||
|
||||
Run `node --experimental-vm-modules --test eng/board-state-storage.test.mjs` from the repository root
|
||||
to check both canvases' session-scoped persistence and legacy imports without accessing GitHub.
|
||||
to check both canvases' session-scoped persistence without accessing GitHub.
|
||||
|
||||
@@ -358,4 +358,4 @@ if (!session.workspacePath) {
|
||||
store = await new BoardStore(
|
||||
path.join(session.workspacePath, "extensions", CANVAS_ID, "state", "board.json"),
|
||||
REPO,
|
||||
).load({ legacyFile: path.join(EXT_DIR, "state", "board.json") });
|
||||
).load();
|
||||
|
||||
@@ -41,25 +41,14 @@ export class BoardStore {
|
||||
this.writeChain = Promise.resolve();
|
||||
}
|
||||
|
||||
async load({ legacyFile } = {}) {
|
||||
let raw;
|
||||
let imported = false;
|
||||
async load() {
|
||||
try {
|
||||
raw = await readFile(this.filePath, "utf8");
|
||||
const raw = await readFile(this.filePath, "utf8");
|
||||
const parsed = JSON.parse(raw);
|
||||
this.state = { ...emptyState(this.repo), ...parsed, repo: parsed.repo ?? this.repo };
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
if (!legacyFile) return this;
|
||||
try {
|
||||
raw = await readFile(legacyFile, "utf8");
|
||||
imported = true;
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
const parsed = JSON.parse(raw);
|
||||
this.state = { ...emptyState(this.repo), ...parsed, repo: parsed.repo ?? this.repo };
|
||||
if (imported) await this.commit();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user