Skip to content

Commit c3f4ba8

Browse files
committed
refactor(webapp): drop the unused settleOpenInvestigations
Nothing calls it. It settles investigation rows in their own writes and leaves the caller to append the closing cards afterwards — the model that produced terminal rows whose card never landed, which the stale sweep no longer selects. Keeping a ready-made path back to that bug next to the atomic API is the whole risk. `settlementCardMessages()` and the `SettledInvestigationCard` type stay: the ordinary `persistTurn` path still uses both.
1 parent abaeebb commit c3f4ba8

1 file changed

Lines changed: 1 addition & 38 deletions

File tree

internal-packages/dashboard-agent/src/agent-runtime.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -169,50 +169,13 @@ export function clearOpenInvestigations(chatId: string): void {
169169
openInvestigations.delete(chatId);
170170
}
171171

172-
/** A revision the settle guard committed, and the card the transcript still needs. */
172+
/** A revision a settling write committed, and the card the transcript still needs. */
173173
export type SettledInvestigationCard = {
174174
investigationId: string;
175175
revision: number;
176176
state: unknown;
177177
};
178178

179-
/**
180-
* Force-settle whatever this turn left `in_progress`, as one more revision on
181-
* the same investigation. Best-effort: a failed settle must not fail a turn the
182-
* user already got an answer from, but it is logged.
183-
*
184-
* The settled revisions are returned because settling the row is only half of it:
185-
* the panel renders from the transcript, so the caller has to append these too.
186-
*/
187-
export async function settleOpenInvestigations(
188-
store: DashboardAgentStore,
189-
chatId: string
190-
): Promise<SettledInvestigationCard[]> {
191-
const open = openInvestigations.get(chatId);
192-
if (!open || open.size === 0) return [];
193-
openInvestigations.delete(chatId);
194-
195-
const settled: SettledInvestigationCard[] = [];
196-
for (const [id, entry] of open) {
197-
const state = forceSettledInvestigationState(entry.state);
198-
try {
199-
const result = await store.upsertInvestigationRevision({
200-
id,
201-
chatId,
202-
projectRef: entry.projectRef,
203-
environmentRef: entry.environmentRef,
204-
state,
205-
});
206-
if (result.ok) {
207-
settled.push({ investigationId: result.id, revision: result.revision, state });
208-
}
209-
} catch (error) {
210-
logger.error("Failed to settle an investigation left in progress", { chatId, id, error });
211-
}
212-
}
213-
return settled;
214-
}
215-
216179
/**
217180
* The settled cards as transcript messages, in the shape the panel's winning-revision
218181
* logic reads. A card that can't be rendered is logged and dropped rather than

0 commit comments

Comments
 (0)