({ workspaceId, root })
| 51 | |
| 52 | return { |
| 53 | async initializeWorkspace({ workspaceId, root }) { |
| 54 | const refs = reviewRefs(workspaceId); |
| 55 | const state: WorkspaceReviewState = { root, ...refs }; |
| 56 | states.set(workspaceId, state); |
| 57 | |
| 58 | try { |
| 59 | const eligibility = await getGitEligibility(root); |
| 60 | if (!eligibility.ok || !eligibility.gitRoot) { |
| 61 | state.diagnostic = eligibility.message ?? "show_changes requires a Git workspace in this version."; |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | state.gitRoot = eligibility.gitRoot; |
| 66 | const commit = await createWorkingTreeSnapshot(eligibility.gitRoot); |
| 67 | await git(eligibility.gitRoot, ["update-ref", state.openRef, commit]); |
| 68 | await git(eligibility.gitRoot, ["update-ref", state.baselineRef, commit]); |
| 69 | } catch (error) { |
| 70 | state.diagnostic = error instanceof Error ? error.message : String(error); |
| 71 | } |
| 72 | }, |
| 73 | |
| 74 | async reviewChanges({ workspaceId, root, since = "last_shown", markReviewed = true }) { |
| 75 | let state = states.get(workspaceId); |
nothing calls this directly
no test coverage detected