Add ACP support with Cursor provider (#1355)
Co-authored-by: codex <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
This commit is contained in:
98 files changed
+26746
-862
No files matched your search
@@ -99,6 +99,7 @@ function createBaseServerConfig(): ServerConfig {
|
||||
providers: {
|
||||
codex: { enabled: true, binaryPath: "", homePath: "", customModels: [] },
|
||||
claudeAgent: { enabled: true, binaryPath: "", customModels: [], launchArgs: "" },
|
||||
cursor: { enabled: true, binaryPath: "", apiEndpoint: "", customModels: [] },
|
||||
opencode: {
|
||||
enabled: true,
|
||||
binaryPath: "",
|
||||
|
||||
@@ -612,6 +612,7 @@ export const ChatComposer = memo(
|
||||
providerStatuses.find((provider) => provider.provider === "claudeAgent")?.models ?? [],
|
||||
opencode:
|
||||
providerStatuses.find((provider) => provider.provider === "opencode")?.models ?? [],
|
||||
cursor: providerStatuses.find((provider) => provider.provider === "cursor")?.models ?? [],
|
||||
}),
|
||||
[providerStatuses],
|
||||
);
|
||||
|
||||
@@ -938,7 +938,13 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: {
|
||||
const iconConfig = workToneIcon(workEntry.tone);
|
||||
const EntryIcon = workEntryIcon(workEntry);
|
||||
const heading = toolWorkEntryHeading(workEntry);
|
||||
const preview = workEntryPreview(workEntry, workspaceRoot);
|
||||
const rawPreview = workEntryPreview(workEntry, workspaceRoot);
|
||||
const preview =
|
||||
rawPreview &&
|
||||
normalizeCompactToolLabel(rawPreview).toLowerCase() ===
|
||||
normalizeCompactToolLabel(heading).toLowerCase()
|
||||
? null
|
||||
: rawPreview;
|
||||
const rawCommand = workEntryRawCommand(workEntry);
|
||||
const displayText = preview ? `${heading} - ${preview}` : heading;
|
||||
const hasChangedFiles = (workEntry.changedFiles?.length ?? 0) > 0;
|
||||
@@ -953,20 +959,20 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: {
|
||||
<EntryIcon className="size-3" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1 overflow-hidden">
|
||||
<div className="max-w-full">
|
||||
<p
|
||||
className={cn(
|
||||
"truncate text-xs leading-5",
|
||||
workToneClass(workEntry.tone),
|
||||
preview ? "text-muted-foreground/70" : "",
|
||||
)}
|
||||
title={rawCommand ? undefined : displayText}
|
||||
>
|
||||
<span className={cn("text-foreground/80", workToneClass(workEntry.tone))}>
|
||||
{heading}
|
||||
</span>
|
||||
{preview &&
|
||||
(rawCommand ? (
|
||||
{rawCommand ? (
|
||||
<div className="max-w-full">
|
||||
<p
|
||||
className={cn(
|
||||
"truncate text-xs leading-5",
|
||||
workToneClass(workEntry.tone),
|
||||
preview ? "text-muted-foreground/70" : "",
|
||||
)}
|
||||
title={displayText}
|
||||
>
|
||||
<span className={cn("text-foreground/80", workToneClass(workEntry.tone))}>
|
||||
{heading}
|
||||
</span>
|
||||
{preview && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
closeDelay={0}
|
||||
@@ -988,11 +994,36 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: {
|
||||
</div>
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<span className="text-muted-foreground/55"> - {preview}</span>
|
||||
))}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
className="block min-w-0 w-full text-left"
|
||||
title={displayText}
|
||||
aria-label={displayText}
|
||||
>
|
||||
<p
|
||||
className={cn(
|
||||
"truncate text-[11px] leading-5",
|
||||
workToneClass(workEntry.tone),
|
||||
preview ? "text-muted-foreground/70" : "",
|
||||
)}
|
||||
>
|
||||
<span className={cn("text-foreground/80", workToneClass(workEntry.tone))}>
|
||||
{heading}
|
||||
</span>
|
||||
{preview && <span className="text-muted-foreground/55"> - {preview}</span>}
|
||||
</p>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup className="max-w-[min(720px,calc(100vw-2rem))]">
|
||||
<p className="whitespace-pre-wrap wrap-break-word text-xs leading-5">
|
||||
{displayText}
|
||||
</p>
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{hasChangedFiles && !previewIsChangedFiles && (
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
type ModelSelection,
|
||||
ClaudeModelOptions,
|
||||
CodexModelOptions,
|
||||
CursorModelOptions,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
OpenCodeModelOptions,
|
||||
@@ -475,6 +476,90 @@ async function mountCodexPicker(props: { model?: string; options?: CodexModelOpt
|
||||
};
|
||||
}
|
||||
|
||||
async function mountCursorPicker(props: { model?: string; options?: CursorModelOptions }) {
|
||||
const model = props.model ?? DEFAULT_MODEL_BY_PROVIDER.cursor;
|
||||
const cursorThreadId = ThreadId.make("thread-cursor-traits");
|
||||
const cursorThreadRef = scopeThreadRef(LOCAL_ENVIRONMENT_ID, cursorThreadId);
|
||||
const cursorThreadKey = scopedThreadKey(cursorThreadRef);
|
||||
const host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
|
||||
useComposerDraftStore.setState({
|
||||
draftsByThreadKey: {
|
||||
[cursorThreadKey]: {
|
||||
prompt: "",
|
||||
images: [],
|
||||
nonPersistedImageIds: [],
|
||||
persistedAttachments: [],
|
||||
terminalContexts: [],
|
||||
modelSelectionByProvider: {
|
||||
cursor: {
|
||||
provider: "cursor",
|
||||
model,
|
||||
...(props.options ? { options: props.options } : {}),
|
||||
},
|
||||
},
|
||||
activeProvider: "cursor",
|
||||
runtimeMode: null,
|
||||
interactionMode: null,
|
||||
},
|
||||
},
|
||||
draftThreadsByThreadKey: {},
|
||||
logicalProjectDraftThreadKeyByLogicalProjectKey: {},
|
||||
});
|
||||
|
||||
const screen = await render(
|
||||
<TraitsPicker
|
||||
provider="cursor"
|
||||
models={[
|
||||
{
|
||||
slug: "composer-2",
|
||||
name: "Composer 2",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: true,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: "claude-opus-4-6",
|
||||
name: "Opus 4.6",
|
||||
isCustom: false,
|
||||
capabilities: {
|
||||
reasoningEffortLevels: [],
|
||||
supportsFastMode: true,
|
||||
supportsThinkingToggle: false,
|
||||
contextWindowOptions: [
|
||||
{ value: "200k", label: "200K", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
promptInjectedEffortLevels: [],
|
||||
},
|
||||
},
|
||||
]}
|
||||
threadRef={cursorThreadRef}
|
||||
model={model}
|
||||
prompt=""
|
||||
modelOptions={props.options}
|
||||
onPromptChange={() => {}}
|
||||
/>,
|
||||
{ container: host },
|
||||
);
|
||||
|
||||
const cleanup = async () => {
|
||||
await screen.unmount();
|
||||
host.remove();
|
||||
};
|
||||
|
||||
return {
|
||||
[Symbol.asyncDispose]: cleanup,
|
||||
cleanup,
|
||||
};
|
||||
}
|
||||
|
||||
describe("TraitsPicker (Codex)", () => {
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = "";
|
||||
@@ -628,3 +713,70 @@ describe("TraitsPicker (OpenCode)", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("TraitsPicker (Cursor)", () => {
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = "";
|
||||
localStorage.removeItem(COMPOSER_DRAFT_STORAGE_KEY);
|
||||
useComposerDraftStore.setState({
|
||||
draftsByThreadKey: {},
|
||||
draftThreadsByThreadKey: {},
|
||||
logicalProjectDraftThreadKeyByLogicalProjectKey: {},
|
||||
stickyModelSelectionByProvider: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the selected fast mode menu label for the trigger in fast-only state", async () => {
|
||||
await using _ = await mountCursorPicker({
|
||||
model: "composer-2",
|
||||
options: { fastMode: false },
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
const text = document.body.textContent ?? "";
|
||||
expect(text).toContain("Normal");
|
||||
});
|
||||
|
||||
await page.getByRole("button").click();
|
||||
|
||||
await vi.waitFor(() => {
|
||||
const text = document.body.textContent ?? "";
|
||||
expect(text).toContain("Fast Mode");
|
||||
expect(text).toContain("off");
|
||||
expect(text).toContain("on");
|
||||
});
|
||||
});
|
||||
|
||||
it("shows Normal for Cursor Opus 4.6 when fast mode and context window are both at defaults", async () => {
|
||||
await using _ = await mountCursorPicker({
|
||||
model: "claude-opus-4-6",
|
||||
options: { fastMode: false },
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
const text = document.body.textContent ?? "";
|
||||
expect(text).toContain("Normal");
|
||||
});
|
||||
|
||||
await page.getByRole("button").click();
|
||||
|
||||
await vi.waitFor(() => {
|
||||
const text = document.body.textContent ?? "";
|
||||
expect(text).toContain("Fast Mode");
|
||||
expect(text).toContain("Context Window");
|
||||
expect(text).toContain("200K (default)");
|
||||
expect(text).toContain("1M");
|
||||
});
|
||||
});
|
||||
|
||||
it("shows Normal · 1M for Cursor Opus 4.6 when fast mode is off and context window is overridden", async () => {
|
||||
await using _ = await mountCursorPicker({
|
||||
model: "claude-opus-4-6",
|
||||
options: { fastMode: false, contextWindow: "1m" },
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(document.body.textContent ?? "").toContain("Normal · 1M");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
type ClaudeModelOptions,
|
||||
type CodexModelOptions,
|
||||
type CursorModelOptions,
|
||||
type OpenCodeModelOptions,
|
||||
type ProviderKind,
|
||||
type ProviderModelOptions,
|
||||
@@ -60,12 +61,22 @@ function getRawEffort(
|
||||
if (provider === "codex") {
|
||||
return trimOrNull((modelOptions as CodexModelOptions | undefined)?.reasoningEffort);
|
||||
}
|
||||
if (provider === "cursor") {
|
||||
return trimOrNull((modelOptions as CursorModelOptions | undefined)?.reasoning);
|
||||
}
|
||||
if (provider === "opencode") {
|
||||
return trimOrNull((modelOptions as OpenCodeModelOptions | undefined)?.variant);
|
||||
}
|
||||
return trimOrNull((modelOptions as ClaudeModelOptions | undefined)?.effort);
|
||||
}
|
||||
|
||||
function getEffortKey(provider: ProviderKind): string {
|
||||
if (provider === "codex") return "reasoningEffort";
|
||||
if (provider === "cursor") return "reasoning";
|
||||
if (provider === "opencode") return "variant";
|
||||
return "effort";
|
||||
}
|
||||
|
||||
function getRawAgent(modelOptions: ProviderOptions | null | undefined): string | null {
|
||||
return trimOrNull((modelOptions as OpenCodeModelOptions | undefined)?.agent);
|
||||
}
|
||||
@@ -87,8 +98,8 @@ function getRawContextWindow(
|
||||
provider: ProviderKind,
|
||||
modelOptions: ProviderOptions | null | undefined,
|
||||
): string | null {
|
||||
if (provider === "claudeAgent") {
|
||||
return trimOrNull((modelOptions as ClaudeModelOptions | undefined)?.contextWindow);
|
||||
if (modelOptions && "contextWindow" in modelOptions) {
|
||||
return trimOrNull(modelOptions.contextWindow);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -98,16 +109,7 @@ function buildNextOptions(
|
||||
modelOptions: ProviderOptions | null | undefined,
|
||||
patch: Record<string, unknown>,
|
||||
): ProviderOptions {
|
||||
if (provider === "codex") {
|
||||
return { ...(modelOptions as CodexModelOptions | undefined), ...patch } as CodexModelOptions;
|
||||
}
|
||||
if (provider === "opencode") {
|
||||
return {
|
||||
...(modelOptions as OpenCodeModelOptions | undefined),
|
||||
...patch,
|
||||
} as OpenCodeModelOptions;
|
||||
}
|
||||
return { ...(modelOptions as ClaudeModelOptions | undefined), ...patch } as ClaudeModelOptions;
|
||||
return { ...(modelOptions as Record<string, unknown> | undefined), ...patch } as ProviderOptions;
|
||||
}
|
||||
|
||||
function getSelectedTraits(
|
||||
@@ -137,7 +139,9 @@ function getSelectedTraits(
|
||||
|
||||
// Thinking toggle (only for models that support it)
|
||||
const thinkingEnabled = caps.supportsThinkingToggle
|
||||
? ((modelOptions as ClaudeModelOptions | undefined)?.thinking ?? true)
|
||||
? modelOptions && "thinking" in modelOptions
|
||||
? modelOptions.thinking === true
|
||||
: null
|
||||
: null;
|
||||
|
||||
// Fast mode
|
||||
@@ -185,6 +189,51 @@ function getSelectedTraits(
|
||||
};
|
||||
}
|
||||
|
||||
function getTraitsSectionVisibility(input: {
|
||||
provider: ProviderKind;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
model: string | null | undefined;
|
||||
prompt: string;
|
||||
modelOptions: ProviderOptions | null | undefined;
|
||||
allowPromptInjectedEffort?: boolean;
|
||||
}) {
|
||||
const selected = getSelectedTraits(
|
||||
input.provider,
|
||||
input.models,
|
||||
input.model,
|
||||
input.prompt,
|
||||
input.modelOptions,
|
||||
input.allowPromptInjectedEffort ?? true,
|
||||
);
|
||||
|
||||
const showEffort = selected.effort !== null;
|
||||
const showThinking = selected.thinkingEnabled !== null;
|
||||
const showFastMode = selected.caps.supportsFastMode;
|
||||
const showContextWindow = selected.contextWindowOptions.length > 1;
|
||||
const showAgent = selected.agentOptions.length > 0;
|
||||
|
||||
return {
|
||||
...selected,
|
||||
showEffort,
|
||||
showThinking,
|
||||
showFastMode,
|
||||
showContextWindow,
|
||||
showAgent,
|
||||
hasAnyControls: showEffort || showThinking || showFastMode || showContextWindow || showAgent,
|
||||
};
|
||||
}
|
||||
|
||||
export function shouldRenderTraitsControls(input: {
|
||||
provider: ProviderKind;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
model: string | null | undefined;
|
||||
prompt: string;
|
||||
modelOptions: ProviderOptions | null | undefined;
|
||||
allowPromptInjectedEffort?: boolean;
|
||||
}): boolean {
|
||||
return getTraitsSectionVisibility(input).hasAnyControls;
|
||||
}
|
||||
|
||||
export interface TraitsMenuContentProps {
|
||||
provider: ProviderKind;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
@@ -219,10 +268,11 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
return;
|
||||
}
|
||||
setProviderModelOptions(threadTarget, provider, nextOptions, {
|
||||
model,
|
||||
persistSticky: true,
|
||||
});
|
||||
},
|
||||
[persistence, provider, setProviderModelOptions],
|
||||
[model, persistence, provider, setProviderModelOptions],
|
||||
);
|
||||
const {
|
||||
caps,
|
||||
@@ -234,10 +284,22 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
contextWindow,
|
||||
defaultContextWindow,
|
||||
ultrathinkPromptControlled,
|
||||
showEffort,
|
||||
showThinking,
|
||||
showFastMode,
|
||||
showContextWindow,
|
||||
ultrathinkInBodyText,
|
||||
agentOptions,
|
||||
selectedAgent,
|
||||
} = getSelectedTraits(provider, models, model, prompt, modelOptions, allowPromptInjectedEffort);
|
||||
hasAnyControls,
|
||||
} = getTraitsSectionVisibility({
|
||||
provider,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
modelOptions,
|
||||
allowPromptInjectedEffort,
|
||||
});
|
||||
const defaultEffort = getDefaultEffort(caps);
|
||||
|
||||
const handleEffortChange = useCallback(
|
||||
@@ -262,7 +324,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
const stripped = prompt.replace(/^Ultrathink:\s*/i, "");
|
||||
onPromptChange(stripped);
|
||||
}
|
||||
const effortKey = provider === "codex" ? "reasoningEffort" : "effort";
|
||||
const effortKey = getEffortKey(provider);
|
||||
updateModelOptions(
|
||||
buildNextOptions(provider, modelOptions, { [effortKey]: nextOption.value }),
|
||||
);
|
||||
@@ -280,18 +342,13 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
],
|
||||
);
|
||||
|
||||
if (
|
||||
effort === null &&
|
||||
thinkingEnabled === null &&
|
||||
contextWindowOptions.length <= 1 &&
|
||||
agentOptions.length === 0
|
||||
) {
|
||||
if (!hasAnyControls) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{effort ? (
|
||||
{showEffort ? (
|
||||
<>
|
||||
<MenuGroup>
|
||||
<div className="px-2 pt-1.5 pb-1 font-medium text-muted-foreground text-xs">
|
||||
@@ -321,7 +378,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
</>
|
||||
) : thinkingEnabled !== null ? (
|
||||
) : showThinking ? (
|
||||
<MenuGroup>
|
||||
<div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Thinking</div>
|
||||
<MenuRadioGroup
|
||||
@@ -337,9 +394,9 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
</MenuRadioGroup>
|
||||
</MenuGroup>
|
||||
) : null}
|
||||
{caps.supportsFastMode ? (
|
||||
{showFastMode ? (
|
||||
<>
|
||||
<MenuDivider />
|
||||
{showEffort || showThinking ? <MenuDivider /> : null}
|
||||
<MenuGroup>
|
||||
<div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Fast Mode</div>
|
||||
<MenuRadioGroup
|
||||
@@ -356,9 +413,9 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
</MenuGroup>
|
||||
</>
|
||||
) : null}
|
||||
{contextWindowOptions.length > 1 ? (
|
||||
{showContextWindow ? (
|
||||
<>
|
||||
<MenuDivider />
|
||||
{showEffort || showThinking || showFastMode ? <MenuDivider /> : null}
|
||||
<MenuGroup>
|
||||
<div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">
|
||||
Context Window
|
||||
@@ -431,30 +488,76 @@ export const TraitsPicker = memo(function TraitsPicker({
|
||||
contextWindow,
|
||||
defaultContextWindow,
|
||||
ultrathinkPromptControlled,
|
||||
selectedAgentLabel,
|
||||
} = getSelectedTraits(provider, models, model, prompt, modelOptions, allowPromptInjectedEffort);
|
||||
showEffort,
|
||||
showThinking,
|
||||
showContextWindow,
|
||||
} = getTraitsSectionVisibility({
|
||||
provider,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
modelOptions,
|
||||
allowPromptInjectedEffort,
|
||||
});
|
||||
const { selectedAgentLabel } = getSelectedTraits(
|
||||
provider,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
modelOptions,
|
||||
allowPromptInjectedEffort,
|
||||
);
|
||||
|
||||
const effortLabel = effort
|
||||
? (effortLevels.find((l) => l.value === effort)?.label ?? effort)
|
||||
: null;
|
||||
const primaryTraitLabel = ultrathinkPromptControlled
|
||||
? "Ultrathink"
|
||||
: effortLabel
|
||||
? effortLabel
|
||||
: thinkingEnabled === null
|
||||
? null
|
||||
: `Thinking ${thinkingEnabled ? "On" : "Off"}`;
|
||||
const contextWindowLabel =
|
||||
contextWindowOptions.length > 1 && contextWindow !== defaultContextWindow
|
||||
showContextWindow && contextWindow !== defaultContextWindow
|
||||
? (contextWindowOptions.find((o) => o.value === contextWindow)?.label ?? null)
|
||||
: null;
|
||||
const triggerLabel = [
|
||||
ultrathinkPromptControlled
|
||||
? "Ultrathink"
|
||||
: effortLabel
|
||||
? effortLabel
|
||||
: thinkingEnabled === null
|
||||
? null
|
||||
: `Thinking ${thinkingEnabled ? "On" : "Off"}`,
|
||||
...(caps.supportsFastMode && fastModeEnabled ? ["Fast"] : []),
|
||||
const fastOnlyControl =
|
||||
caps.supportsFastMode && !showEffort && !showThinking && !showContextWindow;
|
||||
if (
|
||||
!shouldRenderTraitsControls({
|
||||
provider,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
modelOptions,
|
||||
allowPromptInjectedEffort,
|
||||
})
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const selectedTriggerTraits = [
|
||||
primaryTraitLabel,
|
||||
...(caps.supportsFastMode &&
|
||||
(fastModeEnabled || (primaryTraitLabel === null && contextWindowLabel !== null))
|
||||
? [fastModeEnabled ? "Fast" : "Normal"]
|
||||
: []),
|
||||
...(contextWindowLabel ? [contextWindowLabel] : []),
|
||||
...(selectedAgentLabel ? [selectedAgentLabel] : []),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
].filter(Boolean);
|
||||
const triggerLabel = fastOnlyControl
|
||||
? fastModeEnabled
|
||||
? "Fast"
|
||||
: "Normal"
|
||||
: selectedTriggerTraits.length > 0
|
||||
? selectedTriggerTraits.join(" · ")
|
||||
: caps.supportsFastMode
|
||||
? "Normal"
|
||||
: defaultContextWindow
|
||||
? (contextWindowOptions.find((option) => option.value === defaultContextWindow)?.label ??
|
||||
defaultContextWindow)
|
||||
: (selectedAgentLabel ?? "");
|
||||
|
||||
const isCodexStyle = provider === "codex";
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { ReactNode } from "react";
|
||||
|
||||
import type { DraftId } from "../../composerDraftStore";
|
||||
import { getProviderModelCapabilities } from "../../providerModels";
|
||||
import { TraitsMenuContent, TraitsPicker } from "./TraitsPicker";
|
||||
import { shouldRenderTraitsControls, TraitsMenuContent, TraitsPicker } from "./TraitsPicker";
|
||||
|
||||
export type ComposerProviderStateInput = {
|
||||
provider: ProviderKind;
|
||||
@@ -33,6 +33,16 @@ export type ComposerProviderState = {
|
||||
modelPickerIconClassName?: string;
|
||||
};
|
||||
|
||||
type TraitsRenderInput = {
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
modelOptions: ProviderModelOptions[ProviderKind] | undefined;
|
||||
prompt: string;
|
||||
onPromptChange: (prompt: string) => void;
|
||||
};
|
||||
|
||||
export type ComposerProviderControls = {
|
||||
showInteractionModeToggle: boolean;
|
||||
};
|
||||
@@ -40,24 +50,8 @@ export type ComposerProviderControls = {
|
||||
type ProviderRegistryEntry = {
|
||||
controls: ComposerProviderControls;
|
||||
getState: (input: ComposerProviderStateInput) => ComposerProviderState;
|
||||
renderTraitsMenuContent: (input: {
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
modelOptions: ProviderModelOptions[ProviderKind] | undefined;
|
||||
prompt: string;
|
||||
onPromptChange: (prompt: string) => void;
|
||||
}) => ReactNode;
|
||||
renderTraitsPicker: (input: {
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
modelOptions: ProviderModelOptions[ProviderKind] | undefined;
|
||||
prompt: string;
|
||||
onPromptChange: (prompt: string) => void;
|
||||
}) => ReactNode;
|
||||
renderTraitsMenuContent: (input: TraitsRenderInput) => ReactNode;
|
||||
renderTraitsPicker: (input: TraitsRenderInput) => ReactNode;
|
||||
};
|
||||
|
||||
function hasComposerTraitsTarget(input: {
|
||||
@@ -67,6 +61,39 @@ function hasComposerTraitsTarget(input: {
|
||||
return input.threadRef !== undefined || input.draftId !== undefined;
|
||||
}
|
||||
|
||||
function renderTraitsControl(
|
||||
Component: typeof TraitsMenuContent | typeof TraitsPicker,
|
||||
provider: ProviderKind,
|
||||
input: TraitsRenderInput,
|
||||
): ReactNode {
|
||||
const { threadRef, draftId, model, models, modelOptions, prompt, onPromptChange } = input;
|
||||
if (
|
||||
!hasComposerTraitsTarget({ threadRef, draftId }) ||
|
||||
!shouldRenderTraitsControls({
|
||||
provider,
|
||||
models,
|
||||
model,
|
||||
modelOptions,
|
||||
prompt,
|
||||
})
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Component
|
||||
provider={provider}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
model={model}
|
||||
modelOptions={modelOptions}
|
||||
prompt={prompt}
|
||||
onPromptChange={onPromptChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function getProviderStateFromCapabilities(
|
||||
input: ComposerProviderStateInput,
|
||||
): ComposerProviderState {
|
||||
@@ -78,9 +105,11 @@ function getProviderStateFromCapabilities(
|
||||
? providerOptions.effort
|
||||
: "reasoningEffort" in providerOptions
|
||||
? providerOptions.reasoningEffort
|
||||
: "variant" in providerOptions
|
||||
? providerOptions.variant
|
||||
: null
|
||||
: "reasoning" in providerOptions
|
||||
? providerOptions.reasoning
|
||||
: "variant" in providerOptions
|
||||
? providerOptions.variant
|
||||
: null
|
||||
: null;
|
||||
const normalizedOptions = normalizeProviderModelOptionsWithCapabilities(
|
||||
provider,
|
||||
@@ -122,54 +151,15 @@ function createProviderRegistryEntry(
|
||||
...controls,
|
||||
},
|
||||
getState: (input) => getProviderStateFromCapabilities(input),
|
||||
renderTraitsMenuContent: ({
|
||||
threadRef,
|
||||
draftId,
|
||||
model,
|
||||
models,
|
||||
modelOptions,
|
||||
prompt,
|
||||
onPromptChange,
|
||||
}) =>
|
||||
!hasComposerTraitsTarget({ threadRef, draftId }) ? null : (
|
||||
<TraitsMenuContent
|
||||
provider={provider}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
model={model}
|
||||
modelOptions={modelOptions}
|
||||
prompt={prompt}
|
||||
onPromptChange={onPromptChange}
|
||||
/>
|
||||
),
|
||||
renderTraitsPicker: ({
|
||||
threadRef,
|
||||
draftId,
|
||||
model,
|
||||
models,
|
||||
modelOptions,
|
||||
prompt,
|
||||
onPromptChange,
|
||||
}) =>
|
||||
!hasComposerTraitsTarget({ threadRef, draftId }) ? null : (
|
||||
<TraitsPicker
|
||||
provider={provider}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
model={model}
|
||||
modelOptions={modelOptions}
|
||||
prompt={prompt}
|
||||
onPromptChange={onPromptChange}
|
||||
/>
|
||||
),
|
||||
renderTraitsMenuContent: (input) => renderTraitsControl(TraitsMenuContent, provider, input),
|
||||
renderTraitsPicker: (input) => renderTraitsControl(TraitsPicker, provider, input),
|
||||
};
|
||||
}
|
||||
|
||||
const composerProviderRegistry: Record<ProviderKind, ProviderRegistryEntry> = {
|
||||
codex: createProviderRegistryEntry("codex"),
|
||||
claudeAgent: createProviderRegistryEntry("claudeAgent"),
|
||||
cursor: createProviderRegistryEntry("cursor"),
|
||||
opencode: createProviderRegistryEntry("opencode", {
|
||||
showInteractionModeToggle: false,
|
||||
}),
|
||||
|
||||
@@ -56,6 +56,7 @@ import {
|
||||
} from "../../store";
|
||||
import { formatRelativeTime, formatRelativeTimeLabel } from "../../timestampFormat";
|
||||
import { cn } from "../../lib/utils";
|
||||
import { Badge } from "../ui/badge";
|
||||
import { Button } from "../ui/button";
|
||||
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty";
|
||||
@@ -103,6 +104,7 @@ const TIMESTAMP_FORMAT_LABELS = {
|
||||
type InstallProviderSettings = {
|
||||
provider: ProviderKind;
|
||||
title: string;
|
||||
badgeLabel?: string;
|
||||
binaryPlaceholder: string;
|
||||
binaryDescription: ReactNode;
|
||||
serverUrlPlaceholder?: string;
|
||||
@@ -130,6 +132,13 @@ const PROVIDER_SETTINGS: readonly InstallProviderSettings[] = [
|
||||
binaryPlaceholder: "Claude binary path",
|
||||
binaryDescription: "Path to the Claude binary",
|
||||
},
|
||||
{
|
||||
provider: "cursor",
|
||||
title: "Cursor",
|
||||
badgeLabel: "Early Access",
|
||||
binaryPlaceholder: "Cursor agent binary path",
|
||||
binaryDescription: "Path to the Cursor agent binary",
|
||||
},
|
||||
{
|
||||
provider: "opencode",
|
||||
title: "OpenCode",
|
||||
@@ -530,6 +539,11 @@ export function GeneralSettingsPanel() {
|
||||
settings.providers.claudeAgent.customModels.length > 0 ||
|
||||
settings.providers.claudeAgent.launchArgs !== "",
|
||||
),
|
||||
cursor: Boolean(
|
||||
settings.providers.cursor.binaryPath !==
|
||||
DEFAULT_UNIFIED_SETTINGS.providers.cursor.binaryPath ||
|
||||
settings.providers.cursor.customModels.length > 0,
|
||||
),
|
||||
opencode: Boolean(
|
||||
settings.providers.opencode.binaryPath !==
|
||||
DEFAULT_UNIFIED_SETTINGS.providers.opencode.binaryPath ||
|
||||
@@ -545,6 +559,7 @@ export function GeneralSettingsPanel() {
|
||||
>({
|
||||
codex: "",
|
||||
claudeAgent: "",
|
||||
cursor: "",
|
||||
opencode: "",
|
||||
});
|
||||
const [customModelErrorByProvider, setCustomModelErrorByProvider] = useState<
|
||||
@@ -572,6 +587,11 @@ export function GeneralSettingsPanel() {
|
||||
const availableEditors = useServerAvailableEditors();
|
||||
const observability = useServerObservability();
|
||||
const serverProviders = useServerProviders();
|
||||
const visibleProviderSettings = PROVIDER_SETTINGS.filter(
|
||||
(providerSettings) =>
|
||||
providerSettings.provider !== "cursor" ||
|
||||
serverProviders.some((provider) => provider.provider === "cursor"),
|
||||
);
|
||||
const codexHomePath = settings.providers.codex.homePath;
|
||||
const logsDirectoryPath = observability?.logsDirectoryPath ?? null;
|
||||
const diagnosticsDescription = (() => {
|
||||
@@ -736,7 +756,7 @@ export function GeneralSettingsPanel() {
|
||||
[settings, updateSettings],
|
||||
);
|
||||
|
||||
const providerCards = PROVIDER_SETTINGS.map((providerSettings) => {
|
||||
const providerCards = visibleProviderSettings.map((providerSettings) => {
|
||||
const liveProvider = serverProviders.find(
|
||||
(candidate) => candidate.provider === providerSettings.provider,
|
||||
);
|
||||
@@ -756,6 +776,7 @@ export function GeneralSettingsPanel() {
|
||||
return {
|
||||
provider: providerSettings.provider,
|
||||
title: providerSettings.title,
|
||||
badgeLabel: providerSettings.badgeLabel,
|
||||
binaryPlaceholder: providerSettings.binaryPlaceholder,
|
||||
binaryDescription: providerSettings.binaryDescription,
|
||||
serverUrlPlaceholder: providerSettings.serverUrlPlaceholder,
|
||||
@@ -1153,6 +1174,11 @@ export function GeneralSettingsPanel() {
|
||||
className={cn("size-2 shrink-0 rounded-full", providerCard.statusStyle.dot)}
|
||||
/>
|
||||
<h3 className="text-sm font-medium text-foreground">{providerDisplayName}</h3>
|
||||
{providerCard.badgeLabel ? (
|
||||
<Badge variant="warning" size="sm" className="shrink-0">
|
||||
{providerCard.badgeLabel}
|
||||
</Badge>
|
||||
) : null}
|
||||
{providerCard.versionLabel ? (
|
||||
<code className="text-xs text-muted-foreground">
|
||||
{providerCard.versionLabel}
|
||||
|
||||
@@ -91,7 +91,7 @@ function resetComposerDraftStore() {
|
||||
}
|
||||
|
||||
function modelSelection(
|
||||
provider: "codex" | "claudeAgent",
|
||||
provider: "codex" | "claudeAgent" | "cursor",
|
||||
model: string,
|
||||
options?: ModelSelection["options"],
|
||||
): ModelSelection {
|
||||
@@ -1002,6 +1002,60 @@ describe("composerDraftStore modelSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps explicit Cursor reset overrides on the selection", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setModelSelection(
|
||||
threadRef,
|
||||
modelSelection("cursor", "claude-opus-4-6", {
|
||||
reasoning: "xhigh",
|
||||
fastMode: true,
|
||||
thinking: false,
|
||||
}),
|
||||
);
|
||||
|
||||
store.setProviderModelOptions(threadRef, "cursor", {
|
||||
reasoning: "medium",
|
||||
fastMode: false,
|
||||
thinking: true,
|
||||
});
|
||||
|
||||
expect(draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider.cursor).toEqual(
|
||||
modelSelection("cursor", "claude-opus-4-6", {
|
||||
reasoning: "medium",
|
||||
fastMode: false,
|
||||
thinking: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves the selected Cursor model when only traits change", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProviderModelOptions(
|
||||
threadRef,
|
||||
"cursor",
|
||||
{
|
||||
reasoning: "high",
|
||||
},
|
||||
{
|
||||
model: "gpt-5.4",
|
||||
persistSticky: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider.cursor).toEqual(
|
||||
modelSelection("cursor", "gpt-5.4", {
|
||||
reasoning: "high",
|
||||
}),
|
||||
);
|
||||
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider.cursor).toEqual(
|
||||
modelSelection("cursor", "gpt-5.4", {
|
||||
reasoning: "high",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("updates only the draft when sticky persistence is omitted", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
@@ -1174,6 +1228,24 @@ describe("composerDraftStore sticky composer settings", () => {
|
||||
expect(useComposerDraftStore.getState().stickyActiveProvider).toBe("codex");
|
||||
});
|
||||
|
||||
it("drops empty cursor model options when normalizing sticky state", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setStickyModelSelection(
|
||||
modelSelection("cursor", "gpt-5.4", {
|
||||
reasoning: undefined,
|
||||
fastMode: undefined,
|
||||
thinking: undefined,
|
||||
contextWindow: undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider.cursor).toEqual(
|
||||
modelSelection("cursor", "gpt-5.4"),
|
||||
);
|
||||
expect(useComposerDraftStore.getState().stickyActiveProvider).toBe("cursor");
|
||||
});
|
||||
|
||||
it("applies sticky activeProvider to new drafts", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
const threadId = ThreadId.make("thread-sticky-active-provider");
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import {
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
type CursorModelOptions,
|
||||
type CursorReasoningOption,
|
||||
ClaudeAgentEffort,
|
||||
CodexReasoningEffort,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
type EnvironmentId,
|
||||
ModelSelection,
|
||||
ProjectId,
|
||||
@@ -341,6 +344,7 @@ interface ComposerDraftStoreState {
|
||||
provider: ProviderKind,
|
||||
nextProviderOptions: ProviderModelOptions[ProviderKind] | null | undefined,
|
||||
options?: {
|
||||
model?: string | null | undefined;
|
||||
persistSticky?: boolean;
|
||||
},
|
||||
) => void;
|
||||
@@ -527,7 +531,9 @@ function shouldRemoveDraft(draft: ComposerThreadDraftState): boolean {
|
||||
}
|
||||
|
||||
function normalizeProviderKind(value: unknown): ProviderKind | null {
|
||||
return value === "codex" || value === "claudeAgent" || value === "opencode" ? value : null;
|
||||
return value === "codex" || value === "claudeAgent" || value === "cursor" || value === "opencode"
|
||||
? value
|
||||
: null;
|
||||
}
|
||||
|
||||
function normalizeProviderModelOptions(
|
||||
@@ -544,15 +550,22 @@ function normalizeProviderModelOptions(
|
||||
candidate?.claudeAgent && typeof candidate.claudeAgent === "object"
|
||||
? (candidate.claudeAgent as Record<string, unknown>)
|
||||
: null;
|
||||
const cursorCandidate =
|
||||
candidate?.cursor && typeof candidate.cursor === "object"
|
||||
? (candidate.cursor as Record<string, unknown>)
|
||||
: null;
|
||||
const openCodeCandidate =
|
||||
candidate?.opencode && typeof candidate.opencode === "object"
|
||||
? (candidate.opencode as Record<string, unknown>)
|
||||
: null;
|
||||
|
||||
const codexReasoningEffort = Schema.is(CodexReasoningEffort)(codexCandidate?.reasoningEffort)
|
||||
const isCodexReasoningEffort = Schema.is(CodexReasoningEffort);
|
||||
const isClaudeAgentEffort = Schema.is(ClaudeAgentEffort);
|
||||
|
||||
const codexReasoningEffort = isCodexReasoningEffort(codexCandidate?.reasoningEffort)
|
||||
? codexCandidate.reasoningEffort
|
||||
: provider === "codex"
|
||||
? Schema.is(CodexReasoningEffort)(legacy?.effort)
|
||||
? isCodexReasoningEffort(legacy?.effort)
|
||||
? legacy.effort
|
||||
: undefined
|
||||
: undefined;
|
||||
@@ -579,7 +592,7 @@ function normalizeProviderModelOptions(
|
||||
: claudeCandidate?.thinking === false
|
||||
? false
|
||||
: undefined;
|
||||
const claudeEffort = Schema.is(ClaudeAgentEffort)(claudeCandidate?.effort)
|
||||
const claudeEffort = isClaudeAgentEffort(claudeCandidate?.effort)
|
||||
? claudeCandidate.effort
|
||||
: undefined;
|
||||
const claudeFastMode =
|
||||
@@ -604,6 +617,43 @@ function normalizeProviderModelOptions(
|
||||
...(claudeContextWindow !== undefined ? { contextWindow: claudeContextWindow } : {}),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const cursorReasoningRaw = cursorCandidate?.reasoning;
|
||||
const cursorReasoning: CursorReasoningOption | undefined =
|
||||
typeof cursorReasoningRaw === "string" &&
|
||||
(CURSOR_REASONING_OPTIONS as readonly string[]).includes(cursorReasoningRaw)
|
||||
? (cursorReasoningRaw as CursorReasoningOption)
|
||||
: undefined;
|
||||
const cursorFastMode =
|
||||
cursorCandidate?.fastMode === true
|
||||
? true
|
||||
: cursorCandidate?.fastMode === false
|
||||
? false
|
||||
: undefined;
|
||||
const cursorThinking =
|
||||
cursorCandidate?.thinking === true
|
||||
? true
|
||||
: cursorCandidate?.thinking === false
|
||||
? false
|
||||
: undefined;
|
||||
const cursorContextWindow =
|
||||
typeof cursorCandidate?.contextWindow === "string" && cursorCandidate.contextWindow.length > 0
|
||||
? cursorCandidate.contextWindow
|
||||
: undefined;
|
||||
|
||||
const cursor: CursorModelOptions | undefined =
|
||||
cursorCandidate !== null
|
||||
? (() => {
|
||||
const nextCursor = {
|
||||
...(cursorReasoning ? { reasoning: cursorReasoning } : {}),
|
||||
...(cursorFastMode !== undefined ? { fastMode: cursorFastMode } : {}),
|
||||
...(cursorThinking !== undefined ? { thinking: cursorThinking } : {}),
|
||||
...(cursorContextWindow !== undefined ? { contextWindow: cursorContextWindow } : {}),
|
||||
} satisfies CursorModelOptions;
|
||||
return Object.keys(nextCursor).length > 0 ? nextCursor : undefined;
|
||||
})()
|
||||
: undefined;
|
||||
|
||||
const openCodeVariant =
|
||||
typeof openCodeCandidate?.variant === "string" && openCodeCandidate.variant.length > 0
|
||||
? openCodeCandidate.variant
|
||||
@@ -620,12 +670,13 @@ function normalizeProviderModelOptions(
|
||||
}
|
||||
: undefined;
|
||||
|
||||
if (!codex && !claude && !opencode) {
|
||||
if (!codex && !claude && cursor === undefined && !opencode) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
...(codex ? { codex } : {}),
|
||||
...(claude ? { claudeAgent: claude } : {}),
|
||||
...(cursor !== undefined ? { cursor } : {}),
|
||||
...(opencode ? { opencode } : {}),
|
||||
};
|
||||
}
|
||||
@@ -715,7 +766,7 @@ function legacyToModelSelectionByProvider(
|
||||
const result: Partial<Record<ProviderKind, ModelSelection>> = {};
|
||||
// Add entries from the options bag (for non-active providers)
|
||||
if (modelOptions) {
|
||||
for (const provider of ["codex", "claudeAgent", "opencode"] as const) {
|
||||
for (const provider of ["codex", "claudeAgent", "cursor", "opencode"] as const) {
|
||||
const options = modelOptions[provider];
|
||||
if (options && Object.keys(options).length > 0) {
|
||||
result[provider] = createModelSelection(
|
||||
@@ -2261,7 +2312,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
}
|
||||
const base = existing ?? createEmptyThreadDraft();
|
||||
const nextMap = { ...base.modelSelectionByProvider };
|
||||
for (const provider of ["codex", "claudeAgent", "opencode"] as const) {
|
||||
for (const provider of ["codex", "claudeAgent", "cursor", "opencode"] as const) {
|
||||
// Only touch providers explicitly present in the input
|
||||
if (!normalizedOpts || !(provider in normalizedOpts)) continue;
|
||||
const opts = normalizedOpts[provider];
|
||||
@@ -2303,6 +2354,9 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (normalizedProvider === null) {
|
||||
return;
|
||||
}
|
||||
const fallbackModel =
|
||||
normalizeModelSlug(options?.model, normalizedProvider) ??
|
||||
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider];
|
||||
// Normalize just this provider's options
|
||||
const normalizedOpts = normalizeProviderModelOptions(
|
||||
{ [normalizedProvider]: nextProviderOptions },
|
||||
@@ -2320,7 +2374,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (providerOpts) {
|
||||
nextMap[normalizedProvider] = createModelSelection(
|
||||
normalizedProvider,
|
||||
currentForProvider?.model ?? DEFAULT_MODEL_BY_PROVIDER[normalizedProvider],
|
||||
currentForProvider?.model ?? fallbackModel,
|
||||
providerOpts,
|
||||
);
|
||||
} else if (currentForProvider?.options) {
|
||||
@@ -2336,10 +2390,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const stickyBase =
|
||||
nextStickyMap[normalizedProvider] ??
|
||||
base.modelSelectionByProvider[normalizedProvider] ??
|
||||
createModelSelection(
|
||||
normalizedProvider,
|
||||
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider],
|
||||
);
|
||||
createModelSelection(normalizedProvider, fallbackModel);
|
||||
if (providerOpts) {
|
||||
nextStickyMap[normalizedProvider] = createModelSelection(
|
||||
normalizedProvider,
|
||||
|
||||
@@ -49,6 +49,13 @@ const PROVIDER_CUSTOM_MODEL_CONFIG: Record<ProviderKind, ProviderCustomModelConf
|
||||
placeholder: "your-claude-model-slug",
|
||||
example: "claude-sonnet-5-0",
|
||||
},
|
||||
cursor: {
|
||||
provider: "cursor",
|
||||
title: "Cursor",
|
||||
description: "Save additional Cursor model slugs for the picker and `/model` command.",
|
||||
placeholder: "your-cursor-model-slug",
|
||||
example: "claude-sonnet-4-6",
|
||||
},
|
||||
opencode: {
|
||||
provider: "opencode",
|
||||
title: "OpenCode",
|
||||
@@ -176,6 +183,12 @@ export function getCustomModelOptionsByProvider(
|
||||
"claudeAgent",
|
||||
selectedProvider === "claudeAgent" ? selectedModel : undefined,
|
||||
),
|
||||
cursor: getAppModelOptions(
|
||||
settings,
|
||||
providers,
|
||||
"cursor",
|
||||
selectedProvider === "cursor" ? selectedModel : undefined,
|
||||
),
|
||||
opencode: getAppModelOptions(
|
||||
settings,
|
||||
providers,
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import {
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
type CursorModelOptions,
|
||||
type ModelCapabilities,
|
||||
type ProviderKind,
|
||||
type ServerProvider,
|
||||
type ServerProviderModel,
|
||||
} from "@t3tools/contracts";
|
||||
import { normalizeModelSlug } from "@t3tools/shared/model";
|
||||
import {
|
||||
hasEffortLevel,
|
||||
normalizeModelSlug,
|
||||
resolveContextWindow,
|
||||
trimOrNull,
|
||||
} from "@t3tools/shared/model";
|
||||
|
||||
const EMPTY_CAPABILITIES: ModelCapabilities = {
|
||||
reasoningEffortLevels: [],
|
||||
@@ -33,7 +39,10 @@ export function isProviderEnabled(
|
||||
providers: ReadonlyArray<ServerProvider>,
|
||||
provider: ProviderKind,
|
||||
): boolean {
|
||||
return getProviderSnapshot(providers, provider)?.enabled ?? true;
|
||||
if (providers.length === 0) {
|
||||
return true;
|
||||
}
|
||||
return getProviderSnapshot(providers, provider)?.enabled ?? false;
|
||||
}
|
||||
|
||||
export function resolveSelectableProvider(
|
||||
@@ -67,3 +76,30 @@ export function getDefaultServerModel(
|
||||
DEFAULT_MODEL_BY_PROVIDER[provider]
|
||||
);
|
||||
}
|
||||
|
||||
export function normalizeCursorModelOptionsWithCapabilities(
|
||||
caps: ModelCapabilities,
|
||||
modelOptions: CursorModelOptions | null | undefined,
|
||||
): CursorModelOptions | undefined {
|
||||
const reasoning = trimOrNull(modelOptions?.reasoning);
|
||||
const reasoningValue =
|
||||
reasoning && hasEffortLevel(caps, reasoning)
|
||||
? (reasoning as CursorModelOptions["reasoning"])
|
||||
: undefined;
|
||||
const fastMode =
|
||||
caps.supportsFastMode && typeof modelOptions?.fastMode === "boolean"
|
||||
? modelOptions.fastMode
|
||||
: undefined;
|
||||
const thinking =
|
||||
caps.supportsThinkingToggle && typeof modelOptions?.thinking === "boolean"
|
||||
? modelOptions.thinking
|
||||
: undefined;
|
||||
const contextWindow = resolveContextWindow(caps, modelOptions?.contextWindow);
|
||||
const nextOptions: CursorModelOptions = {
|
||||
...(reasoningValue ? { reasoning: reasoningValue } : {}),
|
||||
...(fastMode !== undefined ? { fastMode } : {}),
|
||||
...(thinking !== undefined ? { thinking } : {}),
|
||||
...(contextWindow ? { contextWindow } : {}),
|
||||
};
|
||||
return Object.keys(nextOptions).length > 0 ? nextOptions : undefined;
|
||||
}
|
||||
@@ -921,6 +921,199 @@ describe("deriveWorkLogEntries", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("drops duplicated tool detail when it only repeats the title", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "read-file-generic",
|
||||
kind: "tool.completed",
|
||||
summary: "Read File",
|
||||
payload: {
|
||||
itemType: "dynamic_tool_call",
|
||||
title: "Read File",
|
||||
detail: "Read File",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const [entry] = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entry?.toolTitle).toBe("Read File");
|
||||
expect(entry?.detail).toBeUndefined();
|
||||
});
|
||||
|
||||
it("uses grep raw output summaries instead of repeating the generic tool label", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "grep-update",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "tool.updated",
|
||||
summary: "grep",
|
||||
payload: {
|
||||
itemType: "web_search",
|
||||
title: "grep",
|
||||
detail: "grep",
|
||||
data: {
|
||||
toolCallId: "tool-grep-1",
|
||||
kind: "search",
|
||||
rawInput: {},
|
||||
},
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "grep-complete",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "tool.completed",
|
||||
summary: "grep",
|
||||
payload: {
|
||||
itemType: "web_search",
|
||||
title: "grep",
|
||||
detail: "grep",
|
||||
data: {
|
||||
toolCallId: "tool-grep-1",
|
||||
kind: "search",
|
||||
rawOutput: {
|
||||
totalFiles: 19,
|
||||
truncated: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries).toHaveLength(1);
|
||||
expect(entries[0]).toMatchObject({
|
||||
id: "grep-complete",
|
||||
toolTitle: "grep",
|
||||
detail: "19 files",
|
||||
itemType: "web_search",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses completed read-file output previews and still collapses the same tool call", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "read-update",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "tool.updated",
|
||||
summary: "Read File",
|
||||
payload: {
|
||||
itemType: "dynamic_tool_call",
|
||||
title: "Read File",
|
||||
detail: "Read File",
|
||||
data: {
|
||||
toolCallId: "tool-read-1",
|
||||
kind: "read",
|
||||
rawInput: {},
|
||||
},
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "read-complete",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "tool.completed",
|
||||
summary: "Read File",
|
||||
payload: {
|
||||
itemType: "dynamic_tool_call",
|
||||
title: "Read File",
|
||||
detail: "Read File",
|
||||
data: {
|
||||
toolCallId: "tool-read-1",
|
||||
kind: "read",
|
||||
rawOutput: {
|
||||
content:
|
||||
'import * as Effect from "effect/Effect"\nimport * as Layer from "effect/Layer"\n',
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries).toHaveLength(1);
|
||||
expect(entries[0]).toMatchObject({
|
||||
id: "read-complete",
|
||||
toolTitle: "Read File",
|
||||
detail: 'import * as Effect from "effect/Effect"',
|
||||
itemType: "dynamic_tool_call",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not use command stdout as the detail when Cursor omits the command input", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "cursor-command-complete",
|
||||
createdAt: "2026-04-16T22:40:42.221Z",
|
||||
kind: "tool.completed",
|
||||
summary: "Ran command",
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
title: "Ran command",
|
||||
data: {
|
||||
toolCallId: "toolu_vrtx_01WypXgRM8PPygBtrVAZwzy5",
|
||||
kind: "execute",
|
||||
rawInput: {},
|
||||
rawOutput: {
|
||||
exitCode: 0,
|
||||
stdout: "total 960\napps\npackages\n",
|
||||
stderr: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const [entry] = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entry).toMatchObject({
|
||||
id: "cursor-command-complete",
|
||||
label: "Ran command",
|
||||
itemType: "command_execution",
|
||||
toolTitle: "Ran command",
|
||||
});
|
||||
expect(entry?.detail).toBeUndefined();
|
||||
expect(entry?.command).toBeUndefined();
|
||||
});
|
||||
|
||||
it("collapses legacy completed tool rows that are missing tool metadata", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "legacy-read-update",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "tool.updated",
|
||||
summary: "Read File",
|
||||
payload: {
|
||||
itemType: "dynamic_tool_call",
|
||||
title: "Read File",
|
||||
detail: "Read File",
|
||||
data: {
|
||||
toolCallId: "tool-read-legacy",
|
||||
kind: "read",
|
||||
rawInput: {},
|
||||
},
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "legacy-read-complete",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "tool.completed",
|
||||
summary: "Read File",
|
||||
payload: {
|
||||
itemType: "dynamic_tool_call",
|
||||
title: "Read File",
|
||||
detail: "Read File",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries).toHaveLength(1);
|
||||
expect(entries[0]).toMatchObject({
|
||||
id: "legacy-read-complete",
|
||||
toolTitle: "Read File",
|
||||
itemType: "dynamic_tool_call",
|
||||
});
|
||||
expect(entries[0]?.detail).toBeUndefined();
|
||||
});
|
||||
|
||||
it("collapses repeated lifecycle updates for the same tool call into one entry", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
@@ -1324,32 +1517,3 @@ describe("deriveActiveWorkStartedAt", () => {
|
||||
).toBe("2026-02-27T21:11:00.000Z");
|
||||
});
|
||||
});
|
||||
|
||||
describe("PROVIDER_OPTIONS", () => {
|
||||
it("advertises available providers while keeping Cursor as a placeholder", () => {
|
||||
const claude = PROVIDER_OPTIONS.find((option) => option.value === "claudeAgent");
|
||||
const opencode = PROVIDER_OPTIONS.find((option) => option.value === "opencode");
|
||||
const cursor = PROVIDER_OPTIONS.find((option) => option.value === "cursor");
|
||||
expect(PROVIDER_OPTIONS).toEqual([
|
||||
{ value: "codex", label: "Codex", available: true },
|
||||
{ value: "claudeAgent", label: "Claude", available: true },
|
||||
{ value: "opencode", label: "OpenCode", available: true },
|
||||
{ value: "cursor", label: "Cursor", available: false },
|
||||
]);
|
||||
expect(claude).toEqual({
|
||||
value: "claudeAgent",
|
||||
label: "Claude",
|
||||
available: true,
|
||||
});
|
||||
expect(opencode).toEqual({
|
||||
value: "opencode",
|
||||
label: "OpenCode",
|
||||
available: true,
|
||||
});
|
||||
expect(cursor).toEqual({
|
||||
value: "cursor",
|
||||
label: "Cursor",
|
||||
available: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
+149
-19
@@ -1,3 +1,5 @@
|
||||
import * as Option from "effect/Option";
|
||||
import * as Arr from "effect/Array";
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
isToolLifecycleItemType,
|
||||
@@ -20,7 +22,7 @@ import type {
|
||||
TurnDiffSummary,
|
||||
} from "./types";
|
||||
|
||||
export type ProviderPickerKind = ProviderKind | "cursor";
|
||||
export type ProviderPickerKind = ProviderKind;
|
||||
|
||||
export const PROVIDER_OPTIONS: Array<{
|
||||
value: ProviderPickerKind;
|
||||
@@ -30,7 +32,7 @@ export const PROVIDER_OPTIONS: Array<{
|
||||
{ value: "codex", label: "Codex", available: true },
|
||||
{ value: "claudeAgent", label: "Claude", available: true },
|
||||
{ value: "opencode", label: "OpenCode", available: true },
|
||||
{ value: "cursor", label: "Cursor", available: false },
|
||||
{ value: "cursor", label: "Cursor", available: true },
|
||||
];
|
||||
|
||||
export interface WorkLogEntry {
|
||||
@@ -50,6 +52,7 @@ export interface WorkLogEntry {
|
||||
interface DerivedWorkLogEntry extends WorkLogEntry {
|
||||
activityKind: OrchestrationThreadActivity["kind"];
|
||||
collapseKey?: string;
|
||||
toolCallId?: string;
|
||||
}
|
||||
|
||||
export interface PendingApproval {
|
||||
@@ -352,12 +355,12 @@ export function deriveActivePlanState(
|
||||
const allPlanActivities = ordered.filter((activity) => activity.kind === "turn.plan.updated");
|
||||
// Prefer plan from the current turn; fall back to the most recent plan from any turn
|
||||
// so that TodoWrite tasks persist across follow-up messages.
|
||||
const latest =
|
||||
(latestTurnId
|
||||
? allPlanActivities.filter((activity) => activity.turnId === latestTurnId).at(-1)
|
||||
: undefined) ??
|
||||
allPlanActivities.at(-1) ??
|
||||
null;
|
||||
const latest = Option.firstSomeOf([
|
||||
...(latestTurnId
|
||||
? Arr.findLast(allPlanActivities, (activity) => activity.turnId === latestTurnId)
|
||||
: Option.none()),
|
||||
Arr.last(allPlanActivities),
|
||||
]).pipe(Option.getOrNull);
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
@@ -515,6 +518,15 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
|
||||
? payload.detail
|
||||
: null;
|
||||
const taskLabel = taskSummary || taskDetailAsLabel;
|
||||
const detail = isTaskActivity
|
||||
? !taskDetailAsLabel &&
|
||||
payload &&
|
||||
typeof payload.detail === "string" &&
|
||||
payload.detail.length > 0
|
||||
? stripTrailingExitCode(payload.detail).output
|
||||
: null
|
||||
: extractToolDetail(payload, title ?? activity.summary);
|
||||
const toolCallId = isTaskActivity ? null : extractToolCallId(payload);
|
||||
const entry: DerivedWorkLogEntry = {
|
||||
id: activity.id,
|
||||
createdAt: activity.createdAt,
|
||||
@@ -529,16 +541,8 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
|
||||
};
|
||||
const itemType = extractWorkLogItemType(payload);
|
||||
const requestKind = extractWorkLogRequestKind(payload);
|
||||
if (
|
||||
!taskDetailAsLabel &&
|
||||
payload &&
|
||||
typeof payload.detail === "string" &&
|
||||
payload.detail.length > 0
|
||||
) {
|
||||
const detail = stripTrailingExitCode(payload.detail).output;
|
||||
if (detail) {
|
||||
entry.detail = detail;
|
||||
}
|
||||
if (detail) {
|
||||
entry.detail = detail;
|
||||
}
|
||||
if (commandPreview.command) {
|
||||
entry.command = commandPreview.command;
|
||||
@@ -558,6 +562,9 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
|
||||
if (requestKind) {
|
||||
entry.requestKind = requestKind;
|
||||
}
|
||||
if (toolCallId) {
|
||||
entry.toolCallId = toolCallId;
|
||||
}
|
||||
const collapseKey = deriveToolLifecycleCollapseKey(entry);
|
||||
if (collapseKey) {
|
||||
entry.collapseKey = collapseKey;
|
||||
@@ -593,7 +600,16 @@ function shouldCollapseToolLifecycleEntries(
|
||||
if (previous.activityKind === "tool.completed") {
|
||||
return false;
|
||||
}
|
||||
return previous.collapseKey !== undefined && previous.collapseKey === next.collapseKey;
|
||||
if (previous.collapseKey !== undefined && previous.collapseKey === next.collapseKey) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
previous.toolCallId !== undefined &&
|
||||
next.toolCallId === undefined &&
|
||||
previous.itemType === next.itemType &&
|
||||
normalizeCompactToolLabel(previous.toolTitle ?? previous.label) ===
|
||||
normalizeCompactToolLabel(next.toolTitle ?? next.label)
|
||||
);
|
||||
}
|
||||
|
||||
function mergeDerivedWorkLogEntries(
|
||||
@@ -608,6 +624,7 @@ function mergeDerivedWorkLogEntries(
|
||||
const itemType = next.itemType ?? previous.itemType;
|
||||
const requestKind = next.requestKind ?? previous.requestKind;
|
||||
const collapseKey = next.collapseKey ?? previous.collapseKey;
|
||||
const toolCallId = next.toolCallId ?? previous.toolCallId;
|
||||
return {
|
||||
...previous,
|
||||
...next,
|
||||
@@ -619,6 +636,7 @@ function mergeDerivedWorkLogEntries(
|
||||
...(itemType ? { itemType } : {}),
|
||||
...(requestKind ? { requestKind } : {}),
|
||||
...(collapseKey ? { collapseKey } : {}),
|
||||
...(toolCallId ? { toolCallId } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -637,6 +655,9 @@ function deriveToolLifecycleCollapseKey(entry: DerivedWorkLogEntry): string | un
|
||||
if (entry.activityKind !== "tool.updated" && entry.activityKind !== "tool.completed") {
|
||||
return undefined;
|
||||
}
|
||||
if (entry.toolCallId) {
|
||||
return `tool:${entry.toolCallId}`;
|
||||
}
|
||||
const normalizedLabel = normalizeCompactToolLabel(entry.toolTitle ?? entry.label);
|
||||
const detail = entry.detail?.trim() ?? "";
|
||||
const itemType = entry.itemType ?? "";
|
||||
@@ -674,6 +695,10 @@ function asTrimmedString(value: unknown): string | null {
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
function asNumber(value: unknown): number | null {
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
||||
function trimMatchingOuterQuotes(value: string): string {
|
||||
const trimmed = value.trim();
|
||||
if (
|
||||
@@ -857,6 +882,111 @@ function extractToolTitle(payload: Record<string, unknown> | null): string | nul
|
||||
return asTrimmedString(payload?.title);
|
||||
}
|
||||
|
||||
function extractToolCallId(payload: Record<string, unknown> | null): string | null {
|
||||
const data = asRecord(payload?.data);
|
||||
return asTrimmedString(data?.toolCallId);
|
||||
}
|
||||
|
||||
function normalizeInlinePreview(value: string): string {
|
||||
return value.replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
function truncateInlinePreview(value: string, maxLength = 84): string {
|
||||
if (value.length <= maxLength) {
|
||||
return value;
|
||||
}
|
||||
return `${value.slice(0, maxLength - 1).trimEnd()}…`;
|
||||
}
|
||||
|
||||
function normalizePreviewForComparison(value: string | null | undefined): string | null {
|
||||
const normalized = asTrimmedString(value);
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
return normalizeCompactToolLabel(normalizeInlinePreview(normalized)).toLowerCase();
|
||||
}
|
||||
|
||||
function summarizeToolTextOutput(value: string): string | null {
|
||||
const lines = value
|
||||
.split(/\r?\n/u)
|
||||
.map((line) => normalizeInlinePreview(line))
|
||||
.filter((line) => line.length > 0);
|
||||
const firstLine = lines.find((line) => line !== "```");
|
||||
if (firstLine) {
|
||||
return truncateInlinePreview(firstLine);
|
||||
}
|
||||
if (lines.length > 1) {
|
||||
return `${lines.length.toLocaleString()} lines`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function summarizeToolRawOutput(payload: Record<string, unknown> | null): string | null {
|
||||
const data = asRecord(payload?.data);
|
||||
const rawOutput = asRecord(data?.rawOutput);
|
||||
if (!rawOutput) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const totalFiles = asNumber(rawOutput.totalFiles);
|
||||
if (totalFiles !== null) {
|
||||
const suffix = rawOutput.truncated === true ? "+" : "";
|
||||
return `${totalFiles.toLocaleString()} file${totalFiles === 1 ? "" : "s"}${suffix}`;
|
||||
}
|
||||
|
||||
const content = asTrimmedString(rawOutput.content);
|
||||
if (content) {
|
||||
return summarizeToolTextOutput(content);
|
||||
}
|
||||
|
||||
const stdout = asTrimmedString(rawOutput.stdout);
|
||||
if (stdout) {
|
||||
return summarizeToolTextOutput(stdout);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function isCommandToolDetail(payload: Record<string, unknown> | null, heading: string): boolean {
|
||||
const data = asRecord(payload?.data);
|
||||
const kind = asTrimmedString(data?.kind)?.toLowerCase();
|
||||
const title = asTrimmedString(payload?.title ?? heading)?.toLowerCase();
|
||||
return (
|
||||
extractWorkLogItemType(payload) === "command_execution" ||
|
||||
kind === "execute" ||
|
||||
title === "terminal" ||
|
||||
title === "ran command"
|
||||
);
|
||||
}
|
||||
|
||||
function extractToolDetail(
|
||||
payload: Record<string, unknown> | null,
|
||||
heading: string,
|
||||
): string | null {
|
||||
const rawDetail = asTrimmedString(payload?.detail);
|
||||
const detail = rawDetail ? stripTrailingExitCode(rawDetail).output : null;
|
||||
const normalizedHeading = normalizePreviewForComparison(heading);
|
||||
const normalizedDetail = normalizePreviewForComparison(detail);
|
||||
|
||||
if (detail && normalizedHeading !== normalizedDetail) {
|
||||
return detail;
|
||||
}
|
||||
|
||||
if (isCommandToolDetail(payload, heading)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const rawOutputSummary = summarizeToolRawOutput(payload);
|
||||
if (rawOutputSummary) {
|
||||
const normalizedRawOutputSummary = normalizePreviewForComparison(rawOutputSummary);
|
||||
if (normalizedRawOutputSummary !== normalizedHeading) {
|
||||
return rawOutputSummary;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function stripTrailingExitCode(value: string): {
|
||||
output: string | null;
|
||||
exitCode?: number | undefined;
|
||||
|
||||
@@ -15,12 +15,12 @@ import type {
|
||||
OrchestrationThreadShell,
|
||||
OrchestrationThreadActivity,
|
||||
ProjectId,
|
||||
ProviderKind,
|
||||
ScopedProjectRef,
|
||||
ScopedThreadRef,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { ProviderKind } from "@t3tools/contracts";
|
||||
import type { ThreadId, TurnId } from "@t3tools/contracts";
|
||||
import { Schema } from "effect";
|
||||
import { resolveModelSlugForProvider } from "@t3tools/shared/model";
|
||||
import { create } from "zustand";
|
||||
import {
|
||||
@@ -1001,7 +1001,7 @@ function toLegacySessionStatus(
|
||||
}
|
||||
|
||||
function toLegacyProvider(providerName: string | null): ProviderKind {
|
||||
if (providerName === "codex" || providerName === "claudeAgent" || providerName === "opencode") {
|
||||
if (Schema.is(ProviderKind)(providerName)) {
|
||||
return providerName;
|
||||
}
|
||||
return "codex";
|
||||
|
||||
Reference in new issue
Block a user