-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: generate thread titles with the selected model across connections #10526
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
Changes from all commits
b82e934
b49f9dc
e2b5532
d1c48ce
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 |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import type { | |
| ServerSettings, | ||
| ServerSettingsPatch, | ||
| } from "@t3tools/contracts"; | ||
| import { isModelSelectionProviderEnabled } from "@t3tools/shared/serverSettings"; | ||
| import * as Equal from "effect/Equal"; | ||
| import * as Struct from "effect/Struct"; | ||
|
|
||
|
|
@@ -26,6 +27,7 @@ const SHARED_SERVER_SETTING_KEYS = [ | |
| "sidebarAutoSettleOnMerge", | ||
| "newWorktreesStartFromOrigin", | ||
| "sourceControlWritingStyle", | ||
| "textGenerationModelSelection", | ||
| ] as const satisfies ReadonlyArray<keyof ServerSettings & keyof ServerSettingsPatch>; | ||
|
|
||
| export type SharedServerSettingKey = (typeof SHARED_SERVER_SETTING_KEYS)[number]; | ||
|
|
@@ -52,11 +54,31 @@ export function splitSharedServerPatch(patch: ServerSettingsPatch): { | |
| }; | ||
| } | ||
|
|
||
| /** Omit restart recovery on servers that cannot persist its preference. */ | ||
| /** Filter unsupported preferences; direct model writes retain the server's fallback behavior. */ | ||
| export function filterSharedServerPatch( | ||
| patch: ServerSettingsPatch, | ||
| capabilities: Pick<ExecutionEnvironmentCapabilities, "threadRestartContinuation"> | undefined, | ||
| settings?: ServerSettings, | ||
| sourceSettings = settings, | ||
| targetIsSource = false, | ||
| ): ServerSettingsPatch { | ||
| const instanceId = | ||
| patch.textGenerationModelSelection?.instanceId ?? | ||
| sourceSettings?.textGenerationModelSelection.instanceId; | ||
| if ( | ||
| !targetIsSource && | ||
|
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 8 \
'\bModelSelectionPatch\b|\btextGenerationModelSelection\b' \
packages/contracts packages/client-runtime apps/web apps/mobile \
--glob '*.ts' --glob '*.tsx'
rg -n -C 8 \
'filterSharedServerPatch\(' \
packages/client-runtime apps/web apps/mobile \
--glob '*.ts' --glob '*.tsx'Repository: pingdotgg/t3code Length of output: 50372 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- sharedSettings.ts ---'
sed -n '1,95p' packages/client-runtime/src/state/sharedSettings.ts
printf '%s\n' '--- isModelSelectionProviderEnabled binding ---'
rg -n -C 12 \
'export (function|const) isModelSelectionProviderEnabled|function isModelSelectionProviderEnabled|isModelSelectionProviderEnabled\s*=' \
packages apps --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- patch construction sites ---'
rg -n -C 6 \
'textGenerationModelSelection\s*:' \
packages apps --glob '*.ts' --glob '*.tsx' \
| grep -E '(^|:)([0-9]+):|textGenerationModelSelection|instanceId|model|options' \
| head -240Repository: pingdotgg/t3code Length of output: 26115 🤖 get_repo_knowledge executed:
Length of output: 2601 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- sharedSettings.ts ---'
sed -n '1,95p' packages/client-runtime/src/state/sharedSettings.ts
printf '%s\n' '--- isModelSelectionProviderEnabled binding ---'
rg -n -C 12 \
'export (function|const) isModelSelectionProviderEnabled|function isModelSelectionProviderEnabled|isModelSelectionProviderEnabled\s*=' \
packages apps --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- model-selection patch producers (focused) ---'
rg -n -C 5 \
'textGenerationModelSelection\s*:' \
packages/client-runtime apps/web apps/mobile \
--glob '*.ts' --glob '*.tsx' \
| head -260Repository: pingdotgg/t3code Length of output: 28239 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 14 'isModelSelectionProviderEnabled' packages apps --glob '*.ts' --glob '*.tsx' | head -180Repository: pingdotgg/t3code Length of output: 14925 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -l 'isModelSelectionProviderEnabled' packages apps --glob '*.ts' --glob '*.tsx' |
while IFS= read -r file; do
echo "--- $file ---"
rg -n -C 10 'isModelSelectionProviderEnabled' "$file"
doneRepository: pingdotgg/t3code Length of output: 7682 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '250,325p' packages/shared/src/serverSettings.tsRepository: pingdotgg/t3code Length of output: 2667 Validate partial model-selection patches against the target selection.
🤖 Prompt for AI Agents |
||
| patch.textGenerationModelSelection && | ||
| (!settings || | ||
| (instanceId !== undefined && | ||
| (sourceSettings?.providerInstances[instanceId]?.driver ?? instanceId) !== | ||
| (settings.providerInstances[instanceId]?.driver ?? instanceId)) || | ||
| !isModelSelectionProviderEnabled(settings, { | ||
| ...settings.textGenerationModelSelection, | ||
| ...patch.textGenerationModelSelection, | ||
| })) | ||
| ) { | ||
| patch = Struct.omit(patch, ["textGenerationModelSelection"]); | ||
| } | ||
| return capabilities?.threadRestartContinuation === true | ||
| ? patch | ||
| : Struct.omit(patch, ["continueThreadsAfterServerUpdate"]); | ||
|
|
@@ -67,7 +89,11 @@ export function pickSharedServerSettings( | |
| settings: ServerSettings, | ||
| capabilities?: Pick<ExecutionEnvironmentCapabilities, "threadRestartContinuation">, | ||
| ): ServerSettingsPatch { | ||
| return filterSharedServerPatch(Struct.pick(settings, SHARED_SERVER_SETTING_KEYS), capabilities); | ||
| return filterSharedServerPatch( | ||
| Struct.pick(settings, SHARED_SERVER_SETTING_KEYS), | ||
| capabilities, | ||
| settings, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -129,11 +155,20 @@ export function findSharedSettingsMismatches(input: { | |
| ) { | ||
| return []; | ||
| } | ||
| const expected = filterSharedServerPatch(primarySettings, environment.capabilities); | ||
| const actual = filterSharedServerPatch( | ||
| const expected = filterSharedServerPatch( | ||
| primarySettings, | ||
| environment.capabilities, | ||
| environment.settings, | ||
| input.primarySettings ?? undefined, | ||
| ); | ||
| let actual = filterSharedServerPatch( | ||
| pickSharedServerSettings(environment.settings, environment.capabilities), | ||
| input.primaryCapabilities, | ||
| environment.settings, | ||
| ); | ||
| if (!expected.textGenerationModelSelection) { | ||
| actual = Struct.omit(actual, ["textGenerationModelSelection"]); | ||
| } | ||
| return Equal.equals(actual, expected) | ||
| ? [] | ||
| : [{ environmentId: environment.environmentId, label: environment.label }]; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.