fix(gsd): preserve auto start model through discuss (#2837)
This commit is contained in:
parent
a6bb48e82d
commit
a0b9a85a20
2 changed files with 41 additions and 5 deletions
|
|
@ -131,6 +131,15 @@ export async function bootstrapAutoSession(
|
|||
return false;
|
||||
}
|
||||
|
||||
// Capture the user's session model before guided-flow dispatch can apply a
|
||||
// phase-specific planning model for a discuss turn (#2829).
|
||||
const startModelSnapshot = ctx.model
|
||||
? {
|
||||
provider: ctx.model.provider,
|
||||
id: ctx.model.id,
|
||||
}
|
||||
: null;
|
||||
|
||||
try {
|
||||
// Validate GSD_PROJECT_ID early so the user gets immediate feedback
|
||||
const customProjectId = process.env.GSD_PROJECT_ID;
|
||||
|
|
@ -576,12 +585,11 @@ export async function bootstrapAutoSession(
|
|||
// Initialize routing history
|
||||
initRoutingHistory(s.basePath);
|
||||
|
||||
// Capture session's model at auto-mode start (#650)
|
||||
const currentModel = ctx.model;
|
||||
if (currentModel) {
|
||||
// Restore the model that was active when auto bootstrap began (#650, #2829).
|
||||
if (startModelSnapshot) {
|
||||
s.autoModeStartModel = {
|
||||
provider: currentModel.provider,
|
||||
id: currentModel.id,
|
||||
provider: startModelSnapshot.provider,
|
||||
id: startModelSnapshot.id,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
const sourcePath = join(import.meta.dirname, "..", "auto-start.ts");
|
||||
const source = readFileSync(sourcePath, "utf-8");
|
||||
|
||||
test("bootstrapAutoSession snapshots ctx.model before guided-flow entry (#2829)", () => {
|
||||
const snapshotIdx = source.indexOf("const startModelSnapshot = ctx.model");
|
||||
assert.ok(snapshotIdx > -1, "auto-start.ts should snapshot ctx.model at bootstrap start");
|
||||
|
||||
const firstDiscussIdx = source.indexOf('await showSmartEntry(ctx, pi, base, { step: requestedStepMode });');
|
||||
assert.ok(firstDiscussIdx > -1, "auto-start.ts should route through showSmartEntry during guided flow");
|
||||
|
||||
assert.ok(
|
||||
snapshotIdx < firstDiscussIdx,
|
||||
"auto-start.ts must capture the start model before guided-flow can mutate ctx.model",
|
||||
);
|
||||
});
|
||||
|
||||
test("bootstrapAutoSession restores autoModeStartModel from the early snapshot (#2829)", () => {
|
||||
const assignmentIdx = source.indexOf("s.autoModeStartModel = {");
|
||||
assert.ok(assignmentIdx > -1, "auto-start.ts should assign autoModeStartModel");
|
||||
|
||||
const snapshotRefIdx = source.indexOf("provider: startModelSnapshot.provider", assignmentIdx);
|
||||
assert.ok(snapshotRefIdx > -1, "autoModeStartModel should be restored from startModelSnapshot");
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue