Skip to content
This repository was archived by the owner on Oct 10, 2026. It is now read-only.

Commit a8cd2ad

Browse files
t3dotggclaude
andauthored
fix(web): plans stop hijacking the UI, fold into chat instead (pingdotgg#5558)
Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 4a07c1c commit a8cd2ad

30 files changed

Lines changed: 619 additions & 768 deletions

‎apps/desktop/src/settings/DesktopClientSettings.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
1313
import * as DesktopClientSettings from "./DesktopClientSettings.ts";
1414

1515
const clientSettings: ClientSettings = {
16-
autoOpenPlanSidebar: false,
1716
confirmThreadArchive: true,
1817
confirmThreadDelete: false,
1918
dismissedProviderUpdateNotificationKeys: [],

‎apps/server/integration/OrchestrationEngineHarness.integration.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { OrchestrationEngineLive } from "../src/orchestration/Layers/Orchestrati
5151
import { OrchestrationProjectionPipelineLive } from "../src/orchestration/Layers/ProjectionPipeline.ts";
5252
import { OrchestrationProjectionSnapshotQueryLive } from "../src/orchestration/Layers/ProjectionSnapshotQuery.ts";
5353
import * as ThreadBackgroundLiveness from "../src/orchestration/ThreadBackgroundLiveness.ts";
54+
import * as ThreadPlanProgress from "../src/orchestration/ThreadPlanProgress.ts";
5455
import { RuntimeReceiptBusTest } from "../src/orchestration/Layers/RuntimeReceiptBus.ts";
5556
import { OrchestrationReactorLive } from "../src/orchestration/Layers/OrchestrationReactor.ts";
5657
import { ProviderCommandReactorLive } from "../src/orchestration/Layers/ProviderCommandReactor.ts";
@@ -310,7 +311,10 @@ export const makeOrchestrationIntegrationHarness = (
310311
checkpointStoreLayer,
311312
providerLayer,
312313
RuntimeReceiptBusTest,
313-
).pipe(Layer.provideMerge(ThreadBackgroundLiveness.layer));
314+
).pipe(
315+
Layer.provideMerge(ThreadBackgroundLiveness.layer),
316+
Layer.provideMerge(ThreadPlanProgress.layer),
317+
);
314318
const serverSettingsLayer = ServerSettingsService.layerTest();
315319
const runtimeIngestionLayer = ProviderRuntimeIngestionLive.pipe(
316320
Layer.provideMerge(runtimeServicesLayer),

‎apps/server/src/orchestration/Layers/CheckpointReactor.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
4040
import { OrchestrationProjectionPipelineLive } from "./ProjectionPipeline.ts";
4141
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
4242
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
43+
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
4344
import { RuntimeReceiptBusLive } from "./RuntimeReceiptBus.ts";
4445
import { OrchestrationEventStoreLive } from "../../persistence/Layers/OrchestrationEventStore.ts";
4546
import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts";
@@ -296,6 +297,7 @@ describe("CheckpointReactor", () => {
296297
const orchestrationLayer = OrchestrationEngineLive.pipe(
297298
Layer.provide(OrchestrationProjectionSnapshotQueryLive),
298299
Layer.provide(ThreadBackgroundLiveness.layer),
300+
Layer.provide(ThreadPlanProgress.layer),
299301
Layer.provide(OrchestrationProjectionPipelineLive),
300302
Layer.provide(OrchestrationEventStoreLive),
301303
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
@@ -304,6 +306,7 @@ describe("CheckpointReactor", () => {
304306
);
305307
const projectionSnapshotLayer = OrchestrationProjectionSnapshotQueryLive.pipe(
306308
Layer.provide(ThreadBackgroundLiveness.layer),
309+
Layer.provide(ThreadPlanProgress.layer),
307310
Layer.provide(RepositoryIdentityResolver.layer),
308311
Layer.provide(SqlitePersistenceMemory),
309312
);

‎apps/server/src/orchestration/Layers/OrchestrationEngine.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
3232
import { OrchestrationProjectionPipelineLive } from "./ProjectionPipeline.ts";
3333
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
3434
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
35+
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
3536
import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
3637
import {
3738
OrchestrationProjectionPipeline,
@@ -57,6 +58,7 @@ async function createOrchestrationSystem() {
5758
OrchestrationProjectionSnapshotQueryLive,
5859
).pipe(
5960
Layer.provide(ThreadBackgroundLiveness.layer),
61+
Layer.provide(ThreadPlanProgress.layer),
6062
Layer.provide(OrchestrationEventStoreLive),
6163
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
6264
Layer.provide(RepositoryIdentityResolver.layer),
@@ -820,6 +822,7 @@ describe("OrchestrationEngine", () => {
820822
OrchestrationEngineLive.pipe(
821823
Layer.provide(OrchestrationProjectionSnapshotQueryLive),
822824
Layer.provide(ThreadBackgroundLiveness.layer),
825+
Layer.provide(ThreadPlanProgress.layer),
823826
Layer.provide(OrchestrationProjectionPipelineLive),
824827
Layer.provide(Layer.succeed(OrchestrationEventStore, flakyStore)),
825828
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
@@ -926,6 +929,7 @@ describe("OrchestrationEngine", () => {
926929
OrchestrationEngineLive.pipe(
927930
Layer.provide(OrchestrationProjectionSnapshotQueryLive),
928931
Layer.provide(ThreadBackgroundLiveness.layer),
932+
Layer.provide(ThreadPlanProgress.layer),
929933
Layer.provide(Layer.succeed(OrchestrationProjectionPipeline, flakyProjectionPipeline)),
930934
Layer.provide(OrchestrationEventStoreLive),
931935
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
@@ -1070,6 +1074,7 @@ describe("OrchestrationEngine", () => {
10701074
OrchestrationEngineLive.pipe(
10711075
Layer.provide(OrchestrationProjectionSnapshotQueryLive),
10721076
Layer.provide(ThreadBackgroundLiveness.layer),
1077+
Layer.provide(ThreadPlanProgress.layer),
10731078
Layer.provide(Layer.succeed(OrchestrationProjectionPipeline, flakyProjectionPipeline)),
10741079
Layer.provide(Layer.succeed(OrchestrationEventStore, nonTransactionalStore)),
10751080
Layer.provide(OrchestrationCommandReceiptRepositoryLive),

‎apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
} from "./ProjectionPipeline.ts";
3333
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
3434
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
35+
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
3536
import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
3637
import { OrchestrationProjectionPipeline } from "../Services/ProjectionPipeline.ts";
3738
import { ServerConfig } from "../../config.ts";
@@ -2673,6 +2674,7 @@ const engineLayer = it.layer(
26732674
OrchestrationEngineLive.pipe(
26742675
Layer.provide(OrchestrationProjectionSnapshotQueryLive),
26752676
Layer.provide(ThreadBackgroundLiveness.layer),
2677+
Layer.provide(ThreadPlanProgress.layer),
26762678
Layer.provide(OrchestrationProjectionPipelineLive),
26772679
Layer.provide(OrchestrationEventStoreLive),
26782680
Layer.provide(OrchestrationCommandReceiptRepositoryLive),

‎apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as RepositoryIdentityResolver from "../../project/RepositoryIdentityRes
1818
import { ORCHESTRATION_PROJECTOR_NAMES } from "./ProjectionPipeline.ts";
1919
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
2020
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
21+
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
2122
import { ProjectionSnapshotQuery } from "../Services/ProjectionSnapshotQuery.ts";
2223
import { encodeThreadDetailPageCursor } from "../threadDetailCursor.ts";
2324

@@ -30,6 +31,7 @@ const asCheckpointRef = (value: string): CheckpointRef => CheckpointRef.make(val
3031
const projectionSnapshotLayer = it.layer(
3132
OrchestrationProjectionSnapshotQueryLive.pipe(
3233
Layer.provide(ThreadBackgroundLiveness.layer),
34+
Layer.provide(ThreadPlanProgress.layer),
3335
Layer.provideMerge(RepositoryIdentityResolver.layer),
3436
Layer.provideMerge(SqlitePersistenceMemory),
3537
Layer.provideMerge(NodeServices.layer),
@@ -447,6 +449,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
447449
hasPendingUserInput: false,
448450
hasActionableProposedPlan: false,
449451
backgroundLiveness: null,
452+
planProgress: null,
450453
},
451454
]);
452455

@@ -1830,6 +1833,7 @@ it.effect(
18301833
const resolveCalls: string[] = [];
18311834
const layer = OrchestrationProjectionSnapshotQueryLive.pipe(
18321835
Layer.provide(ThreadBackgroundLiveness.layer),
1836+
Layer.provide(ThreadPlanProgress.layer),
18331837
Layer.provideMerge(
18341838
Layer.succeed(RepositoryIdentityResolver.RepositoryIdentityResolver, {
18351839
resolve: (cwd: string) =>

‎apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
} from "../../persistence/Errors.ts";
4545
import { ProjectionCheckpoint } from "../../persistence/Services/ProjectionCheckpoints.ts";
4646
import { ThreadBackgroundLivenessService } from "../ThreadBackgroundLiveness.ts";
47+
import { ThreadPlanProgressService } from "../ThreadPlanProgress.ts";
4748
import { ProjectionProject } from "../../persistence/Services/ProjectionProjects.ts";
4849
import { ProjectionState } from "../../persistence/Services/ProjectionState.ts";
4950
import { ProjectionThreadActivity } from "../../persistence/Services/ProjectionThreadActivities.ts";
@@ -344,6 +345,7 @@ function toPersistenceSqlOrDecodeError(sqlOperation: string, decodeOperation: st
344345

345346
const makeProjectionSnapshotQuery = Effect.gen(function* () {
346347
const threadBackgroundLiveness = yield* ThreadBackgroundLivenessService;
348+
const threadPlanProgress = yield* ThreadPlanProgressService;
347349
const sql = yield* SqlClient.SqlClient;
348350
const repositoryIdentityResolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
349351
const repositoryIdentityResolutionConcurrency = 4;
@@ -1908,6 +1910,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
19081910
backgroundLiveness: threadBackgroundLiveness.getThreadBackgroundLiveness(
19091911
row.threadId,
19101912
),
1913+
planProgress: threadPlanProgress.getThreadPlanProgress(row.threadId),
19111914
} satisfies OrchestrationThreadShell)
19121915
: Result.failVoid,
19131916
),
@@ -2051,6 +2054,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
20512054
backgroundLiveness: threadBackgroundLiveness.getThreadBackgroundLiveness(
20522055
row.threadId,
20532056
),
2057+
planProgress: threadPlanProgress.getThreadPlanProgress(row.threadId),
20542058
}),
20552059
),
20562060
updatedAt: updatedAt ?? "1970-01-01T00:00:00.000Z",
@@ -2326,6 +2330,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
23262330
backgroundLiveness: threadBackgroundLiveness.getThreadBackgroundLiveness(
23272331
threadRow.value.threadId,
23282332
),
2333+
planProgress: threadPlanProgress.getThreadPlanProgress(threadRow.value.threadId),
23292334
} satisfies OrchestrationThreadShell);
23302335
});
23312336

‎apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
4949
import { OrchestrationProjectionPipelineLive } from "./ProjectionPipeline.ts";
5050
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
5151
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
52+
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
5253
import {
5354
providerErrorLabel,
5455
providerErrorLabelFromInstanceHint,
@@ -347,6 +348,7 @@ describe("ProviderCommandReactor", () => {
347348
const orchestrationLayer = OrchestrationEngineLive.pipe(
348349
Layer.provide(OrchestrationProjectionSnapshotQueryLive),
349350
Layer.provide(ThreadBackgroundLiveness.layer),
351+
Layer.provide(ThreadPlanProgress.layer),
350352
Layer.provide(OrchestrationProjectionPipelineLive),
351353
Layer.provide(OrchestrationEventStoreLive),
352354
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
@@ -355,6 +357,7 @@ describe("ProviderCommandReactor", () => {
355357
);
356358
const projectionSnapshotLayer = OrchestrationProjectionSnapshotQueryLive.pipe(
357359
Layer.provide(ThreadBackgroundLiveness.layer),
360+
Layer.provide(ThreadPlanProgress.layer),
358361
Layer.provide(RepositoryIdentityResolver.layer),
359362
Layer.provide(SqlitePersistenceMemory),
360363
);

‎apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
4545
import { OrchestrationProjectionPipelineLive } from "./ProjectionPipeline.ts";
4646
import { OrchestrationProjectionSnapshotQueryLive } from "./ProjectionSnapshotQuery.ts";
4747
import * as ThreadBackgroundLiveness from "../ThreadBackgroundLiveness.ts";
48+
import * as ThreadPlanProgress from "../ThreadPlanProgress.ts";
4849
import { ProviderRuntimeIngestionLive } from "./ProviderRuntimeIngestion.ts";
4950
import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
5051
import { ProviderRuntimeIngestionService } from "../Services/ProviderRuntimeIngestion.ts";
@@ -241,6 +242,7 @@ describe("ProviderRuntimeIngestion", () => {
241242
// Single shared liveness instance across ingestion (writer), the
242243
// engine, and the snapshot query (reader).
243244
Layer.provideMerge(ThreadBackgroundLiveness.layer),
245+
Layer.provideMerge(ThreadPlanProgress.layer),
244246
Layer.provideMerge(SqlitePersistenceMemory),
245247
Layer.provideMerge(Layer.succeed(ProviderService, provider.service)),
246248
Layer.provideMerge(makeTestServerSettingsLayer(options?.serverSettings)),

‎apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { ProjectionTurnRepositoryLive } from "../../persistence/Layers/Projectio
3535
import { isGitRepository } from "../../git/Utils.ts";
3636
import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
3737
import { ThreadBackgroundLivenessService } from "../ThreadBackgroundLiveness.ts";
38+
import { ThreadPlanProgressService } from "../ThreadPlanProgress.ts";
3839
import { ProjectionSnapshotQuery } from "../Services/ProjectionSnapshotQuery.ts";
3940
import {
4041
ProviderRuntimeIngestionService,
@@ -867,6 +868,7 @@ export function runtimeEventToActivities(
867868

868869
const make = Effect.gen(function* () {
869870
const threadBackgroundLiveness = yield* ThreadBackgroundLivenessService;
871+
const threadPlanProgress = yield* ThreadPlanProgressService;
870872
const crypto = yield* Crypto.Crypto;
871873
const orchestrationEngine = yield* OrchestrationEngineService;
872874
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
@@ -1935,6 +1937,21 @@ const make = Effect.gen(function* () {
19351937
yield* rememberTaskDescription(thread.id, event.payload.taskId, description);
19361938
}
19371939
}
1940+
// Working-indicator plan progress: current step while the turn runs,
1941+
// cleared on settle so a finished plan never lingers as stale UI.
1942+
// Events carrying a turn id that conflicts with the active turn are
1943+
// stale (superseded turn) and must neither overwrite nor clear the
1944+
// active turn's progress; session.exited always clears.
1945+
if (event.type === "session.exited") {
1946+
threadPlanProgress.clearThreadPlanProgress(thread.id);
1947+
} else if (!conflictsWithActiveTurn) {
1948+
if (event.type === "turn.plan.updated") {
1949+
threadPlanProgress.recordPlanProgress(thread.id, event.payload.plan);
1950+
} else if (event.type === "turn.completed" || event.type === "turn.aborted") {
1951+
threadPlanProgress.clearThreadPlanProgress(thread.id);
1952+
}
1953+
}
1954+
19381955
// Sidebar background liveness: fed from the same lifecycle stream,
19391956
// read by the shell query at mapping time (no persistence).
19401957
switch (event.type) {

0 commit comments

Comments
 (0)