From 51da3483a97215b69dcb277df7751cbb49b020fb Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Fri, 22 May 2026 17:28:51 +0530 Subject: [PATCH] feat(tui): copy worktree path from palette (#28823) --- packages/opencode/src/cli/cmd/tui/app.tsx | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index e326a39b59..530ba3ff23 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -25,7 +25,7 @@ import { DialogProvider, useDialog } from "@tui/ui/dialog" import { DialogProvider as DialogProviderList } from "@tui/component/dialog-provider" import { ErrorComponent } from "@tui/component/error-component" import { PluginRouteMissing } from "@tui/component/plugin-route-missing" -import { ProjectProvider } from "@tui/context/project" +import { ProjectProvider, useProject } from "@tui/context/project" import { EditorContextProvider } from "@tui/context/editor" import { useEvent } from "@tui/context/event" import { SDKProvider, useSDK } from "@tui/context/sdk" @@ -279,6 +279,7 @@ function App(props: { onSnapshot?: () => Promise }) { const themeState = useTheme() const { theme, mode, setMode, locked, lock, unlock } = themeState const sync = useSync() + const project = useProject() const exit = useExit() const promptRef = usePromptRef() const routes: RouteMap = new Map() @@ -447,6 +448,13 @@ function App(props: { onSnapshot?: () => Promise }) { ) const connected = useConnected() + const currentWorktreeWorkspace = createMemo(() => { + const workspaceID = project.workspace.current() + if (!workspaceID) return + const workspace = project.workspace.get(workspaceID) + if (workspace?.type !== "worktree" || !workspace.directory) return + return workspace + }) const appCommands = createMemo(() => [ { @@ -483,6 +491,20 @@ function App(props: { onSnapshot?: () => Promise }) { dialog.clear() }, }, + { + name: "workspace.copy_path", + title: "Copy worktree path", + category: "Workspace", + enabled: () => currentWorktreeWorkspace() !== undefined, + run: async () => { + const workspace = currentWorktreeWorkspace() + if (!workspace?.directory) return + await Clipboard.copy(workspace.directory) + .then(() => toast.show({ message: "Copied worktree path", variant: "info" })) + .catch(toast.error) + dialog.clear() + }, + }, ...Array.from({ length: 9 }, (_, i) => ({ name: `session.quick_switch.${i + 1}`, title: `Switch to session in quick slot ${i + 1}`,