Repository navigation
fix: new threads keep their project's last-used model and modes #23524
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.
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
base: main
Are you sure you want to change the base?
Changes from all commits
4571dcf
9602b0e
552b04e
8b2a2b8
4837d5b
ae7039a
7dca654
c99d121
281840b
5ed60b5
f2ff60b
0ac51a3
ad75883
616dbce
a913b30
fc32707
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ import { useProjectPin } from "~/hooks/useProjectGroupUpdate"; | |
| import { useScratchProject } from "~/hooks/useScratchProject"; | ||
| import { isTriagePrompt } from "~/hooks/useStartTriage"; | ||
| import { useClientSettings } from "~/hooks/useSettings"; | ||
| import { hasExplicitComposerModelSelection } from "~/lib/chatThreadActions"; | ||
| import { retargetDraftToProject } from "~/lib/chatThreadActions"; | ||
| import { | ||
| deriveLogicalProjectKeyFromSettings, | ||
| pickableProjectGroups, | ||
|
|
@@ -52,9 +52,6 @@ import { InlineButton } from "../ui/button"; | |
| import { DraftProjectName } from "./DraftProjectName"; | ||
| import { DraftHeroProjectHeading } from "./DraftHeroProjectHeading"; | ||
| import { TriageDraftHero } from "./TriageDraftHero"; | ||
| import { resolveProjectSettings } from "@t3tools/shared/projectSettings"; | ||
| import { resolveProjectDefaultProviderModelSelection } from "../../providerInstances"; | ||
| import { resolveNewThreadModelSelection } from "@t3tools/shared/usageLimits"; | ||
|
|
||
| const ADD_PROJECT_VALUE = "add-project"; | ||
|
|
||
|
|
@@ -81,16 +78,11 @@ export function DraftHeroHeadline({ | |
| const primaryEnvironmentId = usePrimaryEnvironmentId(); | ||
| const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings); | ||
| const projectSortOrder = useClientSettings((settings) => settings.sidebarProjectSortOrder); | ||
| const setLogicalProjectDraftThreadId = useComposerDraftStore( | ||
| (store) => store.setLogicalProjectDraftThreadId, | ||
| ); | ||
| const getComposerDraft = useComposerDraftStore((store) => store.getComposerDraft); | ||
| // A boolean, so typing in a draft does not re-render the hero. | ||
| const isTriageDraftPrompt = useComposerDraftStore((store) => | ||
| draftId ? isTriagePrompt(store.getComposerDraft(draftId)?.prompt ?? "") : false, | ||
| ); | ||
| const applyStickyState = useComposerDraftStore((store) => store.applyStickyState); | ||
| const setModelSelection = useComposerDraftStore((store) => store.setModelSelection); | ||
| const openAddProject = () => openCommandPalette({ open: "add-project" }); | ||
| const { scratchEnvironmentId, scratchWorkspaceRootFor, openScratchProject } = useScratchProject(); | ||
| const openProjectDraft = useNewThreadHandler(); | ||
|
|
@@ -203,46 +195,20 @@ export function DraftHeroHeadline({ | |
| void openProjectDraft(scopeProjectRef(project.environmentId, project.id)); | ||
| return; | ||
| } | ||
| setLogicalProjectDraftThreadId( | ||
| logicalProjectKey, | ||
| scopeProjectRef(project.environmentId, project.id), | ||
| const targetServerConfig = environments.find( | ||
| (environment) => environment.environmentId === project.environmentId, | ||
| )?.serverConfig; | ||
| retargetDraftToProject({ | ||
| draftId, | ||
| ); | ||
| if (!hasExplicitComposerModelSelection(currentDraft)) { | ||
| applyStickyState(draftId); | ||
| const environmentConfig = environments.find( | ||
| (environment) => environment.environmentId === project.environmentId, | ||
| )?.serverConfig; | ||
| const environmentSettings = environmentConfig?.settings; | ||
| const defaultSelection = environmentSettings | ||
| ? resolveProjectSettings(environmentSettings, project.id, project).settings | ||
| .defaultModelSelection | ||
| : project.defaultModelSelection; | ||
| const fallbackResolution = resolveNewThreadModelSelection({ | ||
| defaultSelection: | ||
| defaultSelection ?? | ||
| (useComposerDraftStore.getState().stickyActiveProvider !== null || !environmentSettings | ||
| ? null | ||
| : resolveProjectDefaultProviderModelSelection( | ||
| providersByEnvironment.get(project.environmentId) ?? [], | ||
| environmentSettings, | ||
| project.id, | ||
| )), | ||
| fallbackSelection: environmentSettings?.fallbackModelSelection ?? null, | ||
| providers: providersByEnvironment.get(project.environmentId) ?? [], | ||
| ...(environmentSettings ? { settings: environmentSettings } : {}), | ||
| projectId: project.id, | ||
| now: Date.now(), | ||
| }); | ||
| const defaultModelSelection = fallbackResolution.fallback | ||
| ? fallbackResolution.selection | ||
| : defaultSelection; | ||
| if (defaultModelSelection) { | ||
| setModelSelection(draftId, defaultModelSelection, { | ||
| replaceOptions: true, | ||
| }); | ||
| } | ||
| } | ||
| projectRef: scopeProjectRef(project.environmentId, project.id), | ||
| project, | ||
| environmentSettings: targetServerConfig?.settings, | ||
| managedPolicy: targetServerConfig?.managedPolicy, | ||
| providers: providersByEnvironment.get(project.environmentId) ?? [], | ||
| threads, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| logicalProjectKey, | ||
| refreshModel: true, | ||
| }); | ||
| }; | ||
| const startScratch = async (): Promise<boolean> => { | ||
| if (scratchTargetEnvironmentId === null || isScratchDraft) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
chat/DraftHeroHeadline.tsx:208Retargeting a populated draft can inherit an older thread’s model or runtime mode when the project’s most recently used thread is hidden by the tag filter; if all its threads are hidden, it falls back to environment defaults.
threadscomes fromuseVisibleThreadShells(), andresolveProjectLastUsedSettingssearches only the supplied array, so pass complete thread shells toretargetDraftToProjectinstead.🚀 Reply "fix it for me" or copy this AI Prompt for your agent: