Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/browser/components/ModelSelector/ModelSelector.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { AppStory } from "@/browser/stories/meta.js";
import { appMeta, AppWithMocks } from "@/browser/stories/meta.js";
import { setupSimpleChatStory } from "@/browser/stories/helpers/chatSetup";
import { within, userEvent, waitFor } from "@storybook/test";
import { updatePersistedState } from "@/browser/hooks/usePersistedState";
import { getModelKey } from "@/common/constants/storage";
import { WORKSPACE_DEFAULTS } from "@/constants/workspaceDefaults";

const meta = {
Expand All @@ -30,11 +28,9 @@ export const ModelSelectorPrettyWithGateway: AppStory = {
const workspaceId = "ws-gateway-model";
const baseModel = "openai:gpt-4o";

// Ensure the gateway indicator is active (so the regression would reproduce).
updatePersistedState(getModelKey(workspaceId), baseModel);

return setupSimpleChatStory({
workspaceId,
aiSettings: { model: baseModel, thinkingLevel: "off" },
messages: [],
routePriority: ["mux-gateway", "direct"],
providersConfig: {
Expand Down Expand Up @@ -116,11 +112,9 @@ export const ModelSelectorDropdownOpen: AppStory = {
const workspaceId = "ws-model-dropdown";
const baseModel = "openai:gpt-4o";

// Set the selected model for this workspace
updatePersistedState(getModelKey(workspaceId), baseModel);

return setupSimpleChatStory({
workspaceId,
aiSettings: { model: baseModel, thinkingLevel: "off" },
messages: [],
providersConfig: {
openai: { apiKeySet: true, isEnabled: true, couponCodeSet: false, isConfigured: true },
Expand Down
19 changes: 6 additions & 13 deletions src/browser/features/ChatInput/ChatInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { appMeta, AppWithMocks, PIXEL_DISABLED } from "@/browser/stories/meta.js
import { setupSimpleChatStory } from "@/browser/stories/helpers/chatSetup";
import { collapseLeftSidebar, setWorkspaceInput } from "@/browser/stories/helpers/uiState";
import { updatePersistedState } from "@/browser/hooks/usePersistedState";
import {
getAutoModelRoutingKey,
getModelKey,
getReasoningModeKey,
} from "@/common/constants/storage";
import { getAutoModelRoutingKey } from "@/common/constants/storage";
import { EXPERIMENT_IDS } from "@/common/constants/experiments";
import { createAssistantMessage, createUserMessage } from "@/browser/stories/mocks/messages";
import { createFileReadTool } from "@/browser/stories/mocks/tools";
Expand Down Expand Up @@ -436,10 +432,9 @@ export const ThinkingSelectorOpen: AppStory = {
<AppWithMocks
setup={() => {
collapseLeftSidebar();
updatePersistedState(getModelKey("ws-thinking-selector"), "openai:gpt-6.1-sol");
updatePersistedState(getReasoningModeKey("ws-thinking-selector"), "pro");
return setupSimpleChatStory({
workspaceId: "ws-thinking-selector",
aiSettings: { model: "openai:gpt-6.1-sol", thinkingLevel: "off", reasoningMode: "pro" },
providersConfig: {
openai: {
apiKeySet: true,
Expand Down Expand Up @@ -494,10 +489,9 @@ export const ThinkingSelectorCyberOpen: AppStory = {
<AppWithMocks
setup={() => {
collapseLeftSidebar();
updatePersistedState(getModelKey("ws-thinking-selector-cyber"), "openai:gpt-6.1-sol");
updatePersistedState(getReasoningModeKey("ws-thinking-selector-cyber"), "cyber");
return setupSimpleChatStory({
workspaceId: "ws-thinking-selector-cyber",
aiSettings: { model: "openai:gpt-6.1-sol", thinkingLevel: "off", reasoningMode: "cyber" },
providersConfig: {
openai: {
apiKeySet: true,
Expand Down Expand Up @@ -561,10 +555,9 @@ export const NarrowControlRowCollapse: AppStory = {
collapseLeftSidebar();
// Active Pro and fast modes exercise both compact selector status indicators while the
// narrow-width assertions prove the row still sheds optional detail before overflowing.
updatePersistedState(getModelKey("ws-composer-breakpoints"), "openai:gpt-6.1-sol");
updatePersistedState(getReasoningModeKey("ws-composer-breakpoints"), "pro");
return setupSimpleChatStory({
workspaceId: "ws-composer-breakpoints",
aiSettings: { model: "openai:gpt-6.1-sol", thinkingLevel: "off", reasoningMode: "pro" },
providersConfig: {
openai: {
apiKeySet: true,
Expand Down Expand Up @@ -1055,10 +1048,10 @@ export const AutoModelRoutingActive: AppStory = {
<AppWithMocks
setup={() => {
collapseLeftSidebar();
updatePersistedState(getModelKey("ws-auto-routing"), "openai:gpt-5.6-sol");
updatePersistedState(getAutoModelRoutingKey("ws-auto-routing"), true);
return setupSimpleChatStory({
workspaceId: "ws-auto-routing",
aiSettings: { model: "openai:gpt-5.6-sol", thinkingLevel: "off" },
experiments: { [EXPERIMENT_IDS.AUTO_MODEL_ROUTING]: true },
providersConfig: {
openai: { apiKeySet: true, isEnabled: true, isConfigured: true },
Expand Down Expand Up @@ -1105,9 +1098,9 @@ export const AutoModelRoutingKeyboard: AppStory = {
<AppWithMocks
setup={() => {
collapseLeftSidebar();
updatePersistedState(getModelKey("ws-auto-routing-keyboard"), "openai:gpt-5.6-sol");
return setupSimpleChatStory({
workspaceId: "ws-auto-routing-keyboard",
aiSettings: { model: "openai:gpt-5.6-sol", thinkingLevel: "off" },
experiments: { [EXPERIMENT_IDS.AUTO_MODEL_ROUTING]: true },
providersConfig: {
openai: { apiKeySet: true, isEnabled: true, isConfigured: true },
Expand Down
8 changes: 3 additions & 5 deletions src/browser/stories/App.astraPro.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { appMeta, AppWithMocks, type AppStory } from "./meta.js";
import { setupSimpleChatStory } from "./helpers/chatSetup";
import { collapseLeftSidebar } from "./helpers/uiState";
import { blurActiveElement, waitForChatInputAutofocusDone } from "./storyPlayHelpers";
import { readPersistedState, updatePersistedState } from "@/browser/hooks/usePersistedState";
import { getModelKey, getReasoningModeKey, getThinkingLevelKey } from "@/common/constants/storage";
import { readPersistedState } from "@/browser/hooks/usePersistedState";
import { getReasoningModeKey } from "@/common/constants/storage";

export default { ...appMeta, title: "App/Astra Pro" };

Expand Down Expand Up @@ -32,11 +32,9 @@ export const CoderGateway: AppStory = {
<AppWithMocks
setup={() => {
collapseLeftSidebar();
updatePersistedState(getModelKey(workspaceId), "coder:openai/gpt-6-astra");
updatePersistedState(getThinkingLevelKey(workspaceId), "high");
updatePersistedState(getReasoningModeKey(workspaceId), "standard");
return setupSimpleChatStory({
workspaceId,
aiSettings: { model: "coder:openai/gpt-6-astra", thinkingLevel: "high" },
messages: [],
routePriority: ["coder"],
providersConfig: {
Expand Down
6 changes: 1 addition & 5 deletions src/browser/stories/App.gatewayFastMode.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { expect, userEvent, waitFor, within } from "@storybook/test";
import { updatePersistedState } from "@/browser/hooks/usePersistedState";
import {
FastModePreviousServiceTierSchema,
ServiceTierSchema,
} from "@/common/config/schemas/providersConfig";
import { getModelKey, getReasoningModeKey, getThinkingLevelKey } from "@/common/constants/storage";
import type { ProvidersConfigMap } from "@/common/orpc/types";
import assert from "@/common/utils/assert";
import { appMeta, AppWithMocks, type AppStory } from "./meta.js";
Expand All @@ -19,9 +17,6 @@ const phoneViewport = { name: "Phone", styles: { width: "390px", height: "844px"

function setupGatewayFastMode() {
collapseLeftSidebar();
updatePersistedState(getModelKey(workspaceId), "coder:openai/gpt-6-astra");
updatePersistedState(getThinkingLevelKey(workspaceId), "high");
updatePersistedState(getReasoningModeKey(workspaceId), "standard");
// An unconfigured provider still exposes preferences.
let providersConfig: ProvidersConfigMap = {
coder: {
Expand All @@ -34,6 +29,7 @@ function setupGatewayFastMode() {
};
const client = setupSimpleChatStory({
workspaceId,
aiSettings: { model: "coder:openai/gpt-6-astra", thinkingLevel: "high" },
messages: [],
routePriority: ["coder"],
providersConfig,
Expand Down
4 changes: 1 addition & 3 deletions src/browser/stories/App.tokenBudget.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { expect, userEvent, waitFor, within } from "@storybook/test";
import { createMuxMessage } from "@/common/types/message";
import { createContextBudgetRejectedMessage } from "@/common/utils/messages/contextBudgetRejection";
import { EXPERIMENT_IDS } from "@/common/constants/experiments";
import { getModelKey } from "@/common/constants/storage";
import { updatePersistedState } from "@/browser/hooks/usePersistedState";
import { NARROW_VIEWPORT_MAX_WIDTH_PX } from "@/constants/layout";
import { appMeta, AppWithMocks, type AppStory } from "./meta.js";
import { setupSimpleChatStory } from "./helpers/chatSetup";
Expand All @@ -27,7 +25,6 @@ const LEAD_IN = "Model-only instructions for retrieving earlier context windows.

function setupTokenBudgetStory(inputTokens = 2400) {
collapseLeftSidebar();
updatePersistedState(getModelKey(WORKSPACE_ID), MODEL);
const history = [
createMuxMessage("earlier", "user", "Keep the migration reversible.", {
historySequence: 1,
Expand Down Expand Up @@ -109,6 +106,7 @@ function setupTokenBudgetStory(inputTokens = 2400) {
return setupSimpleChatStory({
workspaceId: WORKSPACE_ID,
workspaceName: "token-budget",
aiSettings: { model: MODEL, thinkingLevel: "off" },
experiments: { [EXPERIMENT_IDS.TOKEN_BUDGET]: true, [EXPERIMENT_IDS.MEMORY]: true },
userPreferences: { ai: { autoCompactionThresholdByModel: { [MODEL]: 70 } } },
messages: [
Expand Down
2 changes: 2 additions & 0 deletions src/browser/stories/helpers/chatSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export interface SimpleChatSetupOptions {
timelineEvents?: TimelineEvent[];
/** Render the chat workspace as transcript-only (worktree gone; no composer). */
transcriptOnly?: boolean;
aiSettings?: FrontendWorkspaceMetadata["aiSettings"];
}

/**
Expand All @@ -124,6 +125,7 @@ export function setupSimpleChatStory(opts: SimpleChatSetupOptions): APIClient {
projectName,
projectPath,
transcriptOnly: opts.transcriptOnly,
aiSettings: opts.aiSettings,
}),
...(opts.additionalWorkspaces ?? []),
];
Expand Down
2 changes: 2 additions & 0 deletions src/browser/stories/mocks/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface WorkspaceFixture {
pinnedAt?: string;
/** Recipient consent generation; present means cross-tree discovery/messaging is on. */
unrelatedWorkspaceConsent?: string;
aiSettings?: FrontendWorkspaceMetadata["aiSettings"];
}

/** Create a workspace with sensible defaults */
Expand All @@ -54,6 +55,7 @@ export function createWorkspace(
transcriptOnly: opts.transcriptOnly,
pinnedAt: opts.pinnedAt,
unrelatedWorkspaceConsent: opts.unrelatedWorkspaceConsent,
aiSettings: opts.aiSettings,
};
}

Expand Down
Loading