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 — Merge upstream/main after #43278 · pingdotgg/t3code@3fc25db

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • server/src
      • htmlRender
        • HtmlRender.test.ts
        • HtmlRender.ts
      • orchestration-v2
        • ProviderTurnStartService.ts
        • testkit
          • ProviderSwitch.integration.test.ts
    • web/src/components/chat
      • useComposerSend.ts
  • packages
    • provider-core/src/server
      • ProviderAdapter.ts
    • provider-cursor/src/server
      • adapter.test.ts
      • adapter.ts
    • shared/src
      • paletteSearch.test.ts
      • paletteSearch.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/htmlRender/HtmlRender.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/htmlRender/HtmlRender.test.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,20 @@ describe("HtmlRender", () => {
105105
"<style media=screen>main{height: calc(100dvh - 2rem)}",
106106
"<div style='top:.5svh'></div>",
107107
"<div style=height:100vh></div>",
108+
"<style>main{min-height:100vmax}</style>",
109+
"<div style='height:calc(100dvmax - 1rem)'></div>",
110+
"<style>main{block-size:100vb}</style>",
111+
"<div style='margin-top:-50vh'></div>",
108112
]) {
109113
const error = yield* htmlRender.prepare(page).pipe(Effect.flip);
110114
expect(error).toBeInstanceOf(HtmlRender.HtmlRenderViewportHeightError);
111115
}
112116
yield* htmlRender.prepare(
113117
'<style>main{width:100vw;height:320px}</style><img src="data:image/png;base64,AB1vh+2vh/3vhC">',
114118
);
119+
yield* htmlRender.prepare(
120+
'<style>.h-100vmax,.min-h-100vb{height:200px}</style><main class="h-100vmax">hi</main>',
121+
);
115122
yield* htmlRender.prepare(
116123
"<p>Avoid 100vh here.</p><!-- <div style=\"height:100vh\"></div> --><script>const unit = '100vh';</script>",
117124
);
Collapse file

‎apps/server/src/htmlRender/HtmlRender.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/htmlRender/HtmlRender.ts
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ export class HtmlRenderViewportHeightError extends Schema.TaggedError<HtmlRender
105105
// Consume unclosed comments, tags, or quotes through EOF to keep both patterns linear.
106106
const CSS_SOURCE =
107107
/<!--[\s\S]*?(?:-->|$)|<style\b[^>]*(?:>|$)([\s\S]*?)(?:<\/style\s*>|$)|\sstyle\s*=\s*(?:"([^"]*)(?:"|$)|'([^']*)(?:'|$)|([^\s>]+))/gi;
108-
// The lookbehind skips base64 runs, such as an inlined image that happens to contain "1vh".
109-
const VIEWPORT_HEIGHT_UNIT = /(?<![\w.+/])(?:\d+(?:\.\d+)?|\.\d+)[sld]?vh(?![\w-])/i;
108+
// vb and vmax follow the frame height too; vmin stays, as the frame width caps it.
109+
// The lookbehind skips base64 runs, such as an inlined image that happens to contain "1vh",
110+
// and identifiers such as the class `.h-100vmax`, while a negative `-50vh` still counts.
111+
const VIEWPORT_HEIGHT_UNIT =
112+
/(?<![\w.+/]|[\w-]-)(?:\d+(?:\.\d+)?|\.\d+)[sld]?v(?:h|b|max)(?![\w-])/i;
110113

111114
const rejectViewportHeight = (html: string) => {
112115
for (const [, sheet, doubleQuoted, singleQuoted, unquoted] of html.matchAll(CSS_SOURCE)) {
Collapse file

‎apps/server/src/orchestration-v2/ProviderTurnStartService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+36-23Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,11 @@ export function abandonedProviderTurns(
154154
const CUT_TURN_SETTLED = "cut-turn-settled";
155155

156156
/**
157-
* The latest cancelled or stopped turn when no adapter said whether it kept the request. A restart
158-
* cancels the turn with no adapter left to tell. A Stop leaves its request with the session, which
159-
* carries it into the next turn and is gone once the session closes. Later runs whose request the
160-
* provider never got are passed over: a stopped request they carried was lost with them.
157+
* The latest cancelled or interrupted turn when no adapter said whether it kept the request. Later
158+
* runs whose request the provider never got are passed over, since a session carries a stopped
159+
* request into the next turn and anything they carried was lost with them.
161160
*/
162-
function unsettledCutProviderTurn(
161+
function unsettledStoppedProviderTurn(
163162
projection: Pick<OrchestrationV2ThreadProjection, "runs" | "providerTurns">,
164163
run: Pick<OrchestrationV2Run, "ordinal">,
165164
providerThread: Pick<OrchestrationV2ProviderThread, "id" | "nativeThreadRef">,
@@ -1014,6 +1013,7 @@ export const layer: Layer.Layer<
10141013
// restart superseded, and the session cannot be reused until those turns stop.
10151014
const abandonedTurns = abandonedProviderTurns(projection, run, providerThread.id);
10161015
const abandonedTurn = abandonedTurns.at(-1)?.turn;
1016+
let providerTurns = projection.providerTurns;
10171017
if (abandonedTurn !== undefined) {
10181018
const liveSession = yield* providerSessions.get(providerSessionId);
10191019
if (Option.isSome(liveSession)) {
@@ -1038,27 +1038,32 @@ export const layer: Layer.Layer<
10381038
}
10391039
}
10401040
const completedAt = yield* DateTime.now;
1041+
const repairEvents = yield* Effect.forEach(abandonedTurns, ({ turn, run: abandonedRun }) =>
1042+
Effect.gen(function* () {
1043+
return {
1044+
id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }),
1045+
type: "provider-turn.updated" as const,
1046+
threadId: projection.thread.id,
1047+
runId: abandonedRun.id,
1048+
nodeId: turn.nodeId,
1049+
providerInstanceId: abandonedRun.providerInstanceId,
1050+
occurredAt: completedAt,
1051+
payload: { ...turn, status: "interrupted" as const, completedAt },
1052+
};
1053+
}),
1054+
);
10411055
const repaired = yield* eventSink.writeIfRunCurrent({
10421056
threadId: projection.thread.id,
10431057
runId: run.id,
10441058
activeAttemptId: attempt.id,
10451059
expectedStatus: "starting",
1046-
events: yield* Effect.forEach(abandonedTurns, ({ turn, run: abandonedRun }) =>
1047-
Effect.gen(function* () {
1048-
return {
1049-
id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }),
1050-
type: "provider-turn.updated" as const,
1051-
threadId: projection.thread.id,
1052-
runId: abandonedRun.id,
1053-
nodeId: turn.nodeId,
1054-
providerInstanceId: abandonedRun.providerInstanceId,
1055-
occurredAt: completedAt,
1056-
payload: { ...turn, status: "interrupted" as const, completedAt },
1057-
};
1058-
}),
1059-
),
1060+
events: repairEvents,
10601061
});
10611062
if (!repaired.committed) return;
1063+
const repairedTurns = new Map(
1064+
repairEvents.map((event) => [event.payload.id, event.payload]),
1065+
);
1066+
providerTurns = providerTurns.map((turn) => repairedTurns.get(turn.id) ?? turn);
10621067
}
10631068
// Opening a session does not prompt the provider, so the workspace is still unchanged.
10641069
const baseline = yield* runExecution.forkBaseline({
@@ -1108,7 +1113,11 @@ export const layer: Layer.Layer<
11081113
}
11091114
const session = sessionResult.success;
11101115
if (!(yield* isCurrentAttemptInStatus("starting"))) return;
1111-
const cutTurn = unsettledCutProviderTurn(projection, run, providerThread);
1116+
const cutTurn = unsettledStoppedProviderTurn(
1117+
{ runs: projection.runs, providerTurns },
1118+
run,
1119+
providerThread,
1120+
);
11121121
// A cut turn the provider did not keep may itself have carried an earlier stopped request,
11131122
// which is lost with it, so keep asking back to a turn the provider kept.
11141123
const droppedCutTurns: Array<NonNullable<typeof cutTurn>> = [];
@@ -1122,14 +1131,18 @@ export const layer: Layer.Layer<
11221131
// As when the turn ends: an unknown answer resends the request rather than losing it.
11231132
.pipe(Effect.orElseSucceed(() => false))
11241133
));
1125-
candidate = unsettledCutProviderTurn(projection, candidate.run, providerThread)
1134+
candidate = unsettledStoppedProviderTurn(
1135+
{ runs: projection.runs, providerTurns },
1136+
candidate.run,
1137+
providerThread,
1138+
)
11261139
) {
11271140
droppedCutTurns.push(candidate);
11281141
}
11291142
const earliestCutTurn = droppedCutTurns.at(-1);
11301143
if (earliestCutTurn !== undefined) {
1131-
// Settle them as a failed turn is settled: mark each request dropped and take back their
1132-
// inline context, so this turn resends all of it. Starting again reads the settled state.
1144+
// Settle them as a Stop would: mark each request dropped and take back their inline
1145+
// context, so this turn resends all of it. Starting again reads the settled state.
11331146
const occurredAt = yield* DateTime.now;
11341147
const allocateEventId = () =>
11351148
idAllocator.allocate.event({ threadId: projection.thread.id });
Collapse file

‎apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+101-20Lines changed: 101 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6552,8 +6552,6 @@ describe("orchestration v2 provider switching", () => {
65526552
"same-provider-retry",
65536553
"cancelled-dropped",
65546554
"cancelled-by-restart",
6555-
"stopped-session-closed",
6556-
"stopped-session-kept",
65576555
"switch-away-and-return",
65586556
"persisted-failure",
65596557
] as const)("handles an inline context handoff after a failed returning turn (%s)", (variant) =>
@@ -6562,10 +6560,7 @@ describe("orchestration v2 provider switching", () => {
65626560
const capturedTurns = yield* Ref.make<ReadonlyArray<CapturedTurn>>([]);
65636561
// A restart cancels the turn with no adapter left to report the drop.
65646562
const cutByRestart = variant === "cancelled-by-restart";
6565-
// A Stop leaves the request with the session; once that closes, nothing carries it.
6566-
const stopped = variant === "stopped-session-closed" || variant === "stopped-session-kept";
6567-
const unsettled = cutByRestart || variant === "stopped-session-closed";
6568-
const dropped = variant !== "persisted-failure" && !cutByRestart && !stopped;
6563+
const dropped = variant !== "persisted-failure" && !cutByRestart;
65696564
const cancelled = variant === "cancelled-dropped" || cutByRestart;
65706565
const layerRegistry = ProviderAdapterRegistry.layerFromAdapters([
65716566
makeTestAdapter({
@@ -6580,17 +6575,13 @@ describe("orchestration v2 provider switching", () => {
65806575
5: "Recovered Codex after round-trip.",
65816576
},
65826577
capturedTurns,
6583-
...(stopped
6584-
? { interruptedRunOrdinals: new Set([3]) }
6585-
: cancelled
6586-
? { cancelledRunOrdinals: new Set([3]) }
6587-
: { failedRunOrdinals: new Set([3]) }),
6578+
...(cancelled
6579+
? { cancelledRunOrdinals: new Set([3]) }
6580+
: { failedRunOrdinals: new Set([3]) }),
65886581
...(dropped ? { promptDroppedRunOrdinals: new Set([3]) } : {}),
6589-
...(unsettled
6582+
...(cutByRestart
65906583
? { nativeTurnKept: (nativeTurnId: string) => !nativeTurnId.endsWith(":3") }
6591-
: stopped
6592-
? { nativeTurnKept: () => true }
6593-
: {}),
6584+
: {}),
65946585
}),
65956586
makeTestAdapter({
65966587
instanceId: CLAUDE_MODEL_SELECTION.instanceId,
@@ -6652,7 +6643,7 @@ describe("orchestration v2 provider switching", () => {
66526643
// Run 3: switch back to Codex (delta handoff covering run 2); fails.
66536644
const afterRun3 = yield* send("Resume after failure", CODEX_MODEL_SELECTION);
66546645
const run3 = afterRun3.runs.find((run) => run.ordinal === 3)!;
6655-
assert.equal(run3.status, stopped ? "interrupted" : cancelled ? "cancelled" : "failed");
6646+
assert.equal(run3.status, cancelled ? "cancelled" : "failed");
66566647
const run3Handoff = afterRun3.contextHandoffs.find(
66576648
(handoff) => handoff.targetRunId === run3.id,
66586649
);
@@ -6672,7 +6663,7 @@ describe("orchestration v2 provider switching", () => {
66726663
assert.equal(run3Handoff?.delivery?.status, "inline");
66736664
}
66746665

6675-
if (variant === "same-provider-retry" || variant === "cancelled-dropped" || unsettled) {
6666+
if (variant === "same-provider-retry" || variant === "cancelled-dropped" || cutByRestart) {
66766667
// Run 4: stay on Codex; must re-deliver run 2's handoff.
66776668
const afterRun4 = yield* send("Resume", CODEX_MODEL_SELECTION);
66786669
const turns = yield* Ref.get(capturedTurns);
@@ -6702,12 +6693,10 @@ describe("orchestration v2 provider switching", () => {
67026693
assert.include(run5Turn.text, "Afternoon Claude shipped b63 live draft.");
67036694
assert.include(run5Turn.text, "Extra Claude turn after dropped handoff.");
67046695
} else {
6705-
// Control: run 3 persisted its prompt before failing, or its live session still carries
6706-
// the stopped request, so run 4 must not send run 2 or run 3 again.
6696+
// Control: run 3 persisted its prompt before failing, so run 4 must not re-send run 2.
67076697
yield* send("Resume", CODEX_MODEL_SELECTION);
67086698
const run4Turn = (yield* Ref.get(capturedTurns)).at(-1)!;
67096699
assert.notInclude(run4Turn.text, "Afternoon Claude shipped b63 live draft.");
6710-
assert.notInclude(run4Turn.text, "Resume after failure");
67116700
}
67126701
}).pipe(
67136702
Effect.provide(
@@ -6731,6 +6720,98 @@ describe("orchestration v2 provider switching", () => {
67316720
}),
67326721
);
67336722

6723+
it.effect("resends a stopped request the provider dropped once its session closed", () =>
6724+
Effect.gen(function* () {
6725+
const cwd = yield* checkpointWorkspace("stopped-request-dropped");
6726+
const capturedTurns = yield* Ref.make<ReadonlyArray<CapturedTurn>>([]);
6727+
const layerRegistry = ProviderAdapterRegistry.layerFromAdapters([
6728+
makeTestAdapter({
6729+
instanceId: CODEX_MODEL_SELECTION.instanceId,
6730+
driver: CODEX_DRIVER,
6731+
capabilities: CodexProviderCapabilitiesV2,
6732+
modelSelection: CODEX_MODEL_SELECTION,
6733+
responseByRunOrdinal: { 1: "hello", 2: "", 3: "Answer." },
6734+
capturedTurns,
6735+
interruptedRunOrdinals: new Set([2]),
6736+
// Stopped before its first checkpoint: the provider never kept run 2.
6737+
nativeTurnKept: (nativeTurnId) => !nativeTurnId.endsWith(":2"),
6738+
}),
6739+
]);
6740+
6741+
yield* Effect.gen(function* () {
6742+
const orchestrator = yield* Orchestrator.OrchestratorV2;
6743+
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
6744+
const testThreadId = ThreadId.make("thread:stopped-request-dropped");
6745+
yield* orchestrator.dispatch({
6746+
type: "thread.create",
6747+
createdBy: "user",
6748+
creationSource: "web",
6749+
commandId: CommandId.make("command:stopped-request-dropped:create"),
6750+
threadId: testThreadId,
6751+
projectId,
6752+
title: "Stopped request dropped",
6753+
modelSelection: CODEX_MODEL_SELECTION,
6754+
runtimeMode: "full-access",
6755+
interactionMode: "default",
6756+
branch: null,
6757+
worktreePath: cwd,
6758+
});
6759+
let step = 0;
6760+
const send = (text: string) =>
6761+
Effect.gen(function* () {
6762+
step += 1;
6763+
yield* orchestrator.dispatch({
6764+
type: "message.dispatch",
6765+
createdBy: "user",
6766+
creationSource: "web",
6767+
commandId: CommandId.make(`command:stopped-request-dropped:msg-${step}`),
6768+
threadId: testThreadId,
6769+
messageId: MessageId.make(`message:stopped-request-dropped:${step}`),
6770+
text,
6771+
attachments: [],
6772+
modelSelection: CODEX_MODEL_SELECTION,
6773+
dispatchMode: { type: "start_immediately" },
6774+
});
6775+
yield* worker.drain();
6776+
yield* waitForIdle(testThreadId);
6777+
yield* worker.drain();
6778+
return yield* orchestrator.getThreadProjection(testThreadId);
6779+
});
6780+
6781+
yield* send("Say hello");
6782+
const afterStop = yield* send("List every prime number below 300");
6783+
const stopped = afterStop.runs.find((run) => run.ordinal === 2)!;
6784+
assert.equal(stopped.status, "interrupted");
6785+
6786+
const afterNext = yield* send("Did I ask you anything about math?");
6787+
const nextTurn = (yield* Ref.get(capturedTurns)).at(-1)!;
6788+
assert.include(nextTurn.text, "List every prime number below 300");
6789+
const stoppedTurn = afterNext.providerTurns.find(
6790+
(turn) => turn.runAttemptId === stopped.activeAttemptId,
6791+
);
6792+
assert.equal(stoppedTurn?.promptDropped, true);
6793+
}).pipe(
6794+
Effect.provide(
6795+
ProviderReplayHarness.layerWithRegistry(
6796+
{
6797+
name: "stopped-request-dropped",
6798+
runtimePolicyOverride: {
6799+
cwd,
6800+
approvalPolicy: "never",
6801+
sandboxPolicy: {
6802+
type: "readOnly",
6803+
access: { type: "fullAccess" },
6804+
networkAccess: false,
6805+
},
6806+
},
6807+
},
6808+
layerRegistry,
6809+
),
6810+
),
6811+
);
6812+
}),
6813+
);
6814+
67346815
it.effect("restores a handoff that a turn cut by a restart carried from an earlier run", () =>
67356816
Effect.gen(function* () {
67366817
const cwd = yield* checkpointWorkspace("carried-handoff-cut-by-restart");
Collapse file

‎apps/web/src/components/chat/useComposerSend.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/useComposerSend.ts
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,24 @@ export function useComposerSend(input: ComposerSendInput) {
10381038
.getState()
10391039
.getComposerDraft(composerDraftTarget);
10401040
sendInFlightRef.current = true;
1041+
// The commands are read as they are now, which takes a round trip, so the send shows as sending.
1042+
const showsWait = isCurrentRouteThread();
1043+
if (showsWait) {
1044+
beginLocalDispatch({
1045+
preparingWorktree: true,
1046+
submissionIntent:
1047+
submissionIntent === "background" && !isLocalDraftThread
1048+
? "foreground"
1049+
: submissionIntent,
1050+
});
1051+
}
10411052
const layoutApproval = await ensureWorktreeLayoutApproved({
10421053
environmentId,
10431054
projectId: activeProject.id,
10441055
projectTitle: activeProject.title,
10451056
}).finally(() => {
10461057
sendInFlightRef.current = false;
1058+
if (showsWait && isCurrentRouteThread()) resetLocalDispatch();
10471059
});
10481060
if (layoutApproval.status === "cancelled") return;
10491061
if (layoutApproval.status === "blocked") {
Collapse file

‎packages/provider-core/src/server/ProviderAdapter.ts‎

Copy file name to clipboardExpand all lines: packages/provider-core/src/server/ProviderAdapter.ts
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,8 @@ export interface ProviderAdapterV2SessionRuntime {
795795
) => number | undefined;
796796
readonly canReuseContextUsage?: (previous: ModelSelection, next: ModelSelection) => boolean;
797797
/**
798-
* False when the provider will not see a cancelled or stopped turn's request again: the native
799-
* session no longer holds it, and this session runtime does not carry it into the next turn.
800-
* Set only by providers that can drop one, so the turn is settled like a failed one.
798+
* False when the native session no longer holds a cancelled turn's request. Set only by
799+
* providers that can drop one, so a turn a restart cut off is settled like a Stop.
801800
*/
802801
readonly nativeTurnKept?: (input: {
803802
readonly providerThread: OrchestrationV2ProviderThread;
Collapse file

‎packages/provider-cursor/src/server/adapter.test.ts‎

Copy file name to clipboardExpand all lines: packages/provider-cursor/src/server/adapter.test.ts
+5-13Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,20 +1416,12 @@ describe("CursorAdapterV2", () => {
14161416
);
14171417
assert(started.type === "provider_turn.updated");
14181418
yield* runtime.interruptTurn({ providerThread, providerTurnId: started.providerTurn.id });
1419-
const stoppedRun = { providerThread, nativeTurnId: "native-cursor-run-1" };
14201419
assert.isTrue(
1421-
yield* runtime.nativeTurnKept!(stoppedRun),
1422-
"the session that saw the Stop sends its request with the next turn",
1423-
);
1424-
const reopened = yield* adapter.openSession({
1425-
threadId,
1426-
providerSessionId: ProviderSessionId.make("cursor-steer-session-reopened"),
1427-
modelSelection,
1428-
runtimePolicy,
1429-
});
1430-
assert.isFalse(
1431-
yield* reopened.nativeTurnKept!(stoppedRun),
1432-
"a session opened after the Stop has nothing to send it with",
1420+
yield* runtime.nativeTurnKept!({
1421+
providerThread,
1422+
nativeTurnId: started.providerTurn.nativeTurnRef!.nativeId!,
1423+
}),
1424+
"a live session replays the stopped request itself, so the server must not resend it too",
14331425
);
14341426
yield* runtime.startTurn(turnInput(2, steerText));
14351427

0 commit comments

Comments
0 (0)
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.