mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 14:16:28 +03:00
All three new findings are the same root cause, and it is my incomplete fix:
operationFailure only covered results built from a *thrown* error. Two paths it
missed:
- Two catches wrote the failure result as a multi-line literal, so the
single-line replace skipped them. The Vue accept catch was still bare, exactly
as reported; the Svelte one too, though its failures happened to be caught by
completion.mjs's Svelte-only special case.
- The accept implementations also *return* `{handled: false, error}` for their own
checks (variant missing, template empty, original text ambiguous). Those never
throw, so no catch ran and no `mode` was set.
Both layers now agree, because each is reachable on its own:
- live-accept marks any unhandled preview-path result via markPreviewFailure,
keyed on `previewMode` — a clean discriminator, since only the preview branches
set it and a plain wrapper never does. This is what the agent reads:
reference/live.md routes on `mode`, so without it the agent was told "read
file, find markers, edit" for a preview that has no markers in source.
- completion.mjs replaces its arbitrary svelte-component special case with the
set of preview modes whose variants live outside the user's source. That case
existed for precisely this reason; Vue and source-artifact were simply never
added, so the identical failure on those paths acknowledged as success.
The plain wrapper keeps its manual handoff, which is the one shape with editable
markers in source. Both deliberate handoffs (mode: 'fallback' and markers not
found) still classify as agent_done, now pinned by a test so the generalization
cannot swallow them.
Prepared with AI assistance under maintainer direction.
Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
// A preview whose variants live outside the user's source: component modules or
|
|
// an isolated artifact. These keep the real file untouched until Accept, so a
|
|
// failed accept leaves nothing in source for the agent to hand-edit and must be
|
|
// reported as a failure rather than reference/live.md's manual-cleanup handoff.
|
|
// Previously only `svelte-component` was special-cased here, so the same failure
|
|
// on a Vue or isolated-artifact preview was acknowledged as a success.
|
|
const PREVIEW_MODES_WITHOUT_SOURCE_MARKERS = new Set([
|
|
'svelte-component',
|
|
'vue-component',
|
|
'source-artifact',
|
|
]);
|
|
|
|
export function completionTypeForAcceptResult(eventType, acceptResult) {
|
|
if (eventType === 'discard') return acceptResult?.handled === true ? 'discarded' : 'error';
|
|
if (acceptResult?.handled === true && acceptResult?.carbonize === true) return 'agent_done';
|
|
if (acceptResult?.handled === true) return 'complete';
|
|
if (acceptResult?.mode === 'error') return 'error';
|
|
if (eventType === 'accept' && PREVIEW_MODES_WITHOUT_SOURCE_MARKERS.has(acceptResult?.previewMode)) return 'error';
|
|
return 'agent_done';
|
|
}
|
|
|
|
export function completionAckForAcceptResult(eventId, completionType, acceptResult) {
|
|
const ack = { ok: true, type: completionType };
|
|
if (acceptResult?.handled === true && acceptResult?.carbonize === true) {
|
|
ack.final = false;
|
|
ack.requiresComplete = true;
|
|
ack.nextCommand = `live-complete.mjs --id ${eventId}`;
|
|
ack.message = 'Carbonize cleanup must be verified, then the session must be completed explicitly before polling again.';
|
|
}
|
|
return ack;
|
|
}
|