fix(dashboard): preserve store this-binding in merge-advance-events endpoint

The route was extracting getRunAuditEvents off scopedStore and calling it as
a bare function, which made this.db.prepare(...) throw. useMergeAdvanceNotice
silently swallowed the error, so the banner never rendered after merges.
Call the method on the store reference instead so this is preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-23 14:16:36 -07:00
parent 6ecaa717d6
commit 6083de214a
2 changed files with 14 additions and 5 deletions

View File

@@ -0,0 +1,9 @@
---
"@fusion/dashboard": patch
---
fix(dashboard): unbreak Merge Advance Notice banner by preserving store `this` binding in events endpoint
`GET /api/tasks/merge-advance-events` was extracting `getRunAuditEvents` off the scoped store as a bare function reference and calling it without `this`, which made `this.db.prepare(...)` throw "Cannot read properties of undefined (reading 'db')" on every request. The `useMergeAdvanceNotice` hook caught the failure silently (`catch { setEvents([]) }`), so the banner never appeared even after the merger advanced the integration branch ref.
Fix: keep the store reference and call `storeWithRunAudit.getRunAuditEvents(...)` as a method so `this` is preserved, matching the pattern used by other routes that read run-audit events.

View File

@@ -518,19 +518,19 @@ export function registerTaskWorkflowRoutes(ctx: ApiRoutesContext, deps: TaskWork
try {
const { store: scopedStore } = await getProjectContext(req);
const limit = parseMergeAdvanceLimit(req.query.limit);
const getRunAuditEvents = (scopedStore as TaskStore & {
const storeWithRunAudit = scopedStore as TaskStore & {
getRunAuditEvents?: (filters: {
taskId?: string;
domain?: "database" | "git" | "filesystem" | "sandbox";
mutationType?: string;
limit?: number;
}) => RunAuditEvent[];
}).getRunAuditEvents;
if (typeof getRunAuditEvents !== "function") {
};
if (typeof storeWithRunAudit.getRunAuditEvents !== "function") {
throw notFound("run-audit unavailable");
}
const advanceEvents = getRunAuditEvents({
const advanceEvents = storeWithRunAudit.getRunAuditEvents({
domain: "git",
mutationType: "merge:integration-ref-advance",
limit,
@@ -544,7 +544,7 @@ export function registerTaskWorkflowRoutes(ctx: ApiRoutesContext, deps: TaskWork
}
let userCheckout: MergeAdvanceEvent["userCheckout"] = null;
const stateEvents = getRunAuditEvents({
const stateEvents = storeWithRunAudit.getRunAuditEvents({
taskId: extracted.taskId,
domain: "git",
mutationType: "merge:integration-worktree-state",