Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3fa2a2553 | ||
|
|
9143d3bbe0 |
No files matched your search
@@ -727,16 +727,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
prompt,
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
}),
|
||||
[
|
||||
composerModelOptions,
|
||||
prompt,
|
||||
selectedInstanceId,
|
||||
selectedModel,
|
||||
selectedProvider,
|
||||
selectedProviderModels,
|
||||
],
|
||||
[composerModelOptions, prompt, selectedModel, selectedProvider, selectedProviderModels],
|
||||
);
|
||||
|
||||
const selectedPromptEffort = composerProviderState.promptEffort;
|
||||
@@ -1025,23 +1018,21 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
|
||||
const providerTraitsMenuContent = renderProviderTraitsMenuContent({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
const providerTraitsPicker = renderProviderTraitsPicker({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionDescriptor,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
@@ -197,7 +196,6 @@ export function shouldRenderTraitsControls(input: {
|
||||
|
||||
export interface TraitsMenuContentProps {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
model: string | null | undefined;
|
||||
prompt: string;
|
||||
@@ -210,7 +208,6 @@ export interface TraitsMenuContentProps {
|
||||
|
||||
export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -231,12 +228,11 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
return;
|
||||
}
|
||||
setProviderModelOptions(threadTarget, provider, nextOptions, {
|
||||
...(instanceId ? { instanceId } : {}),
|
||||
model,
|
||||
persistSticky: true,
|
||||
});
|
||||
},
|
||||
[instanceId, model, persistence, provider, setProviderModelOptions],
|
||||
[model, persistence, provider, setProviderModelOptions],
|
||||
);
|
||||
const {
|
||||
descriptors,
|
||||
@@ -347,7 +343,6 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
|
||||
export const TraitsPicker = memo(function TraitsPicker({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -436,7 +431,6 @@ export const TraitsPicker = memo(function TraitsPicker({
|
||||
<MenuPopup align="start">
|
||||
<TraitsMenuContent
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
model={model}
|
||||
prompt={prompt}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
type ServerProviderModel,
|
||||
@@ -36,7 +35,6 @@ export type ComposerProviderState = {
|
||||
|
||||
type TraitsRenderInput = {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
@@ -78,17 +76,8 @@ function renderTraitsControl(
|
||||
Component: typeof TraitsMenuContent | typeof TraitsPicker,
|
||||
input: TraitsRenderInput,
|
||||
): ReactNode {
|
||||
const {
|
||||
provider,
|
||||
instanceId,
|
||||
threadRef,
|
||||
draftId,
|
||||
model,
|
||||
models,
|
||||
modelOptions,
|
||||
prompt,
|
||||
onPromptChange,
|
||||
} = input;
|
||||
const { provider, threadRef, draftId, model, models, modelOptions, prompt, onPromptChange } =
|
||||
input;
|
||||
const hasTarget = threadRef !== undefined || draftId !== undefined;
|
||||
if (
|
||||
!hasTarget ||
|
||||
@@ -99,7 +88,6 @@ function renderTraitsControl(
|
||||
return (
|
||||
<Component
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { DesktopSshPasswordPromptRequest } from "@t3tools/contracts";
|
||||
import { useEffect, useId, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useId, useRef, useState, type RefObject } from "react";
|
||||
|
||||
import { Button } from "../ui/button";
|
||||
import {
|
||||
@@ -28,16 +28,10 @@ function getPromptErrorMessage(error: unknown): string {
|
||||
: message;
|
||||
}
|
||||
|
||||
export function SshPasswordPromptDialog() {
|
||||
const EXPIRED_PROMPT_ERROR = "This SSH password prompt expired. Try connecting again.";
|
||||
|
||||
function useSshPasswordPromptQueue() {
|
||||
const [queue, setQueue] = useState<readonly DesktopSshPasswordPromptRequest[]>([]);
|
||||
const [password, setPassword] = useState("");
|
||||
const [isResponding, setIsResponding] = useState(false);
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const [responseError, setResponseError] = useState<string | null>(null);
|
||||
const currentRequest = queue[0] ?? null;
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
const isRespondingRef = useRef(false);
|
||||
const formId = useId();
|
||||
|
||||
useEffect(() => {
|
||||
const bridge = window.desktopBridge;
|
||||
@@ -50,14 +44,23 @@ export function SshPasswordPromptDialog() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setPassword("");
|
||||
setResponseError(null);
|
||||
if (!currentRequest) {
|
||||
return;
|
||||
}
|
||||
const removeCurrentPrompt = useCallback((requestId: string) => {
|
||||
setQueue((currentQueue) =>
|
||||
currentQueue[0]?.requestId === requestId ? currentQueue.slice(1) : currentQueue,
|
||||
);
|
||||
}, []);
|
||||
|
||||
setNow(Date.now());
|
||||
return {
|
||||
currentRequest: queue[0] ?? null,
|
||||
removeCurrentPrompt,
|
||||
};
|
||||
}
|
||||
|
||||
function useSshPasswordPromptFocus(
|
||||
requestId: string,
|
||||
inputRef: RefObject<HTMLInputElement | null>,
|
||||
) {
|
||||
useEffect(() => {
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
inputRef.current?.focus();
|
||||
inputRef.current?.select();
|
||||
@@ -65,50 +68,72 @@ export function SshPasswordPromptDialog() {
|
||||
return () => {
|
||||
window.cancelAnimationFrame(frame);
|
||||
};
|
||||
}, [currentRequest]);
|
||||
}, [inputRef, requestId]);
|
||||
}
|
||||
|
||||
function useSshPasswordPromptNow(requestId: string) {
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentRequest) {
|
||||
return;
|
||||
}
|
||||
|
||||
const interval = window.setInterval(() => {
|
||||
setNow(Date.now());
|
||||
}, 1_000);
|
||||
return () => {
|
||||
window.clearInterval(interval);
|
||||
};
|
||||
}, [currentRequest]);
|
||||
}, [requestId]);
|
||||
|
||||
const expiresAtMs = currentRequest ? Date.parse(currentRequest.expiresAt) : Number.NaN;
|
||||
return now;
|
||||
}
|
||||
|
||||
export function SshPasswordPromptDialog() {
|
||||
const { currentRequest, removeCurrentPrompt } = useSshPasswordPromptQueue();
|
||||
|
||||
if (!currentRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SshPasswordPromptRequestDialog
|
||||
key={currentRequest.requestId}
|
||||
currentRequest={currentRequest}
|
||||
removeCurrentPrompt={removeCurrentPrompt}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function SshPasswordPromptRequestDialog({
|
||||
currentRequest,
|
||||
removeCurrentPrompt,
|
||||
}: {
|
||||
currentRequest: DesktopSshPasswordPromptRequest;
|
||||
removeCurrentPrompt: (requestId: string) => void;
|
||||
}) {
|
||||
const [password, setPassword] = useState("");
|
||||
const [isResponding, setIsResponding] = useState(false);
|
||||
const [responseError, setResponseError] = useState<string | null>(null);
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
const isRespondingRef = useRef(false);
|
||||
const formId = useId();
|
||||
const now = useSshPasswordPromptNow(currentRequest.requestId);
|
||||
useSshPasswordPromptFocus(currentRequest.requestId, inputRef);
|
||||
|
||||
const expiresAtMs = Date.parse(currentRequest.expiresAt);
|
||||
const remainingMs = Number.isFinite(expiresAtMs) ? Math.max(0, expiresAtMs - now) : null;
|
||||
const isExpired = remainingMs !== null && remainingMs <= 0;
|
||||
const remainingSeconds = remainingMs === null ? null : Math.ceil(remainingMs / 1_000);
|
||||
const remainingLabel =
|
||||
remainingSeconds === null ? null : formatRemainingSeconds(remainingSeconds);
|
||||
|
||||
useEffect(() => {
|
||||
if (isExpired) {
|
||||
setResponseError("This SSH password prompt expired. Try connecting again.");
|
||||
}
|
||||
}, [isExpired]);
|
||||
|
||||
const removeCurrentPrompt = (requestId: string) => {
|
||||
setQueue((currentQueue) =>
|
||||
currentQueue[0]?.requestId === requestId ? currentQueue.slice(1) : currentQueue,
|
||||
);
|
||||
setPassword("");
|
||||
setResponseError(null);
|
||||
};
|
||||
const displayedError = isExpired ? EXPIRED_PROMPT_ERROR : responseError;
|
||||
|
||||
const respond = async (nextPassword: string | null) => {
|
||||
if (!currentRequest || isRespondingRef.current) {
|
||||
if (isRespondingRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const requestId = currentRequest.requestId;
|
||||
if (nextPassword !== null && isExpired) {
|
||||
setResponseError("This SSH password prompt expired. Try connecting again.");
|
||||
setResponseError(EXPIRED_PROMPT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,8 +223,8 @@ export function SshPasswordPromptDialog() {
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{responseError ? (
|
||||
<p className="text-sm text-destructive">{responseError}</p>
|
||||
{displayedError ? (
|
||||
<p className="text-sm text-destructive">{displayedError}</p>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Use SSH keys to avoid repeated password prompts on new SSH sessions.
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import type { ServerProvider } from "@t3tools/contracts";
|
||||
import { CircleCheckIcon, DownloadIcon, LoaderIcon, TriangleAlertIcon, XIcon } from "lucide-react";
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type CSSProperties,
|
||||
type Dispatch,
|
||||
type SetStateAction,
|
||||
type TransitionEvent,
|
||||
} from "react";
|
||||
import { useCallback, useEffect, useState, type CSSProperties } from "react";
|
||||
|
||||
import { useServerProviders } from "../../rpc/serverState";
|
||||
import {
|
||||
@@ -46,36 +37,48 @@ function latestProviderCheckedAt(
|
||||
);
|
||||
}
|
||||
|
||||
function useProviderUpdateVisibleAfterIso(
|
||||
providers: ReadonlyArray<Pick<ServerProvider, "checkedAt">>,
|
||||
): string | undefined {
|
||||
const visibleAfterIsoRef = useRef<string | undefined>(undefined);
|
||||
|
||||
if (visibleAfterIsoRef.current === undefined) {
|
||||
visibleAfterIsoRef.current = latestProviderCheckedAt(providers);
|
||||
}
|
||||
|
||||
return visibleAfterIsoRef.current;
|
||||
}
|
||||
|
||||
function useDisplayedProviderUpdatePill(input: {
|
||||
view: ProviderUpdateSidebarPillView | null;
|
||||
setDismissedKeys: Dispatch<SetStateAction<ReadonlySet<string>>>;
|
||||
}) {
|
||||
const { view, setDismissedKeys } = input;
|
||||
const [renderedView, setRenderedView] = useState<ProviderUpdateSidebarPillView | null>(view);
|
||||
export function SidebarProviderUpdatePill() {
|
||||
const navigate = useNavigate();
|
||||
const providers = useServerProviders();
|
||||
const [dismissedKeys, setDismissedKeys] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const [renderedView, setRenderedView] = useState<ProviderUpdateSidebarPillView | null>(null);
|
||||
const [pendingView, setPendingView] = useState<ProviderUpdateSidebarPillView | null>(null);
|
||||
const [exitingKey, setExitingKey] = useState<string | null>(null);
|
||||
const pendingViewRef = useRef<ProviderUpdateSidebarPillView | null>(null);
|
||||
const dismissAfterExitKeyRef = useRef<string | null>(null);
|
||||
const [dismissAfterExitKey, setDismissAfterExitKey] = useState<string | null>(null);
|
||||
const [visibleAfterIso, setVisibleAfterIso] = useState<string | undefined>();
|
||||
const effectiveVisibleAfterIso = visibleAfterIso ?? latestProviderCheckedAt(providers);
|
||||
const view = getProviderUpdateSidebarPillView(providers, {
|
||||
...(effectiveVisibleAfterIso !== undefined
|
||||
? { visibleAfterIso: effectiveVisibleAfterIso }
|
||||
: {}),
|
||||
dismissedKeys,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (visibleAfterIso === undefined && effectiveVisibleAfterIso !== undefined) {
|
||||
setVisibleAfterIso(effectiveVisibleAfterIso);
|
||||
}
|
||||
}, [effectiveVisibleAfterIso, visibleAfterIso]);
|
||||
|
||||
const openProviderSettings = useCallback(() => {
|
||||
void navigate({ to: "/settings/providers" });
|
||||
}, [navigate]);
|
||||
const displayedView = renderedView ?? view;
|
||||
const dismissAfterVisibleMs = displayedView?.dismissAfterVisibleMs;
|
||||
const viewKey = displayedView?.key ?? null;
|
||||
const showDismissProgress =
|
||||
dismissAfterVisibleMs !== undefined &&
|
||||
displayedView?.tone !== "loading" &&
|
||||
exitingKey !== viewKey;
|
||||
|
||||
const startExit = useCallback(
|
||||
(key: string, nextView: ProviderUpdateSidebarPillView | null, dismissKey?: string) => {
|
||||
if (exitingKey === key) {
|
||||
return;
|
||||
}
|
||||
pendingViewRef.current = nextView;
|
||||
dismissAfterExitKeyRef.current = dismissKey ?? null;
|
||||
setPendingView(nextView);
|
||||
setExitingKey(key);
|
||||
setDismissAfterExitKey(dismissKey ?? null);
|
||||
},
|
||||
[exitingKey],
|
||||
);
|
||||
@@ -100,46 +103,6 @@ function useDisplayedProviderUpdatePill(input: {
|
||||
}
|
||||
}, [exitingKey, renderedView, startExit, view]);
|
||||
|
||||
const displayedView = renderedView ?? view;
|
||||
const onTransitionEnd = useCallback(
|
||||
(event: TransitionEvent<HTMLDivElement>) => {
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
if (!displayedView || exitingKey !== displayedView.key) {
|
||||
return;
|
||||
}
|
||||
if (dismissAfterExitKeyRef.current === displayedView.key) {
|
||||
setDismissedKeys((previous) => new Set(previous).add(displayedView.key));
|
||||
}
|
||||
setRenderedView(pendingViewRef.current);
|
||||
pendingViewRef.current = null;
|
||||
dismissAfterExitKeyRef.current = null;
|
||||
setExitingKey(null);
|
||||
},
|
||||
[displayedView, exitingKey, setDismissedKeys],
|
||||
);
|
||||
|
||||
return {
|
||||
displayedView,
|
||||
exitingKey,
|
||||
onTransitionEnd,
|
||||
startExit,
|
||||
};
|
||||
}
|
||||
|
||||
function useProviderUpdateAutoDismiss(input: {
|
||||
dismissAfterVisibleMs: number | undefined;
|
||||
exitingKey: string | null;
|
||||
startExit: (
|
||||
key: string,
|
||||
nextView: ProviderUpdateSidebarPillView | null,
|
||||
dismissKey?: string,
|
||||
) => void;
|
||||
viewKey: string | null;
|
||||
}) {
|
||||
const { dismissAfterVisibleMs, exitingKey, startExit, viewKey } = input;
|
||||
|
||||
useEffect(() => {
|
||||
if (!dismissAfterVisibleMs || !viewKey) {
|
||||
return;
|
||||
@@ -153,40 +116,6 @@ function useProviderUpdateAutoDismiss(input: {
|
||||
|
||||
return () => window.clearTimeout(timeoutId);
|
||||
}, [dismissAfterVisibleMs, exitingKey, startExit, viewKey]);
|
||||
}
|
||||
|
||||
export function SidebarProviderUpdatePill() {
|
||||
const navigate = useNavigate();
|
||||
const providers = useServerProviders();
|
||||
const [dismissedKeys, setDismissedKeys] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const effectiveVisibleAfterIso = useProviderUpdateVisibleAfterIso(providers);
|
||||
const view = getProviderUpdateSidebarPillView(providers, {
|
||||
...(effectiveVisibleAfterIso !== undefined
|
||||
? { visibleAfterIso: effectiveVisibleAfterIso }
|
||||
: {}),
|
||||
dismissedKeys,
|
||||
});
|
||||
|
||||
const openProviderSettings = useCallback(() => {
|
||||
void navigate({ to: "/settings/providers" });
|
||||
}, [navigate]);
|
||||
const { displayedView, exitingKey, onTransitionEnd, startExit } = useDisplayedProviderUpdatePill({
|
||||
view,
|
||||
setDismissedKeys,
|
||||
});
|
||||
const dismissAfterVisibleMs = displayedView?.dismissAfterVisibleMs;
|
||||
const viewKey = displayedView?.key ?? null;
|
||||
const showDismissProgress =
|
||||
dismissAfterVisibleMs !== undefined &&
|
||||
displayedView?.tone !== "loading" &&
|
||||
exitingKey !== viewKey;
|
||||
|
||||
useProviderUpdateAutoDismiss({
|
||||
dismissAfterVisibleMs,
|
||||
exitingKey,
|
||||
startExit,
|
||||
viewKey,
|
||||
});
|
||||
|
||||
if (!displayedView) {
|
||||
return null;
|
||||
@@ -201,7 +130,21 @@ export function SidebarProviderUpdatePill() {
|
||||
? "pointer-events-none translate-y-1.5 opacity-0"
|
||||
: "translate-y-0 opacity-100"
|
||||
}`}
|
||||
onTransitionEnd={onTransitionEnd}
|
||||
onTransitionEnd={(event) => {
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
if (!displayedView || exitingKey !== displayedView.key) {
|
||||
return;
|
||||
}
|
||||
if (dismissAfterExitKey === displayedView.key) {
|
||||
setDismissedKeys((previous) => new Set(previous).add(displayedView.key));
|
||||
}
|
||||
setRenderedView(pendingView);
|
||||
setPendingView(null);
|
||||
setExitingKey(null);
|
||||
setDismissAfterExitKey(null);
|
||||
}}
|
||||
>
|
||||
{showDismissProgress ? (
|
||||
<div
|
||||
|
||||
@@ -21,7 +21,6 @@ import { createModelSelection } from "@t3tools/shared/model";
|
||||
// `stickyModelSelectionByProvider` maps are keyed by `ProviderInstanceId`
|
||||
// in production; these aliases keep the legacy-key migration tests concise.
|
||||
const CODEX_INSTANCE = ProviderInstanceId.make("codex");
|
||||
const CODEX_SECONDARY_INSTANCE = ProviderInstanceId.make("codex_secondary");
|
||||
const CLAUDE_AGENT_INSTANCE = ProviderInstanceId.make("claudeAgent");
|
||||
const CURSOR_INSTANCE = ProviderInstanceId.make("cursor");
|
||||
const CODEX_DRIVER = ProviderDriverKind.make("codex");
|
||||
@@ -1202,43 +1201,6 @@ describe("composerDraftStore modelSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("stores provider option changes on a selected custom instance", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProviderModelOptions(
|
||||
threadRef,
|
||||
CODEX_DRIVER,
|
||||
toSelections({ reasoningEffort: "low" }),
|
||||
{
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
model: "gpt-5-codex",
|
||||
persistSticky: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
expect(draftFor(threadId, TEST_ENVIRONMENT_ID)?.activeProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyActiveProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_INSTANCE]).toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("updates only the draft when sticky persistence is disabled", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
|
||||
@@ -371,7 +371,6 @@ interface ComposerDraftStoreState {
|
||||
provider: ProviderDriverKind,
|
||||
nextProviderOptions: ReadonlyArray<ProviderOptionSelection> | null | undefined,
|
||||
options?: {
|
||||
instanceId?: ProviderInstanceId | null | undefined;
|
||||
model?: string | null | undefined;
|
||||
persistSticky?: boolean;
|
||||
},
|
||||
@@ -2457,7 +2456,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (normalizedProvider === null) {
|
||||
return;
|
||||
}
|
||||
const instanceKey = options?.instanceId ?? defaultInstanceIdForDriver(normalizedProvider);
|
||||
const instanceKey = defaultInstanceIdForDriver(normalizedProvider);
|
||||
const fallbackModel =
|
||||
normalizeModelSlug(options?.model, normalizedProvider) ??
|
||||
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider] ??
|
||||
@@ -2502,9 +2501,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const { options: _, ...rest } = stickyBase;
|
||||
nextStickyMap[instanceKey] = rest as ModelSelection;
|
||||
}
|
||||
nextStickyActiveProvider = options.instanceId
|
||||
? instanceKey
|
||||
: (base.activeProvider ?? instanceKey);
|
||||
nextStickyActiveProvider = base.activeProvider ?? instanceKey;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -2517,7 +2514,6 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
...(options?.instanceId ? { activeProvider: instanceKey } : {}),
|
||||
modelSelectionByProvider: nextMap,
|
||||
};
|
||||
const nextDraftsByThreadKey = { ...state.draftsByThreadKey };
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user