Merge remote-tracking branch 'upstream/main' into josh/desktop-wsl-parallel-backends
This commit is contained in:
commit
0bb1553690
80 files changed
+4666
-189
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
buildExpiredTerminalContextToastCopy,
|
||||
createLocalDispatchSnapshot,
|
||||
deriveComposerSendState,
|
||||
getStartedThreadModelChangeBlockReason,
|
||||
hasServerAcknowledgedLocalDispatch,
|
||||
reconcileMountedTerminalThreadIds,
|
||||
resolveSendEnvMode,
|
||||
@@ -90,6 +91,73 @@ describe("buildExpiredTerminalContextToastCopy", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getStartedThreadModelChangeBlockReason", () => {
|
||||
const providers = [
|
||||
{
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
},
|
||||
{
|
||||
instanceId: ProviderInstanceId.make("grok"),
|
||||
requiresNewThreadForModelChange: true,
|
||||
},
|
||||
];
|
||||
|
||||
it("allows model changes before a provider session has started", () => {
|
||||
expect(
|
||||
getStartedThreadModelChangeBlockReason({
|
||||
providers,
|
||||
hasStartedSession: false,
|
||||
currentModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("grok"),
|
||||
model: "grok-build",
|
||||
},
|
||||
nextModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("grok"),
|
||||
model: "grok-other",
|
||||
},
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("allows unchanged model selections for restricted providers", () => {
|
||||
expect(
|
||||
getStartedThreadModelChangeBlockReason({
|
||||
providers,
|
||||
hasStartedSession: true,
|
||||
currentModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("grok"),
|
||||
model: "grok-build",
|
||||
},
|
||||
nextModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("grok"),
|
||||
model: "grok-build",
|
||||
},
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("blocks started-session model changes when either provider requires a new thread", () => {
|
||||
expect(
|
||||
getStartedThreadModelChangeBlockReason({
|
||||
providers,
|
||||
hasStartedSession: true,
|
||||
currentModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5.4",
|
||||
},
|
||||
nextModelSelection: {
|
||||
instanceId: ProviderInstanceId.make("grok"),
|
||||
model: "grok-build",
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
title: "Start a new chat to change models",
|
||||
description:
|
||||
"This provider does not allow switching models after a conversation has started.",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSendEnvMode", () => {
|
||||
it("keeps worktree mode for git repositories", () => {
|
||||
expect(resolveSendEnvMode({ requestedEnvMode: "worktree", isGitRepo: true })).toBe("worktree");
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
ProjectId,
|
||||
type ModelSelection,
|
||||
type ProviderDriverKind,
|
||||
type ServerProvider,
|
||||
type ScopedThreadRef,
|
||||
type ThreadId,
|
||||
type TurnId,
|
||||
@@ -262,6 +263,44 @@ export function deriveLockedProvider(input: {
|
||||
return narrowedThreadProvider ?? narrowedSelectedProvider ?? null;
|
||||
}
|
||||
|
||||
export function getStartedThreadModelChangeBlockReason(input: {
|
||||
providers: ReadonlyArray<Pick<ServerProvider, "instanceId" | "requiresNewThreadForModelChange">>;
|
||||
hasStartedSession: boolean;
|
||||
currentModelSelection: ModelSelection;
|
||||
currentProviderInstanceId?: ModelSelection["instanceId"] | null | undefined;
|
||||
nextModelSelection: ModelSelection;
|
||||
}): { title: string; description: string } | null {
|
||||
if (!input.hasStartedSession) {
|
||||
return null;
|
||||
}
|
||||
const currentModelSelection = {
|
||||
...input.currentModelSelection,
|
||||
instanceId: input.currentProviderInstanceId ?? input.currentModelSelection.instanceId,
|
||||
};
|
||||
if (
|
||||
currentModelSelection.instanceId === input.nextModelSelection.instanceId &&
|
||||
currentModelSelection.model === input.nextModelSelection.model
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const currentProvider = input.providers.find(
|
||||
(snapshot) => snapshot.instanceId === currentModelSelection.instanceId,
|
||||
);
|
||||
const nextProvider = input.providers.find(
|
||||
(snapshot) => snapshot.instanceId === input.nextModelSelection.instanceId,
|
||||
);
|
||||
if (
|
||||
currentProvider?.requiresNewThreadForModelChange !== true &&
|
||||
nextProvider?.requiresNewThreadForModelChange !== true
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
title: "Start a new chat to change models",
|
||||
description: "This provider does not allow switching models after a conversation has started.",
|
||||
};
|
||||
}
|
||||
|
||||
export async function waitForStartedServerThread(
|
||||
threadRef: ScopedThreadRef,
|
||||
timeoutMs = 1_000,
|
||||
|
||||
@@ -163,6 +163,7 @@ import {
|
||||
createLocalDispatchSnapshot,
|
||||
deriveComposerSendState,
|
||||
hasServerAcknowledgedLocalDispatch,
|
||||
getStartedThreadModelChangeBlockReason,
|
||||
LAST_INVOKED_SCRIPT_BY_PROJECT_KEY,
|
||||
LastInvokedScriptByProjectSchema,
|
||||
type LocalDispatchSnapshot,
|
||||
@@ -1984,15 +1985,18 @@ export default function ChatView(props: ChatViewProps) {
|
||||
|
||||
const focusComposer = useCallback(() => {
|
||||
composerRef.current?.focusAtEnd();
|
||||
}, []);
|
||||
}, [composerRef]);
|
||||
const scheduleComposerFocus = useCallback(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
focusComposer();
|
||||
});
|
||||
}, [focusComposer]);
|
||||
const addTerminalContextToDraft = useCallback((selection: TerminalContextSelection) => {
|
||||
composerRef.current?.addTerminalContext(selection);
|
||||
}, []);
|
||||
const addTerminalContextToDraft = useCallback(
|
||||
(selection: TerminalContextSelection) => {
|
||||
composerRef.current?.addTerminalContext(selection);
|
||||
},
|
||||
[composerRef],
|
||||
);
|
||||
const setTerminalOpen = useCallback(
|
||||
(open: boolean) => {
|
||||
if (!activeThreadRef) return;
|
||||
@@ -2771,6 +2775,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
keybindings,
|
||||
onToggleDiff,
|
||||
toggleTerminalVisibility,
|
||||
composerRef,
|
||||
]);
|
||||
|
||||
const onRevertToTurnCount = useCallback(
|
||||
@@ -3245,7 +3250,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
promptRef.current = "";
|
||||
composerRef.current?.resetCursorState({ cursor: 0 });
|
||||
},
|
||||
[activePendingProgress?.activeQuestion, activePendingUserInput],
|
||||
[activePendingProgress?.activeQuestion, activePendingUserInput, composerRef],
|
||||
);
|
||||
|
||||
const onChangeActivePendingUserInputCustomAnswer = useCallback(
|
||||
@@ -3279,7 +3284,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
composerRef.current?.focusAt(nextCursor);
|
||||
}
|
||||
},
|
||||
[activePendingUserInput],
|
||||
[activePendingUserInput, composerRef],
|
||||
);
|
||||
|
||||
const onAdvanceActivePendingUserInput = useCallback(() => {
|
||||
@@ -3451,6 +3456,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
setThreadError,
|
||||
autoOpenPlanSidebar,
|
||||
environmentId,
|
||||
composerRef,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -3588,6 +3594,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
runtimeMode,
|
||||
autoOpenPlanSidebar,
|
||||
environmentId,
|
||||
composerRef,
|
||||
]);
|
||||
|
||||
const onProviderModelSelect = useCallback(
|
||||
@@ -3633,6 +3640,22 @@ export default function ChatView(props: ChatViewProps) {
|
||||
instanceId,
|
||||
model: resolvedModel,
|
||||
};
|
||||
const modelChangeBlockReason = getStartedThreadModelChangeBlockReason({
|
||||
providers: providerStatuses,
|
||||
hasStartedSession: activeThread.session !== null,
|
||||
currentModelSelection: activeThread.modelSelection,
|
||||
currentProviderInstanceId: activeThread.session?.providerInstanceId ?? null,
|
||||
nextModelSelection,
|
||||
});
|
||||
if (modelChangeBlockReason) {
|
||||
toastManager.add({
|
||||
type: "warning",
|
||||
title: modelChangeBlockReason.title,
|
||||
description: modelChangeBlockReason.description,
|
||||
});
|
||||
scheduleComposerFocus();
|
||||
return;
|
||||
}
|
||||
setComposerDraftModelSelection(
|
||||
scopeThreadRef(activeThread.environmentId, activeThread.id),
|
||||
nextModelSelection,
|
||||
|
||||
@@ -199,6 +199,18 @@ export const CursorIcon: Icon = ({ className, ...props }) => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const GrokIcon: Icon = ({ className, ...props }) => (
|
||||
<svg
|
||||
{...props}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
className={cn("fill-[#0F0F0F] dark:fill-[#F5F5F5]", className)}
|
||||
>
|
||||
<path d="M9.26905 15.284L17.2479 9.36086C17.6391 9.07047 18.1981 9.18374 18.3845 9.63478C19.3655 12.0135 18.9272 14.8721 16.9755 16.8349C15.0238 18.7976 12.3082 19.228 9.8261 18.2477L7.1146 19.5102C11.0037 22.1834 15.7263 21.5223 18.6774 18.5525C21.0182 16.1985 21.7432 12.9897 21.0653 10.0961L21.0714 10.1023C20.0884 5.85143 21.3131 4.15233 23.8218 0.677913C23.8812 0.595532 23.9406 0.513151 24 0.428711L20.6987 3.74866V3.73836L9.267 15.2861" />
|
||||
<path d="M7.62249 16.7237C4.83113 14.0422 5.3124 9.89222 7.69417 7.49905C9.45541 5.72786 12.341 5.00497 14.86 6.06768L17.5653 4.81138C17.0779 4.45714 16.4533 4.07613 15.7365 3.80839C12.4966 2.46764 8.6178 3.13492 5.98413 5.78141C3.45081 8.32904 2.65415 12.2463 4.02219 15.5889C5.04412 18.0871 3.36889 19.8541 1.68137 21.6377C1.08337 22.2699 0.483318 22.9022 0 23.5716L7.62045 16.7257" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const TraeIcon: Icon = (props) => (
|
||||
<svg {...props} viewBox="0 0 24 24" fill="currentColor">
|
||||
{/* Back rectangle: left strip + bottom strip drawn separately — empty bottom-left corner is the gap between them */}
|
||||
|
||||
@@ -158,6 +158,7 @@ function createBaseServerConfig(): ServerConfig {
|
||||
launchArgs: "",
|
||||
},
|
||||
cursor: { enabled: true, binaryPath: "", apiEndpoint: "", customModels: [] },
|
||||
grok: { enabled: true, binaryPath: "", customModels: [] },
|
||||
opencode: {
|
||||
enabled: true,
|
||||
binaryPath: "",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ProviderDriverKind } from "@t3tools/contracts";
|
||||
import { ClaudeAI, CursorIcon, Icon, OpenAI, OpenCodeIcon } from "../Icons";
|
||||
import { ClaudeAI, CursorIcon, GrokIcon, Icon, OpenAI, OpenCodeIcon } from "../Icons";
|
||||
import { PROVIDER_OPTIONS } from "../../session-logic";
|
||||
|
||||
export const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>> = {
|
||||
@@ -7,6 +7,7 @@ export const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>
|
||||
[ProviderDriverKind.make("claudeAgent")]: ClaudeAI,
|
||||
[ProviderDriverKind.make("opencode")]: OpenCodeIcon,
|
||||
[ProviderDriverKind.make("cursor")]: CursorIcon,
|
||||
[ProviderDriverKind.make("grok")]: GrokIcon,
|
||||
};
|
||||
|
||||
function isAvailableProviderOption(option: (typeof PROVIDER_OPTIONS)[number]): option is {
|
||||
|
||||
@@ -2,11 +2,12 @@ import {
|
||||
ClaudeSettings,
|
||||
CodexSettings,
|
||||
CursorSettings,
|
||||
GrokSettings,
|
||||
OpenCodeSettings,
|
||||
ProviderDriverKind,
|
||||
} from "@t3tools/contracts";
|
||||
import type * as Schema from "effect/Schema";
|
||||
import { ClaudeAI, CursorIcon, type Icon, OpenAI, OpenCodeIcon } from "../Icons";
|
||||
import { ClaudeAI, CursorIcon, GrokIcon, type Icon, OpenAI, OpenCodeIcon } from "../Icons";
|
||||
|
||||
type ProviderSettingsSchema = {
|
||||
readonly fields: Readonly<Record<string, Schema.Top>>;
|
||||
@@ -53,6 +54,13 @@ export const PROVIDER_CLIENT_DEFINITIONS: readonly ProviderClientDefinition[] =
|
||||
badgeLabel: "Early Access",
|
||||
settingsSchema: CursorSettings,
|
||||
},
|
||||
{
|
||||
value: ProviderDriverKind.make("grok"),
|
||||
label: "Grok",
|
||||
icon: GrokIcon,
|
||||
badgeLabel: "Early Access",
|
||||
settingsSchema: GrokSettings,
|
||||
},
|
||||
{
|
||||
value: ProviderDriverKind.make("opencode"),
|
||||
label: "OpenCode",
|
||||
|
||||
Reference in new issue
Block a user