Skip to content

Commit 8f55af8

Browse files
committed
fix(cloud): expose persistence truncation
1 parent 062dc54 commit 8f55af8

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/chrome/src/cloud-runs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ function cloudSnapshot(run, { includeUpdates = true } = {}) {
103103
task: run.task,
104104
structured: run.structured ?? !!run.outputSchema,
105105
result: run.result,
106+
persistenceTruncated: run.persistenceTruncated,
106107
summary: run.summary,
107108
content: run.content,
108109
finalUrl: run.finalUrl,

test/run.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4258,6 +4258,45 @@ test('cloud run persistence caps oversized strings, runs, and total snapshot byt
42584258
assert.ok(!JSON.stringify(rows).includes(oversized), 'raw oversized strings must not reach storage.session');
42594259
});
42604260

4261+
test('cloud run status exposes persistence truncation after service-worker restart', async () => {
4262+
const oversized = 'x'.repeat(32 * 1024);
4263+
const [row] = buildCloudPersistenceRows([{
4264+
runId: 'run_truncated',
4265+
status: 'completed',
4266+
tabId: 7,
4267+
task: 'Return a large structured result',
4268+
outputSchema: { chunks: 'string[]' },
4269+
result: { chunks: Array.from({ length: 40 }, () => oversized) },
4270+
summary: 'Completed with a result too large to persist.',
4271+
content: '',
4272+
finalUrl: 'https://example.com/',
4273+
error: '',
4274+
updates: [],
4275+
createdAt: '2026-01-01T00:00:00.000Z',
4276+
updatedAt: '2026-01-01T00:01:00.000Z',
4277+
completedAt: '2026-01-01T00:01:00.000Z',
4278+
}]);
4279+
const session = { webbrainCloudRunSnapshots: [row] };
4280+
const controller = createCloudRunController({
4281+
chromeApi: {
4282+
tabs: {},
4283+
storage: {
4284+
local: { get: async () => ({}) },
4285+
session: { get: async key => ({ [key]: session[key] }), set: async value => Object.assign(session, value) },
4286+
},
4287+
runtime: { sendMessage: async () => ({}) },
4288+
},
4289+
agent: {},
4290+
ensureOffscreen: async () => {},
4291+
});
4292+
4293+
const restored = await controller.status({ runId: 'run_truncated' });
4294+
assert.equal(restored.status, 'completed');
4295+
assert.equal(restored.structured, true);
4296+
assert.equal(restored.result, undefined);
4297+
assert.equal(restored.persistenceTruncated?.omittedResult, true);
4298+
});
4299+
42614300
test('cloud bridge accepts only loopback WebSocket URLs', () => {
42624301
assert.equal(normalizeCloudBridgeUrl('ws://127.0.0.1:17373/extension'), 'ws://127.0.0.1:17373/extension');
42634302
assert.equal(normalizeCloudBridgeUrl('ws://localhost:17373/extension'), 'ws://localhost:17373/extension');

0 commit comments

Comments
 (0)