gestalt-mobile 0.73.0 → 0.74.0

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,8 +16,8 @@ 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-C5YNh-JV.js"></script>
20
- <link rel="stylesheet" crossorigin href="/assets/index-EYPvWfrJ.css">
19
+ <script type="module" crossorigin src="/assets/index-YgsHeAim.js"></script>
20
+ <link rel="stylesheet" crossorigin href="/assets/index-B7ZFxnEl.css">
21
21
  </head>
22
22
  <body>
23
23
  <div id="app"></div>
@@ -481,6 +481,7 @@ async function orgPlanActivationFixture(installedCodexVersion = 'codex-cli 0.144
481
481
  const controls = {
482
482
  failInitialize: false,
483
483
  failThread: false,
484
+ threadBusy: false,
484
485
  initializationGate: null,
485
486
  threadGate: null,
486
487
  catalogGate: null,
@@ -540,6 +541,14 @@ async function orgPlanActivationFixture(installedCodexVersion = 'codex-cli 0.144
540
541
  throw new Error('INJECTED_THREAD_RECEIPT_LOSS');
541
542
  }
542
543
  }
544
+ if (method === 'thread/read' && controls.threadBusy) {
545
+ return {
546
+ thread: {
547
+ id: params.threadId,
548
+ status: { type: 'active' },
549
+ },
550
+ };
551
+ }
543
552
  if (method === 'skills/list') {
544
553
  const gate = !runtime && controls.catalogGate;
545
554
  if (gate) {
@@ -6394,16 +6403,66 @@ describe('production composition', () => {
6394
6403
  const launch = (await app.inject({ method: 'POST', url: '/api/plans/execute', payload })).json();
6395
6404
  expect(launch).toMatchObject({
6396
6405
  kind: 'blocked',
6397
- code: 'ACTIVE_SUPERVISION',
6406
+ code: 'WORKSPACE_BUSY',
6398
6407
  existingSessionId: id,
6399
6408
  });
6400
- expect(launch.reason).toContain('Stop its work');
6409
+ expect(launch.reason).toContain('idle');
6401
6410
  expect((await app.inject('/api/sessions')).json()).toHaveLength(1);
6402
6411
  }
6403
6412
  finally {
6404
6413
  await app.close();
6405
6414
  }
6406
6415
  });
6416
+ it('rechecks the confirmed session before replacement and keeps its saved thread', async () => {
6417
+ const f = await orgPlanActivationFixture('codex-cli 0.167.0');
6418
+ const app = await f.open();
6419
+ try {
6420
+ const id = await createComposedSession(app);
6421
+ const { threadId } = (await app.inject(`/api/sessions/${id}`)).json();
6422
+ const payload = await f.prepare(app);
6423
+ const reference = {
6424
+ kind: 'session',
6425
+ sessionId: id,
6426
+ planName: payload.reference.planName,
6427
+ };
6428
+ const prepare = async () => (await app.inject({
6429
+ method: 'POST',
6430
+ url: '/api/plans/prepare',
6431
+ payload: { ...reference, expectedRevision: payload.expectedRevision },
6432
+ })).json();
6433
+ await expect.poll(prepare).toMatchObject({
6434
+ kind: 'eligible',
6435
+ workspaceSession: { sessionId: id, replaceAllowed: true },
6436
+ });
6437
+ const execute = async () => (await app.inject({
6438
+ method: 'POST',
6439
+ url: '/api/plans/execute',
6440
+ payload: { ...payload, reference, replaceSessionId: id },
6441
+ })).json();
6442
+ // Simulate provider work beginning after the user saw the idle status.
6443
+ f.controls.threadBusy = true;
6444
+ expect(await execute()).toMatchObject({
6445
+ kind: 'blocked',
6446
+ code: 'WORKSPACE_BUSY',
6447
+ existingSessionId: id,
6448
+ });
6449
+ expect((await app.inject(`/api/sessions/${id}`)).json()).toMatchObject({
6450
+ state: 'ready',
6451
+ threadId,
6452
+ });
6453
+ expect(f.requests('thread/start')).toHaveLength(1);
6454
+ f.controls.threadBusy = false;
6455
+ expect(await execute()).toMatchObject({ kind: 'started', bootstrap: { kind: 'accepted' } });
6456
+ expect((await app.inject(`/api/sessions/${id}`)).json()).toMatchObject({
6457
+ state: 'released',
6458
+ threadId,
6459
+ });
6460
+ expect(f.requests('thread/start')).toHaveLength(2);
6461
+ }
6462
+ finally {
6463
+ await app.close();
6464
+ }
6465
+ });
6407
6466
  it('executes a validated plan on Codex 0.167.0 with supervision instructions and exclusive workspace ownership', async () => {
6408
6467
  const f = await orgPlanActivationFixture('codex-cli 0.167.0');
6409
6468
  const app = await f.open();
@@ -57,7 +57,7 @@ import { SqliteAuthorizationStore } from './platform/auth/sqlite-authorization-s
57
57
  import { SimpleWebAuthnAdapter } from './platform/auth/simple-webauthn-adapter.js';
58
58
  import { authorizationSessionId, authorizedDeviceId } from './features/auth/domain/identifiers.js';
59
59
  import { SqliteSessionRepository } from './platform/persistence/sqlite-session-repository.js';
60
- import { SqliteWorkspaceLifecycle } from './platform/persistence/sqlite-workspace-lifecycle.js';
60
+ import { canonicalSessionWorkspace, SqliteWorkspaceLifecycle, } from './platform/persistence/sqlite-workspace-lifecycle.js';
61
61
  import { FilesystemWorkspaceForget } from './platform/scratch/filesystem-workspace-forget.js';
62
62
  import { SqliteEventJournal } from './platform/persistence/sqlite-event-journal.js';
63
63
  import { SqlitePendingInteractionStore } from './platform/persistence/sqlite-pending-interaction-store.js';
@@ -169,7 +169,11 @@ export async function composeRelayApp(options) {
169
169
  const orgPlanLaunches = new SqliteOrgPlanLaunchStore(database);
170
170
  // Admission spans asynchronous provider calls so Execute cannot reserve a workspace mid-start.
171
171
  const workspaceAdmissions = new Map();
172
+ const replacingWorkspaceSessions = new Map();
172
173
  const assertWorkspaceOwner = (session) => {
174
+ if (replacingWorkspaceSessions.size &&
175
+ replacingWorkspaceSessions.has(canonicalSessionWorkspace(session.workspacePath)))
176
+ throw new WriterAcquisitionError('workspaceLocked');
173
177
  let owner = orgPlanLaunches.workspaceOwner(session.workspacePath);
174
178
  while (owner &&
175
179
  forgetOperations.find(owner.sessionId)?.phase === 'completed' &&
@@ -1915,18 +1919,19 @@ export async function composeRelayApp(options) {
1915
1919
  const reclaimableLaunchOwner = (record) => forgetOperations.find(record.sessionId)?.phase === 'completed' &&
1916
1920
  !sessions.find(record.sessionId) &&
1917
1921
  !runtime?.ownsWriter(record.sessionId);
1918
- const workspaceBusy = (workspacePath) => {
1922
+ const sessionHasWorkspaceWork = (session, snapshot = activity.snapshot(session.id, new Date().toISOString())) => Boolean(session.activeTurnId ||
1923
+ pendingRootTurn(session.id) ||
1924
+ workspaceAdmissions.has(session.id) ||
1925
+ orgPlanStarting.has(session.id) ||
1926
+ snapshot.subagents.some((agent) => ['working', 'awaitingAgent'].includes(agent.state) ||
1927
+ agent.ownedProcesses?.some((process) => ['running', 'detached-active'].includes(process.state))));
1928
+ const workspaceBusy = (workspacePath, skipExact = false) => {
1919
1929
  const session = sessions.list().find((session) => {
1920
1930
  if (!within(workspacePath, session.workspacePath) &&
1921
1931
  !within(session.workspacePath, workspacePath))
1922
1932
  return false;
1923
- const snapshot = activity.snapshot(session.id, new Date().toISOString());
1924
- return Boolean(session.activeTurnId ||
1925
- pendingRootTurn(session.id) ||
1926
- workspaceAdmissions.has(session.id) ||
1927
- orgPlanStarting.has(session.id) ||
1928
- snapshot.subagents.some((agent) => ['working', 'awaitingAgent'].includes(agent.state) ||
1929
- agent.ownedProcesses?.some((process) => ['running', 'detached-active'].includes(process.state))));
1933
+ return ((!skipExact || canonicalSessionWorkspace(session.workspacePath) !== workspacePath) &&
1934
+ sessionHasWorkspaceWork(session));
1930
1935
  });
1931
1936
  return session
1932
1937
  ? {
@@ -1935,8 +1940,110 @@ export async function composeRelayApp(options) {
1935
1940
  }
1936
1941
  : null;
1937
1942
  };
1943
+ const workspaceSession = (workspacePath) => {
1944
+ const replacing = replacingWorkspaceSessions.get(workspacePath);
1945
+ if (replacing)
1946
+ return {
1947
+ sessionId: replacing.sessionId,
1948
+ replaceAllowed: !replacing.closing,
1949
+ retryClose: true,
1950
+ };
1951
+ const session = sessions
1952
+ .list()
1953
+ .find((candidate) => candidate.desiredState === 'active' &&
1954
+ !['stopped', 'released'].includes(candidate.state) &&
1955
+ canonicalSessionWorkspace(candidate.workspacePath) === workspacePath);
1956
+ if (!session)
1957
+ return null;
1958
+ const snapshot = activity.snapshot(session.id, new Date().toISOString());
1959
+ const automatic = autopilot.snapshot(session.id);
1960
+ return {
1961
+ sessionId: session.id,
1962
+ replaceAllowed: session.state === 'ready' &&
1963
+ snapshot.confidence === 'fresh' &&
1964
+ snapshot.root.state === 'idle' &&
1965
+ !sessionHasWorkspaceWork(session, snapshot) &&
1966
+ !session.pendingInteractions?.length &&
1967
+ !blockingInteractions(session.id).length &&
1968
+ automatic?.state !== 'attentionRequired' &&
1969
+ !automatic?.health?.healthy &&
1970
+ !forgetOperations.find(session.id) &&
1971
+ !hostTests?.supervisionSummary(session.id).running,
1972
+ };
1973
+ };
1974
+ const releaseSessionSnapshot = (session) => {
1975
+ providerRecovery.cancel(session.id);
1976
+ autopilot.cancel(session.id, 'sessionEnded');
1977
+ return RelaySession.rehydrate(session).release(new Date().toISOString()).snapshot;
1978
+ };
1979
+ const closeReleasedSession = async (id) => {
1980
+ providerRecovery.cancel(id);
1981
+ autopilot.cancel(id, 'sessionEnded');
1982
+ await hostTests?.cancelSession(id);
1983
+ planMeasurementRefresh?.stop(id);
1984
+ dismissPendingInteractions(id, new Date().toISOString());
1985
+ activity.dispose(id);
1986
+ const session = sessions.find(id);
1987
+ const owner = session ? ownerRuntime(session) : null;
1988
+ if (session && owner)
1989
+ await owner.releaseForForget(session);
1990
+ await playwright.waitForRelease(id);
1991
+ const current = sessions.find(id);
1992
+ if (current?.desiredState === 'stopped' && ['stopped', 'released'].includes(current.state)) {
1993
+ orgPlanLaunches.releaseSession(id);
1994
+ takeoverStore.releaseSession(id);
1995
+ if (replacingWorkspaceSessions.size) {
1996
+ const workspacePath = canonicalSessionWorkspace(current.workspacePath);
1997
+ if (replacingWorkspaceSessions.get(workspacePath)?.sessionId === id)
1998
+ replacingWorkspaceSessions.delete(workspacePath);
1999
+ }
2000
+ }
2001
+ };
2002
+ const replaceIdleSession = async (workspacePath, id) => {
2003
+ const initial = workspaceSession(workspacePath);
2004
+ if (initial?.sessionId !== id || !initial.replaceAllowed)
2005
+ return false;
2006
+ if (!initial.retryClose)
2007
+ await activity.refresh(id);
2008
+ const occupant = workspaceSession(workspacePath);
2009
+ const session = sessions.find(id);
2010
+ if (!session ||
2011
+ forgetOperations.find(id) ||
2012
+ workspaceBusy(workspacePath, true) ||
2013
+ occupant?.sessionId !== id ||
2014
+ !occupant.replaceAllowed)
2015
+ return false;
2016
+ // Recheck and mark the saved session as released before yielding to provider teardown.
2017
+ const replacement = { sessionId: id, closing: true };
2018
+ replacingWorkspaceSessions.set(workspacePath, replacement);
2019
+ try {
2020
+ if (!occupant.retryClose)
2021
+ saveSession(releaseSessionSnapshot(session));
2022
+ await closeReleasedSession(id);
2023
+ return !replacingWorkspaceSessions.has(workspacePath);
2024
+ }
2025
+ catch {
2026
+ if (sessions.find(id)?.desiredState === 'active')
2027
+ replacingWorkspaceSessions.delete(workspacePath);
2028
+ return false;
2029
+ }
2030
+ finally {
2031
+ replacement.closing = false;
2032
+ }
2033
+ };
1938
2034
  const prepareOrgPlan = (reference, expectedRevision, skillProfile, ownUnpublishedLaunchId) => prepareOrgPlanSupervision(reference, {
1939
2035
  resolveReference: (ref) => orgPlanContext.resolveReference(ref),
2036
+ workspaceSession: async (workspacePath) => {
2037
+ const occupant = workspaceSession(workspacePath);
2038
+ if (expectedRevision &&
2039
+ occupant &&
2040
+ !occupant.replaceAllowed &&
2041
+ sessions.find(occupant.sessionId)?.state === 'ready') {
2042
+ await activity.refresh(occupant.sessionId);
2043
+ return workspaceSession(workspacePath);
2044
+ }
2045
+ return occupant;
2046
+ },
1940
2047
  workspace: (path, revision) => orgPlanContext.workspace(path, revision),
1941
2048
  read: (workspacePath, planName) => workspacePlanCatalog.readExecution(workspacePath, planName),
1942
2049
  runtimeAvailable: async () => protocol.compatible
@@ -1963,14 +2070,17 @@ export async function composeRelayApp(options) {
1963
2070
  !sessions.find(pending.sessionId) &&
1964
2071
  !runtime?.ownsWriter(pending.sessionId) &&
1965
2072
  ['reserved', 'creating'].includes(pending.phase);
2073
+ const busy = workspaceBusy(workspacePath, true);
2074
+ if (busy && busy.sessionId !== pending?.sessionId)
2075
+ return busy;
1966
2076
  if (pending && !reclaimableLaunchOwner(pending) && !ownUnpublished)
1967
2077
  return {
1968
2078
  ...(sessions.find(pending.sessionId) ? { sessionId: pending.sessionId } : {}),
2079
+ ...(pending.canonicalPath !== canonicalPath
2080
+ ? { workspaceConflict: true }
2081
+ : {}),
1969
2082
  reason: 'This plan or an overlapping workspace is reserved by another supervisor. Open its session to continue, or close it to release the reservation.',
1970
2083
  };
1971
- const busy = workspaceBusy(workspacePath);
1972
- if (busy && busy.sessionId !== pending?.sessionId)
1973
- return busy;
1974
2084
  const identity = createHash('sha256').update(canonicalPath).digest('hex');
1975
2085
  const owner = sessions.list().find((session) => {
1976
2086
  if (session.desiredState === 'stopped' &&
@@ -1991,6 +2101,7 @@ export async function composeRelayApp(options) {
1991
2101
  createId: randomUUID,
1992
2102
  launches: orgPlanLaunches,
1993
2103
  workspaceBusy,
2104
+ replaceIdleSession,
1994
2105
  reclaimForgottenOwner: (path, workspacePath) => {
1995
2106
  const record = orgPlanLaunches.owner(path);
1996
2107
  if (record && reclaimableLaunchOwner(record))
@@ -2379,11 +2490,7 @@ export async function composeRelayApp(options) {
2379
2490
  : recentThreads.executionPolicy(candidate.id),
2380
2491
  })
2381
2492
  : undefined,
2382
- release: (session) => {
2383
- providerRecovery.cancel(session.id);
2384
- autopilot.cancel(session.id, 'sessionEnded');
2385
- return RelaySession.rehydrate(session).release(new Date().toISOString()).snapshot;
2386
- },
2493
+ release: releaseSessionSnapshot,
2387
2494
  remove: (id) => {
2388
2495
  providerRecovery.cancel(id);
2389
2496
  autopilot.cancel(id, 'sessionEnded');
@@ -2391,27 +2498,7 @@ export async function composeRelayApp(options) {
2391
2498
  sessions.remove(id);
2392
2499
  },
2393
2500
  idempotency,
2394
- close: runtime || kimiRuntime
2395
- ? async (id) => {
2396
- providerRecovery.cancel(id);
2397
- autopilot.cancel(id, 'sessionEnded');
2398
- await hostTests?.cancelSession(id);
2399
- planMeasurementRefresh?.stop(id);
2400
- dismissPendingInteractions(id, new Date().toISOString());
2401
- activity.dispose(id);
2402
- const session = sessions.find(id);
2403
- const owner = session ? ownerRuntime(session) : null;
2404
- if (session && owner)
2405
- await owner.releaseForForget(session);
2406
- await playwright.waitForRelease(id);
2407
- const current = sessions.find(id);
2408
- if (current?.desiredState === 'stopped' &&
2409
- ['stopped', 'released'].includes(current.state)) {
2410
- orgPlanLaunches.releaseSession(id);
2411
- takeoverStore.releaseSession(id);
2412
- }
2413
- }
2414
- : undefined,
2501
+ close: runtime || kimiRuntime ? closeReleasedSession : undefined,
2415
2502
  replyInteraction: runtime || kimiRuntime
2416
2503
  ? async (sessionId, requestId, value) => {
2417
2504
  providerRecovery.cancel(sessionId);
@@ -2769,7 +2769,10 @@ export class AutopilotCoordinator {
2769
2769
  const executor = state && plan
2770
2770
  ? this.currentExecutor(sessionId, plan.plan, state.consecutiveNoProgress, state.executor)
2771
2771
  : undefined;
2772
- const fence = state && plan && !this.deps.session(sessionId)?.activeTurnId
2772
+ const fence = state &&
2773
+ plan &&
2774
+ !this.deps.session(sessionId)?.activeTurnId &&
2775
+ !this.deps.pendingTurn?.(sessionId)
2773
2776
  ? {
2774
2777
  generation: state.generation,
2775
2778
  identity: plan.identity,
@@ -2795,11 +2798,6 @@ export class AutopilotCoordinator {
2795
2798
  this.enqueue(sessionId, async () => {
2796
2799
  const current = this.deps.store.find(sessionId);
2797
2800
  const currentPlan = this.deps.plan(sessionId);
2798
- const currentChild = fence.executorThreadId
2799
- ? this.deps
2800
- .activity(sessionId)
2801
- ?.subagents.find((child) => (child.threadId ?? child.id) === fence.executorThreadId)
2802
- : null;
2803
2801
  if (!current?.requestedEnabled ||
2804
2802
  this.deps.pendingInteraction(sessionId) ||
2805
2803
  current.generation !== fence.generation ||
@@ -2810,13 +2808,20 @@ export class AutopilotCoordinator {
2810
2808
  !currentPlan ||
2811
2809
  fingerprint(currentPlan.plan) !== fence.fingerprint ||
2812
2810
  Boolean(this.deps.session(sessionId)?.activeTurnId) ||
2813
- (fence.executorThreadId !== null &&
2814
- (currentChild?.canonicalPosition !== fence.canonicalPosition ||
2815
- (currentChild.continuationGeneration ?? 1) !== fence.executorGeneration))) {
2811
+ this.deps.pendingTurn?.(sessionId)) {
2816
2812
  this.audit(sessionId, 'autopilot.executor-refresh-stale', { fence });
2817
2813
  return;
2818
2814
  }
2815
+ // Refresh restores evidence, not executor authority. A disconnected
2816
+ // roster may omit or replace the armed child; requiring that stale
2817
+ // identity here prevents the read that could recover it. Execution
2818
+ // is fenced independently against the refreshed state below.
2819
2819
  await this.deps.executorController?.refresh(sessionId);
2820
+ const refreshed = this.deps.store.find(sessionId);
2821
+ if (refreshed && this.decision(sessionId, refreshed).kind === 'reconcile') {
2822
+ this.evaluate(sessionId);
2823
+ return;
2824
+ }
2820
2825
  if (!(await this.enforceSupervisedLifecycle(sessionId, 'processObserved')))
2821
2826
  this.evaluate(sessionId);
2822
2827
  });
@@ -55,13 +55,18 @@ export async function prepareOrgPlanSupervision(reference, deps, expectedRevisio
55
55
  if (!policy.allowed)
56
56
  return blocked('MODEL_POLICY_UNAVAILABLE', policy.action);
57
57
  let owner;
58
+ let workspaceSession;
58
59
  try {
59
60
  owner = await deps.owner(file.canonicalPath, context.workspace.path);
61
+ workspaceSession = await deps.workspaceSession?.(context.workspace.path);
60
62
  }
61
63
  catch {
62
64
  return blocked('WORKSPACE_UNAVAILABLE', 'Plan and workspace ownership could not be verified. Refresh and retry.');
63
65
  }
64
- if (owner)
66
+ if (owner &&
67
+ (!owner.workspaceConflict ||
68
+ !workspaceSession ||
69
+ owner.sessionId !== workspaceSession.sessionId))
65
70
  return {
66
71
  kind: 'blocked',
67
72
  code: 'ACTIVE_SUPERVISION',
@@ -86,6 +91,7 @@ export async function prepareOrgPlanSupervision(reference, deps, expectedRevisio
86
91
  title: file.plan.title,
87
92
  sourcePath: file.canonicalPath,
88
93
  workspace: context.workspace,
94
+ ...(workspaceSession ? { workspaceSession } : {}),
89
95
  revision: context.revision,
90
96
  settings: settings.settings,
91
97
  skillProfiles: settings.skillProfiles,
@@ -25,6 +25,7 @@ export async function startOrgPlanSupervision(request, deps) {
25
25
  reference.kind === 'retained-session' ? null : reference.planName,
26
26
  input.expectedRevision,
27
27
  input.skillProfile ?? null,
28
+ ...(input.replaceSessionId ? [input.replaceSessionId] : []),
28
29
  ]))
29
30
  .digest('hex');
30
31
  let record = deps.launches.find(input.launchId);
@@ -36,12 +37,15 @@ export async function startOrgPlanSupervision(request, deps) {
36
37
  return conflict();
37
38
  }
38
39
  else {
39
- const context = await deps.prepare(reference, input.expectedRevision, input.skillProfile);
40
+ let context = await deps.prepare(reference, input.expectedRevision, input.skillProfile);
40
41
  if (context.kind === 'blocked') {
41
42
  // Another delivery can reserve/attach while this delivery is preparing.
42
43
  // Records are retained, so one bounded re-entry takes the replay path.
43
44
  return deps.launches.find(input.launchId) ? startOrgPlanSupervision(input, deps) : context;
44
45
  }
46
+ const occupant = context.workspaceSession;
47
+ if (occupant && (!occupant.replaceAllowed || occupant.sessionId !== input.replaceSessionId))
48
+ return replacementBlocked(occupant.sessionId);
45
49
  let skillSelection;
46
50
  try {
47
51
  skillSelection = await deps.captureSkills(context);
@@ -59,6 +63,15 @@ export async function startOrgPlanSupervision(request, deps) {
59
63
  code: 'GESTALT_CAPABILITIES_UNAVAILABLE',
60
64
  reason: 'The Org-plan skill changed before launch. Refresh and confirm again.',
61
65
  };
66
+ if (occupant) {
67
+ if (!(await deps.replaceIdleSession?.(context.workspace.path, occupant.sessionId)))
68
+ return replacementBlocked(occupant.sessionId);
69
+ context = await deps.prepare(reference, input.expectedRevision, input.skillProfile);
70
+ if (context.kind === 'blocked')
71
+ return context;
72
+ if (context.workspaceSession)
73
+ return replacementBlocked(context.workspaceSession.sessionId);
74
+ }
62
75
  deps.reclaimForgottenOwner?.(context.sourcePath, context.workspace.path);
63
76
  const busy = deps.workspaceBusy?.(context.workspace.path);
64
77
  if (busy)
@@ -106,6 +119,14 @@ export async function startOrgPlanSupervision(request, deps) {
106
119
  return continueLaunch(deps.launches.find(current.launchId) ?? current, deps);
107
120
  });
108
121
  }
122
+ function replacementBlocked(sessionId) {
123
+ return {
124
+ kind: 'blocked',
125
+ code: 'WORKSPACE_BUSY',
126
+ reason: 'Refresh the workspace session status and confirm replacement once it is idle.',
127
+ existingSessionId: sessionId,
128
+ };
129
+ }
109
130
  async function continueLaunch(record, deps) {
110
131
  if (deps.sessions.unavailable?.(record.sessionId))
111
132
  return unavailable();
@@ -255,8 +276,12 @@ export class OrgPlanSessionNotPublished extends Error {
255
276
  }
256
277
  async function revalidateUnpublished(input, record, deps) {
257
278
  const fresh = await deps.prepare(input.reference, input.expectedRevision, input.skillProfile, record.launchId);
258
- let blocked = fresh.kind === 'blocked' ? fresh : null;
259
- if (fresh.kind === 'eligible') {
279
+ let blocked = fresh.kind === 'blocked'
280
+ ? fresh
281
+ : fresh.workspaceSession
282
+ ? replacementBlocked(fresh.workspaceSession.sessionId)
283
+ : null;
284
+ if (fresh.kind === 'eligible' && !blocked) {
260
285
  try {
261
286
  const skills = await deps.captureSkills(fresh);
262
287
  if (fresh.sourcePath !== record.canonicalPath ||
@@ -16,6 +16,7 @@ export const orgPlanLaunchRequestSchema = z
16
16
  ]),
17
17
  expectedRevision: identity,
18
18
  skillProfile: z.string().max(256).optional(),
19
+ replaceSessionId: identity.optional(),
19
20
  launchId: z.string().min(1).max(256),
20
21
  })
21
22
  .strict();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.73.0",
3
+ "version": "0.74.0",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",