GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): Stop ends a dev server left running before a provider switch by t3dotgg · Pull Request #15355 · pingdotgg/t3code

fix(server): Stop ends a dev server left running before a provider switch #15355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
t3dotgg merged 3 commits into main from t3code/fix-thread-stop-and-auto-settle
Oct 3, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(server): Stop ends a dev server left running before a provider switch #15355

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
79bda02
fix(server): Stop ends a dev server left by an earlier provider
t3dotgg Oct 3, 2026
8bfd33e
fix(server): settle every interrupted provider thread through its lat…
t3dotgg Oct 3, 2026
60b0dfe
fix(server): interrupt a provider thread through the turn that owns i…
t3dotgg Oct 3, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
fix(server): interrupt a provider thread through the turn that owns i…
…ts work

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@t3dotgg @claude
t3dotgg and claude committed Oct 3, 2026
commit 60b0dfec82f7d7481b2b1cc1543fcda02c40fbb3

There are no files selected for viewing

93 changes: 59 additions & 34 deletions 93 apps/server/src/orchestration-v2/BackgroundWorkStop.integration.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ it.effect("Stop reaches background work an earlier provider thread still runs",
const codexProviderThread = (yield* orchestrator.getThreadProjection(threadId))
.providerThreads[0]!;
// A settled run with its root node, attempt, provider turn and,
// optionally, a command it left running.
// optionally, a command or native subagent it left running.
const settledRun = (input: {
readonly ordinal: number;
readonly providerThreadId: ProviderThreadId;
readonly runningCommandId?: TurnItemId;
readonly runningItem?: { readonly id: TurnItemId; readonly kind: "command" | "subagent" };
}) => {
const runId = RunId.make(`run:${input.ordinal}`);
const attemptId = RunAttemptId.make(`attempt:${input.ordinal}`);
Expand Down Expand Up @@ -324,49 +324,73 @@ it.effect("Stop reaches background work an earlier provider thread still runs",
},
},
];
if (input.runningCommandId !== undefined) {
const item = input.runningItem;
if (item !== undefined) {
const base = {
id: item.id,
threadId,
runId,
nodeId,
providerThreadId: input.providerThreadId,
providerTurnId,
nativeItemRef: null,
parentItemId: null,
ordinal: input.ordinal * 100,
status: "running",
title: null,
startedAt: now,
completedAt: null,
updatedAt: now,
} as const;
events.push({
id: EventId.make(`command:${input.ordinal}`),
id: EventId.make(`item:${input.ordinal}`),
type: "turn-item.updated",
threadId,
runId,
occurredAt: now,
payload: {
id: input.runningCommandId,
threadId,
runId,
nodeId,
providerThreadId: input.providerThreadId,
providerTurnId,
nativeItemRef: null,
parentItemId: null,
ordinal: input.ordinal * 100,
status: "running",
title: null,
startedAt: now,
completedAt: null,
updatedAt: now,
type: "command_execution",
input: "vp run test --watch",
},
payload:
item.kind === "command"
? { ...base, type: "command_execution", input: "vp run test --watch" }
: {
...base,
// A native subagent item names its own provider thread
// but its parent's provider turn.
providerThreadId: ProviderThreadId.make("provider-thread:codex-subagent"),
type: "subagent",
subagentId: NodeId.make(`subagent:${input.ordinal}`),
origin: "provider_native",
driver,
providerInstanceId: instanceId,
childThreadId: null,
prompt: "Review the change",
result: null,
},
});
}
return { runId, providerTurnId, events };
};

// Codex leaves a second command in a later run. Then the thread moves
// on to another provider thread, which also has a live session.
// Later Codex runs leave a second command and a native subagent. Then
// the thread moves on to another provider thread, which also has a
// live session.
const watcherId = TurnItemId.make("turn-item:watcher");
const laterCodexRun = settledRun({
const watcherRun = settledRun({
ordinal: 2,
providerThreadId: codexProviderThread.id,
runningCommandId: watcherId,
runningItem: { id: watcherId, kind: "command" },
});
const reviewerId = TurnItemId.make("turn-item:reviewer");
const reviewerRun = settledRun({
ordinal: 3,
providerThreadId: codexProviderThread.id,
runningItem: { id: reviewerId, kind: "subagent" },
});
const otherProviderThreadId = ProviderThreadId.make("provider-thread:other");
const latestRun = settledRun({ ordinal: 3, providerThreadId: otherProviderThreadId });
const latestRun = settledRun({ ordinal: 4, providerThreadId: otherProviderThreadId });
yield* sink.write({
events: [
...laterCodexRun.events,
...watcherRun.events,
...reviewerRun.events,
{
id: EventId.make("provider-thread:other"),
type: "provider-thread.updated",
Expand All @@ -375,8 +399,8 @@ it.effect("Stop reaches background work an earlier provider thread still runs",
payload: {
...codexProviderThread,
id: otherProviderThreadId,
firstRunOrdinal: 3,
lastRunOrdinal: 3,
firstRunOrdinal: 4,
lastRunOrdinal: 4,
},
},
...latestRun.events,
Expand All @@ -392,20 +416,21 @@ it.effect("Stop reaches background work an earlier provider thread still runs",
yield* worker.drain();

// Stop reaches both provider threads. The Codex one is interrupted at
// its latest pending work, so its settle covers both of its runs.
// its latest pending work, the subagent's parent turn, so its settle
// covers all three Codex runs.
assert.sameDeepMembers(
interrupts.map((interrupt) => [interrupt.providerThread.id, interrupt.providerTurnId]),
[
[otherProviderThreadId, latestRun.providerTurnId],
[codexProviderThread.id, laterCodexRun.providerTurnId],
[codexProviderThread.id, reviewerRun.providerTurnId],
],
);
const after = yield* orchestrator.getThreadProjection(threadId);
assert.deepEqual(
[devServerId, watcherId].map(
[devServerId, watcherId, reviewerId].map(
(id) => after.turnItems.find((item) => item.id === id)?.status,
),
["interrupted", "interrupted"],
["interrupted", "interrupted", "interrupted"],
);
}).pipe(
Effect.provide(
Expand Down
46 changes: 20 additions & 26 deletions 46 apps/server/src/orchestration-v2/Orchestrator.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8120,53 +8120,47 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
);
const runOrdinalOf = (item: (typeof projection.turnItems)[number]) =>
item.runId === null ? -1 : (runOrdinals.get(item.runId) ?? -1);
// Each provider thread is interrupted at its latest pending item: that
// item's run bounds the settle follow-up, which must cover all of the
// thread's work.
const latestItemByProviderThread = new Map<
// Each provider thread is interrupted at its latest pending work: that
// turn's run bounds the settle follow-up, which must cover all of the
// thread's work. The target comes from the item's provider turn, since
// a native subagent item names its own provider thread but its
// parent's turn; interrupting the parent's turn reaches the subagent.
const latestTurnByProviderThread = new Map<
OrchestrationV2ProviderThread["id"],
(typeof projection.turnItems)[number]
{ readonly turn: (typeof projection.providerTurns)[number]; readonly runOrdinal: number }
>();
for (const item of pendingBackgroundTurnItems({
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

turnItems: projection.turnItems,
runs: projection.runs,
})) {
if (
item.providerThreadId == null ||
item.providerThreadId === providerThread.id ||
item.providerTurnId === null
) {
continue;
}
const latest = latestItemByProviderThread.get(item.providerThreadId);
if (latest === undefined || runOrdinalOf(item) > runOrdinalOf(latest)) {
latestItemByProviderThread.set(item.providerThreadId, item);
const turn = projection.providerTurns.find(
(candidate) => candidate.id === item.providerTurnId,
);
if (turn === undefined || turn.providerThreadId === providerThread.id) continue;
const runOrdinal = runOrdinalOf(item);
const latest = latestTurnByProviderThread.get(turn.providerThreadId);
if (latest === undefined || runOrdinal > latest.runOrdinal) {
latestTurnByProviderThread.set(turn.providerThreadId, { turn, runOrdinal });
}
}
for (const item of latestItemByProviderThread.values()) {
for (const { turn } of latestTurnByProviderThread.values()) {
const owner = projection.providerThreads.find(
(candidate) => candidate.id === item.providerThreadId,
(candidate) => candidate.id === turn.providerThreadId,
);
if (
owner === undefined ||
owner.providerSessionId === null ||
item.providerTurnId === null
) {
continue;
}
if (owner === undefined || owner.providerSessionId === null) continue;
const ownerSession = yield* providerSessions
.get(owner.providerSessionId)
.pipe(Effect.orElseSucceed(() => Option.none()));
if (Option.isNone(ownerSession)) continue;
otherProviderInterrupts.push({
id: `effect:${command.commandId}:provider-turn.interrupt:${item.providerTurnId}`,
id: `effect:${command.commandId}:provider-turn.interrupt:${turn.id}`,
commandId: command.commandId,
threadId: command.threadId,
request: {
type: "provider-turn.interrupt",
providerSessionId: owner.providerSessionId,
providerThreadId: owner.id,
providerTurnId: item.providerTurnId,
providerTurnId: turn.id,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion 2 apps/server/src/orchestration-v2/ProjectionSettlement.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ it.effect.each([
forkedFrom: null,
createdAt: old,
updatedAt: old,
pendingBackgroundTasks: [{ taskId: "running-task", kind: "command" }],
pendingBackgroundTasks: [{ taskId: "running-task", kind: "subagent" }],
},
});
const candidates = yield* store.getSettlementCandidates();
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.