Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
"@ai-sdk/groq@3.0.31": "patches/@ai-sdk%2Fgroq@3.0.31.patch",
"@ai-sdk/anthropic@3.0.111": "patches/@ai-sdk%2Fanthropic@3.0.111.patch",
"@ai-sdk/amazon-bedrock@4.0.166": "patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch",
"@ai-sdk/openai@3.0.88": "patches/@ai-sdk%2Fopenai@3.0.88.patch"
"@ai-sdk/openai@3.0.88": "patches/@ai-sdk%2Fopenai@3.0.88.patch",
"@opentui/core@0.4.5": "patches/@opentui%2Fcore@0.4.5.patch"
}
}
22 changes: 16 additions & 6 deletions packages/tui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ClipboardProvider, useClipboard } from "./context/clipboard"
import { ExitProvider, useExit } from "./context/exit"
import { EpilogueProvider } from "./context/epilogue"
import * as Selection from "./util/selection"
import { createCliRenderer, MouseButton } from "@opentui/core"
import { createCliRenderer, MouseButton, type MouseEvent } from "@opentui/core"
import { RouteProvider, useRoute } from "./context/route"
import {
Switch,
Expand Down Expand Up @@ -66,6 +66,8 @@ import { openUrl } from "@opencode-ai/core/open"
import { PromptRefProvider, usePromptRef } from "./context/prompt"
import { TuiConfigProvider, useTuiConfig, type TuiConfig } from "./config"
import { createTuiApiAdapters } from "./plugin/adapters"
import { copyText, onClick } from "./ui/click"
import { idUnder } from "./ui/id-click"
import { createTuiApi } from "./plugin/api"
import { createPluginRuntime, PluginRuntimeProvider, usePluginRuntime, type TuiPluginHost } from "./plugin/runtime"
import { CommandPaletteDialog } from "./component/command-palette"
Expand Down Expand Up @@ -372,6 +374,14 @@ function App(props: { onSnapshot?: () => Promise<string[]>; pluginHost: TuiPlugi
const attention = createTuiAttention({ renderer, config: tuiConfig, kv })
const clipboard = useClipboard()
const update = useUpdateNotification()
// A click on a session or message ID outside a dialog copies it.
const idClick = onClick((evt: MouseEvent) => {
if (dialog.stack.length > 0) return false
const found = idUnder(renderer.currentRenderBuffer, evt)
if (!found) return false
copyText(clipboard, toast.show, found.value)
return true
})

const api = createTuiApi(
createTuiApiAdapters({
Expand Down Expand Up @@ -1042,18 +1052,18 @@ function App(props: { onSnapshot?: () => Promise<string[]>; pluginHost: TuiPlugi
flexDirection="column"
backgroundColor={theme.background}
onMouseDown={(evt) => {
idClick.onMouseDown(evt)
if (!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) return
if (evt.button !== MouseButton.RIGHT) return

if (!Selection.copy(renderer, toast, clipboard)) return
evt.preventDefault()
evt.stopPropagation()
}}
onMouseUp={
!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT
? () => Selection.copy(renderer, toast, clipboard)
: undefined
}
onMouseUp={(evt) => {
if (idClick.onMouseUp(evt)) return
if (!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) Selection.copy(renderer, toast, clipboard)
}}
>
<Show when={Flag.OPENCODE_SHOW_TTFD}>
<TimeToFirstDraw />
Expand Down
26 changes: 2 additions & 24 deletions packages/tui/src/component/dialog-mcp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { map, pipe, entries, sortBy } from "remeda"
import { DialogSelect, type DialogSelectRef, type DialogSelectOption } from "../ui/dialog-select"
import { useTheme } from "../context/theme"
import { TextAttributes } from "@opentui/core"
import { useSDK } from "../context/sdk"

function Status(props: { enabled: boolean; loading: boolean }) {
const { theme } = useTheme()
Expand All @@ -21,14 +20,12 @@ function Status(props: { enabled: boolean; loading: boolean }) {
export function DialogMcp() {
const local = useLocal()
const sync = useSync()
const sdk = useSDK()
const [, setRef] = createSignal<DialogSelectRef<unknown>>()
const [loading, setLoading] = createSignal<string | null>(null)

const options = createMemo(() => {
// Track sync data and loading state to trigger re-render when they change
const mcpData = sync.data.mcp
const loadingMcp = loading()
const loadingMcp = local.mcp.pending()

return pipe(
mcpData ?? {},
Expand All @@ -48,26 +45,7 @@ export function DialogMcp() {
{
command: "dialog.mcp.toggle",
title: "toggle",
onTrigger: async (option: DialogSelectOption<string>) => {
// Prevent toggling while an operation is already in progress
if (loading() !== null) return

setLoading(option.value)
try {
await local.mcp.toggle(option.value)
// Refresh MCP status from server
const status = await sdk.client.mcp.status()
if (status.data) {
sync.set("mcp", status.data)
} else {
console.error("Failed to refresh MCP status: no data returned")
}
} catch (error) {
console.error("Failed to toggle MCP:", error)
} finally {
setLoading(null)
}
},
onTrigger: (option: DialogSelectOption<string>) => local.mcp.toggle(option.value),
},
])

Expand Down
6 changes: 4 additions & 2 deletions packages/tui/src/component/dialog-model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import * as fuzzysort from "fuzzysort"
import { useConnected } from "./use-connected"
import { useSync } from "../context/sync"

export function DialogModel(props: { providerID?: string }) {
// `current` puts the cursor on another model than the selected one, e.g. the
// model a past turn ran on.
export function DialogModel(props: { providerID?: string; current?: { providerID: string; modelID: string } }) {
const local = useLocal()
const sync = useSync()
const dialog = useDialog()
Expand Down Expand Up @@ -178,7 +180,7 @@ export function DialogModel(props: { providerID?: string }) {
flat={true}
skipFilter={true}
title={title()}
current={local.model.current()}
current={props.current ?? local.model.current()}
/>
)
}
Expand Down
Loading
Loading