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(clients): honor project default models in new threads (#6011) · incognitojam/styal@8e9c647

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • mobile/src
      • features/threads
        • NewTaskDraftScreen.tsx
        • new-task-flow-provider.tsx
      • lib
        • modelOptions.test.ts
        • modelOptions.ts
      • state
        • use-composer-drafts.test.ts
        • use-composer-drafts.ts
    • web/src
      • components
        • ChatView.tsx
      • composerDraftStore.test.ts
      • composerDraftStore.ts
      • hooks
        • useHandleNewThread.ts
      • lib
        • chatThreadActions.test.ts
        • chatThreadActions.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ export function NewTaskDraftScreen(props: {
897897
flow.finishEditingPendingTask();
898898
} else {
899899
clearComposerDraftContent(draftKey, {
900+
clearModelSelection: true,
900901
clearWorkspaceSelection: true,
901902
deferAttachmentCleanup: true,
902903
});
Collapse file

‎apps/mobile/src/features/threads/new-task-flow-provider.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/new-task-flow-provider.tsx
+27-11Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
buildModelOptions,
3434
groupByProvider,
3535
resolveDefaultableModelSelection,
36+
resolveNewTaskModelSelection,
3637
resolveSelectableModelSelection,
3738
} from "../../lib/modelOptions";
3839
import { scopedProjectKey } from "../../lib/scopedEntities";
@@ -49,8 +50,10 @@ import {
4950
replaceComposerDraftAttachments,
5051
scheduleUnusedComposerAttachmentCleanup,
5152
setComposerDraftText,
53+
setStickyComposerModelSelection,
5254
updateComposerDraftSettings,
5355
useComposerDraft,
56+
useStickyComposerModelSelection,
5457
} from "../../state/use-composer-drafts";
5558
import {
5659
capturePendingTaskEditorWriteBaseline,
@@ -430,21 +433,33 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
430433
selectedEnvironmentServerConfig,
431434
selectedProject?.defaultModelSelection ?? null,
432435
);
436+
const storedStickyModelSelection = useStickyComposerModelSelection();
437+
const stickyModelSelection = resolveDefaultableModelSelection(
438+
selectedEnvironmentServerConfig,
439+
storedStickyModelSelection,
440+
);
433441
const modelOptions = useMemo(
434442
() =>
435443
buildModelOptions(
436444
selectedEnvironmentServerConfig,
437-
draftModelSelection ?? projectDefaultModelSelection,
445+
draftModelSelection ?? projectDefaultModelSelection ?? stickyModelSelection,
438446
),
439-
[selectedEnvironmentServerConfig, draftModelSelection, projectDefaultModelSelection],
447+
[
448+
selectedEnvironmentServerConfig,
449+
draftModelSelection,
450+
projectDefaultModelSelection,
451+
stickyModelSelection,
452+
],
440453
);
441454

442-
const selectedModel =
443-
draftModelSelection ??
444-
projectDefaultModelSelection ??
445-
modelOptions.find((option) => option.isDefault)?.selection ??
446-
modelOptions[0]?.selection ??
447-
null;
455+
// An unsent draft keeps its explicit pick. Fresh drafts resolve the project
456+
// default before the last manual app-wide selection and provider default.
457+
const selectedModel = resolveNewTaskModelSelection({
458+
draftSelection: draftModelSelection,
459+
projectDefaultSelection: projectDefaultModelSelection,
460+
stickySelection: stickyModelSelection,
461+
modelOptions,
462+
});
448463
const selectedModelKey = selectedModel
449464
? `${selectedModel.instanceId}:${selectedModel.model}`
450465
: null;
@@ -474,9 +489,9 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
474489
if (!option) {
475490
return;
476491
}
477-
updateComposerDraftSettings(selectedProjectDraftKey, {
478-
modelSelection: options ? { ...option.selection, options } : option.selection,
479-
});
492+
const selection = options ? { ...option.selection, options } : option.selection;
493+
updateComposerDraftSettings(selectedProjectDraftKey, { modelSelection: selection });
494+
setStickyComposerModelSelection(selection);
480495
},
481496
[modelOptions, selectedProjectDraftKey],
482497
);
@@ -494,6 +509,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
494509
updateComposerDraftSettings(selectedProjectDraftKey, {
495510
modelSelection: nextSelection,
496511
});
512+
setStickyComposerModelSelection(nextSelection);
497513
},
498514
[selectedModel, selectedProjectDraftKey],
499515
);
Collapse file

‎apps/mobile/src/lib/modelOptions.test.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/lib/modelOptions.test.ts
+29-1Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { describe, expect, it } from "vite-plus/test";
22

3-
import { ProviderInstanceId, type ServerConfig } from "@t3tools/contracts";
3+
import { ProviderInstanceId, type ModelSelection, type ServerConfig } from "@t3tools/contracts";
44

55
import {
66
buildModelOptions,
77
groupByProvider,
88
resolveDefaultableModelSelection,
9+
resolveNewTaskModelSelection,
910
resolveSelectableModelSelection,
11+
type ModelOption,
1012
} from "./modelOptions";
1113

1214
describe("mobile model options", () => {
@@ -220,4 +222,30 @@ describe("mobile model options", () => {
220222
// Offline: nothing to validate against, selection passes through.
221223
expect(resolveDefaultableModelSelection(null, legacy)).toBe(legacy);
222224
});
225+
226+
it("resolves new tasks from draft, project, sticky, then provider defaults", () => {
227+
const draft = { instanceId: ProviderInstanceId.make("codex"), model: "draft" };
228+
const project = { instanceId: ProviderInstanceId.make("codex"), model: "project" };
229+
const sticky = { instanceId: ProviderInstanceId.make("codex"), model: "sticky" };
230+
const providerDefault = {
231+
selection: { instanceId: ProviderInstanceId.make("codex"), model: "default" },
232+
isDefault: true,
233+
} as ModelOption;
234+
const resolve = (
235+
draftSelection: ModelSelection | null,
236+
projectDefaultSelection: ModelSelection | null,
237+
stickySelection: ModelSelection | null,
238+
) =>
239+
resolveNewTaskModelSelection({
240+
draftSelection,
241+
projectDefaultSelection,
242+
stickySelection,
243+
modelOptions: [providerDefault],
244+
});
245+
246+
expect(resolve(draft, project, sticky)).toBe(draft);
247+
expect(resolve(null, project, sticky)).toBe(project);
248+
expect(resolve(null, null, sticky)).toBe(sticky);
249+
expect(resolve(null, null, null)).toBe(providerDefault.selection);
250+
});
223251
});
Collapse file

‎apps/mobile/src/lib/modelOptions.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/lib/modelOptions.ts
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ export function resolveDefaultableModelSelection(
104104
return model?.isLegacy === true ? null : usable;
105105
}
106106

107+
export function resolveNewTaskModelSelection(input: {
108+
readonly draftSelection: ModelSelection | null;
109+
readonly projectDefaultSelection: ModelSelection | null;
110+
readonly stickySelection: ModelSelection | null;
111+
readonly modelOptions: ReadonlyArray<ModelOption>;
112+
}): ModelSelection | null {
113+
return (
114+
input.draftSelection ??
115+
input.projectDefaultSelection ??
116+
input.stickySelection ??
117+
input.modelOptions.find((option) => option.isDefault)?.selection ??
118+
input.modelOptions[0]?.selection ??
119+
null
120+
);
121+
}
122+
107123
export function buildModelOptions(
108124
config: T3ServerConfig | null | undefined,
109125
fallbackModelSelection: ModelSelection | null,

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.