thinking-toggle-wip
Aiden Cline 2025-12-26 22:37:31 -06:00
parent 3127f4f30e
commit f6b24d81d4
5 changed files with 26 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import { Editor } from "@tui/util/editor"
import { useExit } from "../../context/exit"
import { Clipboard } from "../../util/clipboard"
import type { FilePart } from "@opencode-ai/sdk/v2"
import type { MessageV2 } from "@/session/message-v2"
import { TuiEvent } from "../../event"
import { iife } from "@/util/iife"
import { Locale } from "@/util/locale"
@ -171,6 +172,7 @@ export function Prompt(props: PromptProps) {
extmarkToPartIndex: Map<number, number>
interrupt: number
placeholder: number
effort: MessageV2.Thinking["effort"]
}>({
placeholder: Math.floor(Math.random() * PLACEHOLDERS.length),
prompt: {
@ -180,6 +182,7 @@ export function Prompt(props: PromptProps) {
mode: "normal",
extmarkToPartIndex: new Map(),
interrupt: 0,
effort: "default",
})
command.register(() => {
@ -510,6 +513,7 @@ export function Prompt(props: PromptProps) {
parts: [],
})
setStore("extmarkToPartIndex", new Map())
setStore("effort", "default")
},
submit() {
submit()
@ -841,6 +845,14 @@ export function Prompt(props: PromptProps) {
return
}
}
if (keybind.match("effort_cycle", e)) {
e.preventDefault()
const levels: MessageV2.Thinking["effort"][] = ["default", "medium", "high"]
const currentIndex = levels.indexOf(store.effort)
const nextIndex = (currentIndex + 1) % levels.length
setStore("effort", levels[nextIndex])
return
}
if (store.mode === "normal") autocomplete.onKeyDown(e)
if (!autocomplete.visible) {
if (
@ -956,6 +968,12 @@ export function Prompt(props: PromptProps) {
{local.model.parsed().model}
</text>
<text fg={theme.textMuted}>{local.model.parsed().provider}</text>
<Show when={store.effort !== "default"}>
<text fg={theme.textMuted}>·</text>
<text>
<span style={{ fg: theme.warning, bold: true }}>{store.effort}</span>
</text>
</Show>
</box>
</Show>
</box>

View File

@ -478,6 +478,7 @@ export namespace Config {
agent_list: z.string().optional().default("<leader>a").describe("List agents"),
agent_cycle: z.string().optional().default("tab").describe("Next agent"),
agent_cycle_reverse: z.string().optional().default("shift+tab").describe("Previous agent"),
effort_cycle: z.string().optional().default("ctrl+t").describe("Cycle thinking effort level"),
input_clear: z.string().optional().default("ctrl+c").describe("Clear input field"),
input_paste: z.string().optional().default("ctrl+v").describe("Paste from clipboard"),
input_submit: z.string().optional().default("return").describe("Submit input"),

View File

@ -245,7 +245,7 @@ export namespace ProviderTransform {
}
export function thinking(model: Provider.Model, thinking: MessageV2.Thinking) {
if (!model.capabilities.reasoning) return undefined
if (!model.capabilities.reasoning || thinking.effort === "default") return undefined
switch (model.api.npm) {
case "@openrouter/ai-sdk-provider":

View File

@ -289,7 +289,7 @@ export namespace MessageV2 {
sessionID: z.string(),
})
export const Thinking = z.object({ effort: z.enum(["low", "medium", "high"]) })
export const Thinking = z.object({ effort: z.enum(["default", "medium", "high"]) })
export type Thinking = z.infer<typeof Thinking>
export const User = Base.extend({

View File

@ -91,7 +91,7 @@ export type UserMessage = {
[key: string]: boolean
}
thinking?: {
effort: "low" | "medium" | "high"
effort: "default" | "medium" | "high"
}
}
@ -972,6 +972,10 @@ export type KeybindsConfig = {
* Previous agent
*/
agent_cycle_reverse?: string
/**
* Cycle thinking effort level
*/
effort_cycle?: string
/**
* Clear input field
*/