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): snooze no longer waits two minutes after a steered queued message by juliusmarminge · Pull Request #35661 · pingdotgg/t3code

fix(server): snooze no longer waits two minutes after a steered queued message #35661

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
juliusmarminge merged 5 commits into main from factory/issue-23778-a23787
Nov 12, 2026

Uh oh!

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

Merged

fix(server): snooze no longer waits two minutes after a steered queued message #35661

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
5 commits
Select commit Hold shift + click to select a range
d1545ee
test(server): a steered queued run that never started is not the shel…
juliusmarminge Nov 12, 2026
29ac4dc
fix(server): snooze no longer waits two minutes after a steered queue…
juliusmarminge Nov 12, 2026
761c8b7
fix(server): keep a removed queued run latest when the earlier run al…
juliusmarminge Nov 12, 2026
c351030
fix(server): silent compaction runs no longer hide a removed queued r…
juliusmarminge Nov 12, 2026
5197429
Merge branch 'main' into factory/issue-23778-a23787
juliusmarminge Nov 12, 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

There are no files selected for viewing

54 changes: 50 additions & 4 deletions 54 apps/server/src/orchestration-v2/ProjectionStore.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5039,8 +5039,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
),
);

// A steer cancels the queued run before it starts while the steered run keeps writing, so
// the queued message leaves the window but its run is still the shell's latest run.
// A steer moves the cancelled queued message outside the window.
const steeredItemId = "turn-item:bounded-sql-history:steered-output";
const steeredRunId = RunId.make("run:bounded-sql-history:1000");
yield* sql`
Expand Down Expand Up @@ -5078,7 +5077,14 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
assert.isFalse(
steeredSnapshot.projection.turnItems.some((item) => item.runId === cancelledRunId),
);
assert.isTrue(steeredSnapshot.projection.runs.some((run) => run.id === cancelledRunId));
const latestRunId = (yield* projectionStore.getShellSnapshot()).threads.find(
(thread) => thread.id === threadId,
)?.latestRunId;
assert.equal(latestRunId, hiddenRunId);
assert.isFalse(
steeredSnapshot.projection.turnItems.some((item) => item.runId === latestRunId),
);
assert.isTrue(steeredSnapshot.projection.runs.some((run) => run.id === latestRunId));
yield* sql`DELETE FROM orchestration_v2_projection_turn_items WHERE turn_item_id = ${steeredItemId}`;

const interruptRunId = RunId.make("run:bounded-sql-history:interrupt");
Expand Down Expand Up @@ -7395,6 +7401,28 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
silent ? hidden : visible,
]);

// A follow-up removed before it started stays latest unless a visible run outlives it.
const removedRunId = RunId.make(`run:projection-shell-silent:${key}:removed`);
yield* projectionStore.apply({
id: EventId.make(`event:projection-shell-silent:${key}:removed`),
type: "run.updated",
threadId,
occurredAt: now,
payload: {
...(yield* projectionStore.getThreadProjection(threadId)).runs[0]!,
id: removedRunId,
ordinal: 2,
userMessageId: MessageId.make(`message:projection-shell-silent:${key}:removed`),
status: "cancelled",
startedAt: null,
completedAt: now,
},
});
assert.deepStrictEqual(
(yield* presented).map((shell) => shell.latestRunId),
silent ? [removedRunId, removedRunId] : [runId, runId],
);

// A run that fails outright, e.g. on a provider error, needs the user too.
const running = (yield* projectionStore.getThreadProjection(threadId)).runs[0]!;
const setRunStatus = (status: "failed" | "running") =>
Expand Down Expand Up @@ -7633,9 +7661,27 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
value == null ? null : DateTime.toEpochMillis(value);
assert.equal(timestamp(sqlShell.activityRunStartedAt), expected);
assert.equal(timestamp(memoryShell.activityRunStartedAt), expected);
assert.equal(sqlShell.latestRunId, "run:clock:newer");
// A queued message steered or removed before it started never ran, so the run that did presents.
for (const shell of [sqlShell, memoryShell]) {
assert.equal(shell.latestRunId, status === "cancelled" ? runId : "run:clock:newer");
}
}
}
// Removing a message after the earlier run ended leaves the cancelled run as the latest.
yield* projectionStore.apply({
id: EventId.make("event:clock:ended-before-cancel"),
type: "run.updated",
threadId,
occurredAt: later,
payload: { ...run, status: "completed", startedAt: now, completedAt: now },
});
const endedBeforeCancelProjection = yield* projectionStore.getThreadProjection(threadId);
for (const shell of [
(yield* projectionStore.getShellSnapshot()).threads.find((row) => row.id === threadId)!,
ProjectionStore.threadShellFromProjection(endedBeforeCancelProjection),
]) {
assert.equal(shell.latestRunId, "run:clock:newer");
}

yield* projectionStore.apply({
id: EventId.make("event:clock:newer:held"),
Expand Down
20 changes: 18 additions & 2 deletions 20 apps/server/src/orchestration-v2/ProjectionStore.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3785,7 +3785,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
OR run_id IN (SELECT value FROM json_each(${cohortRunIds}))
OR run_id = ${window.requiredRunId ?? null}
${
// The shell's latest run, even a steer-cancelled one outside the newest window.
// Keep the shell's latest run even when its items are outside the newest window.
window.anchorItemId === undefined && window.requiredRunId === undefined
? sql`OR run_id = ${presentedShellRunId(sql`${threadId}`)}`
: sql``
Expand Down Expand Up @@ -7436,7 +7436,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
)
)`;
};
// The newest run not waiting in a held queue, matching latestUnheldRun.
// The newest run not held or outlived before it started, matching latestUnheldRun.
const presentedShellRunId = (threadId: Statement.Fragment) => sql`(
SELECT candidate.run_id
FROM orchestration_v2_projection_runs candidate
Expand All @@ -7445,6 +7445,22 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
candidate.status = 'queued'
AND json_extract(candidate.payload_json, '$.queueHeld') IS 1
)
AND NOT (
candidate.status = 'cancelled'
AND json_extract(candidate.payload_json, '$.startedAt') IS NULL
AND candidate.completed_at IS NOT NULL
AND EXISTS (
SELECT 1 FROM orchestration_v2_projection_runs earlier
WHERE earlier.thread_id = candidate.thread_id
AND earlier.ordinal < candidate.ordinal
AND earlier.status <> 'queued'
AND NOT ${isSilentShellRun("earlier")}
AND (
earlier.completed_at IS NULL
OR julianday(earlier.completed_at) >= julianday(candidate.completed_at)
)
)
)
AND NOT ${isSilentShellRun("candidate")}
ORDER BY candidate.ordinal DESC, candidate.run_id DESC
LIMIT 1
Expand Down
5 changes: 3 additions & 2 deletions 5 ...erver/src/orchestration-v2/testkit/fixtures/queued_cancelled_while_active/codex_output.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export function assertQueuedCancelledWhileActiveOutput(
.get(ACTIVE_RUN_SHELL_SNAPSHOT_KEY)
?.threads.find((thread) => thread.id === projection.thread.id);
assert.isDefined(capturedShell);
assert.equal(capturedShell.latestRunId, cancelledRun.id);
assert.equal(capturedShell.status, "cancelled");
// The cancelled queued run never started, so the active run presents as the latest.
assert.equal(capturedShell.latestRunId, activeRun.id);
assert.equal(capturedShell.status, "running");
assert.equal(capturedShell.activeRunId, activeRun.id);
assert.equal(capturedShell.activityRunStatus, "running");
assert.deepEqual(
Expand Down
17 changes: 17 additions & 0 deletions 17 packages/shared/src/orchestrationV2ThreadError.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,24 @@ export function latestUnheldRun(
let latest: OrchestrationV2Run | null = null;
for (const run of runs) {
if (run.status === "queued" && run.queueHeld === true) continue;
if (outlivedBeforeStart(run, runs)) continue;
if (latest === null || run.ordinal > latest.ordinal) latest = run;
}
return latest;
}

// Steering a queued message cancels its run before it starts and hands the message to the
// earlier run, which outlives the cancellation; that earlier run then presents as latest.
function outlivedBeforeStart(
run: OrchestrationV2Run,
runs: ReadonlyArray<OrchestrationV2Run>,
): boolean {
if (run.status !== "cancelled" || run.startedAt !== null || !run.completedAt) return false;
const cancelledAt = DateTime.toEpochMillis(run.completedAt);
return runs.some(
(earlier) =>
earlier.ordinal < run.ordinal &&
earlier.status !== "queued" &&
(!earlier.completedAt || DateTime.toEpochMillis(earlier.completedAt) >= cancelledAt),
);
}
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 01402809 — 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.