gestalt-mobile 0.65.5 → 0.65.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
16
16
  <link rel="icon" href="/icons/gestalt-mobile-192.png" />
17
17
  <link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
18
18
  <title>Gestalt Mobile</title>
19
- <script type="module" crossorigin src="/assets/index-CohraBWu.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-CKJWzSwH.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-VDRT2Esv.css">
21
21
  </head>
22
22
  <body>
@@ -387,6 +387,7 @@ export function acceptSnapshot(current, snapshot) {
387
387
  if (prior?.state === 'resolved')
388
388
  return {
389
389
  ...prior,
390
+ ...(next.occurredAt !== undefined ? { occurredAt: next.occurredAt } : {}),
390
391
  ...(next.resolvedAt !== undefined ? { resolvedAt: next.resolvedAt } : {}),
391
392
  };
392
393
  return {
@@ -4943,6 +4943,104 @@ describe('production composition', () => {
4943
4943
  });
4944
4944
  });
4945
4945
  describeCompositionConcern('attention', () => {
4946
+ it('coalesces concurrent attention guidance and rejects a competing operation before replaying settlement', async () => {
4947
+ const fixture = await createProductionAutopilotFixture({
4948
+ autopilotSchedule: () => () => { },
4949
+ });
4950
+ const handle = fixture.handles.find((candidate) => candidate.request);
4951
+ let releaseGuidance;
4952
+ const guidanceGate = new Promise((resolve) => {
4953
+ releaseGuidance = resolve;
4954
+ });
4955
+ let guidanceStarted = false;
4956
+ handle.respond = async (method) => {
4957
+ if (method !== 'turn/start')
4958
+ return;
4959
+ guidanceStarted = true;
4960
+ await guidanceGate;
4961
+ return { turn: { id: 'attention-guidance-turn' } };
4962
+ };
4963
+ const submit = (operationKey) => Promise.resolve(fixture.app.inject({
4964
+ method: 'POST',
4965
+ url: `/api/sessions/${fixture.sessionId}/attention/690/resolve`,
4966
+ payload: { operationKey, action: 'resume', guidance: 'Continue the bounded task.' },
4967
+ }));
4968
+ const resolutions = [];
4969
+ try {
4970
+ await expect(handle.request(attentionCall(690))).resolves.toEqual(toOrgPlanAttentionAcknowledgement());
4971
+ resolutions.push(submit('shared-guidance'));
4972
+ await vi.waitFor(() => expect(guidanceStarted).toBe(true));
4973
+ resolutions.push(submit('shared-guidance'));
4974
+ const competing = await submit('competing-guidance');
4975
+ expect(competing.statusCode).toBe(409);
4976
+ expect(competing.json()).toEqual({ code: 'ATTENTION_OPERATION_STALE' });
4977
+ expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}/attention`)).json()).toMatchObject({ requestId: '690' });
4978
+ releaseGuidance();
4979
+ const [first, duplicate] = await Promise.all(resolutions);
4980
+ expect(first.statusCode).toBe(202);
4981
+ expect(duplicate.statusCode).toBe(202);
4982
+ expect(duplicate.json()).toEqual(first.json());
4983
+ expect(first.json()).toMatchObject({ accepted: true, replayed: false });
4984
+ const replay = await submit('shared-guidance');
4985
+ expect(replay.statusCode).toBe(202);
4986
+ expect(replay.json()).toEqual({ ...first.json(), replayed: true });
4987
+ const delivered = handle.requests.filter((request) => request.method === 'turn/start');
4988
+ expect(delivered).toHaveLength(1);
4989
+ expect(JSON.stringify(delivered[0].params)).toContain('Continue the bounded task.');
4990
+ const history = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}/history`)).json();
4991
+ expect(history.interactions.filter((item) => item.requestId === '690')).toEqual([
4992
+ expect.objectContaining({ outcome: 'answered', resolvedAt: first.json().resolvedAt }),
4993
+ ]);
4994
+ }
4995
+ finally {
4996
+ releaseGuidance();
4997
+ await Promise.allSettled(resolutions);
4998
+ await fixture.app.close();
4999
+ expect(handle.pendingResponses.size).toBe(0);
5000
+ }
5001
+ });
5002
+ it.each(['response settlement', 'relay shutdown'])('cancels the attention acknowledgement deadline after %s while retaining durable attention', async (boundary) => {
5003
+ const fixture = await createProductionAutopilotFixture({
5004
+ attentionAcknowledgementDeadlineMs: 300,
5005
+ autopilotSchedule: () => () => { },
5006
+ });
5007
+ const handle = fixture.handles.find((candidate) => candidate.request);
5008
+ handle.deferResponseSettlement = true;
5009
+ const response = handle.request(attentionCall(692));
5010
+ void response.catch(() => { });
5011
+ try {
5012
+ await vi.waitFor(() => expect(handle.pendingResponses.has(692)).toBe(true));
5013
+ const writersBefore = fixture.handles.length;
5014
+ if (boundary === 'response settlement') {
5015
+ handle.responseSettled({ id: 692, outcome: 'resultWritten' });
5016
+ await expect(response).resolves.toEqual(toOrgPlanAttentionAcknowledgement());
5017
+ }
5018
+ else {
5019
+ await fixture.app.close();
5020
+ await expect(response).rejects.toThrow('CODEX_SERVER_REQUEST_CANCELLED');
5021
+ }
5022
+ await new Promise((resolve) => setTimeout(resolve, 400));
5023
+ expect(fixture.handles).toHaveLength(writersBefore);
5024
+ const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
5025
+ try {
5026
+ expect(database
5027
+ .prepare('SELECT resolution_state, resolved_at, outcome FROM pending_interactions WHERE session_id = ? AND request_id = ?')
5028
+ .get(fixture.sessionId, '692')).toMatchObject({
5029
+ resolution_state: 'acknowledged',
5030
+ resolved_at: null,
5031
+ outcome: null,
5032
+ });
5033
+ }
5034
+ finally {
5035
+ database.close();
5036
+ }
5037
+ }
5038
+ finally {
5039
+ await fixture.app.close();
5040
+ await Promise.allSettled([response]);
5041
+ expect(handle.pendingResponses.size).toBe(0);
5042
+ }
5043
+ });
4946
5044
  it('includes the same blocked root turn explanation in attention and session reloads', async () => {
4947
5045
  const timers = [];
4948
5046
  const fixture = await createProductionAutopilotFixture({