fix(orchestration): keep locator fields when stripping copies; never let the optional receipt page block remote release

This commit is contained in:
Jinwoo-H
2026-11-11 23:54:07 -05:00
parent d03d420739
commit dcddee3f85
2 changed files with 9 additions and 2 deletions
@@ -19,6 +19,9 @@ try {
"UPDATE worker_terminal_archives SET content = CASE WHEN json_valid(content) THEN json_patch('{\\"version\\":3}', json_object(" +
"'agent', json_extract(content, '$.agent'), " +
"'processIncarnation', json_extract(content, '$.processIncarnation'), " +
"'sessionId', json_extract(content, '$.sessionId'), " +
"'transcriptPath', json_extract(content, '$.transcriptPath'), " +
"'wslDistro', json_extract(content, '$.wslDistro'), " +
"'fallbackReason', json_extract(content, '$.fallbackReason'))) " +
"ELSE '{\\"version\\":3}' END WHERE dispatch_id = ? AND " + workerData.copyPredicate
);
@@ -35,12 +35,16 @@ export async function readRemoteAttachmentArchive(args: {
})
}
/** Release receipts carry the output only while its original is still readable. */
/** Release receipts carry the output only while its original is still readable and steady. */
export function readRemoteAttachmentOutputIfAvailable(
args: Parameters<typeof readRemoteAttachmentArchive>[0]
): ReturnType<typeof readRemoteAttachmentArchive> {
return readRemoteAttachmentArchive(args).catch((error: unknown) => {
if (error instanceof OrchestrationError && error.code === 'archive_unavailable') {
// A transcript written during the read only drops the optional page; it never blocks release.
if (
error instanceof OrchestrationError &&
(error.code === 'archive_unavailable' || error.code === 'source_changed')
) {
return null
}
throw error