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
32 changes: 2 additions & 30 deletions packages/opencode/src/cli/cmd/tui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ExitProvider, useExit } from "./context/exit"
import { Session as SessionApi } from "@/session"
import { TuiEvent } from "./event"
import { KVProvider, useKV } from "./context/kv"
import { StatusBar } from "./component/status-bar"
import { Provider } from "@/provider/provider"
import { ArgsProvider, useArgs, type Args } from "./context/args"

Expand Down Expand Up @@ -423,36 +424,7 @@ function App() {
</Match>
</Switch>
</box>
<box
height={1}
backgroundColor={theme.backgroundPanel}
flexDirection="row"
justifyContent="space-between"
flexShrink={0}
>
<box flexDirection="row">
<box flexDirection="row" backgroundColor={theme.backgroundElement} paddingLeft={1} paddingRight={1}>
<text fg={theme.textMuted}>open</text>
<text fg={theme.text} attributes={TextAttributes.BOLD}>
code{" "}
</text>
<text fg={theme.textMuted}>v{Installation.VERSION}</text>
</box>
<box paddingLeft={1} paddingRight={1}>
<text fg={theme.textMuted}>{process.cwd().replace(Global.Path.home, "~")}</text>
</box>
</box>
<box flexDirection="row" flexShrink={0}>
<text fg={theme.textMuted} paddingRight={1}>
tab
</text>
<text fg={local.agent.color(local.agent.current().name)}>{""}</text>
<text bg={local.agent.color(local.agent.current().name)} fg={theme.background} wrapMode={undefined}>
<span style={{ bold: true }}> {local.agent.current().name.toUpperCase()}</span>
<span> AGENT </span>
</text>
</box>
</box>
<StatusBar />
</box>
)
}
Expand Down
48 changes: 48 additions & 0 deletions packages/opencode/src/cli/cmd/tui/component/status-bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { useTheme } from "@tui/context/theme"
import { useLocal } from "@tui/context/local"
import { Installation } from "@/installation"
import { Global } from "@/global"
import { TextAttributes } from "@opentui/core"
import { useGitBranch } from "./status-bar/git"

export function StatusBar() {
const { theme } = useTheme()
const local = useLocal()
const { branch } = useGitBranch()

return (
<box
height={1}
backgroundColor={theme.backgroundPanel}
flexDirection="row"
justifyContent="space-between"
flexShrink={0}
>
<box flexDirection="row">
<box flexDirection="row" backgroundColor={theme.backgroundElement} paddingLeft={1} paddingRight={1}>
<text fg={theme.textMuted}>open</text>
<text fg={theme.text} attributes={TextAttributes.BOLD}>
code{" "}
</text>
<text fg={theme.textMuted}>v{Installation.VERSION}</text>
</box>
<box paddingLeft={1} paddingRight={1}>
<text fg={theme.textMuted}>
{process.cwd().replace(Global.Path.home, "~")}
{branch() ? `:${branch()}` : ""}
</text>
</box>
</box>
<box flexDirection="row" flexShrink={0}>
<text fg={theme.textMuted} paddingRight={1}>
tab
</text>
<text fg={local.agent.color(local.agent.current().name)}>{""}</text>
<text bg={local.agent.color(local.agent.current().name)} fg={theme.background} wrapMode={undefined}>
<span style={{ bold: true }}> {local.agent.current().name.toUpperCase()}</span>
<span> AGENT </span>
</text>
</box>
</box>
)
}
25 changes: 25 additions & 0 deletions packages/opencode/src/cli/cmd/tui/component/status-bar/git.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createSignal, createEffect, onCleanup } from "solid-js"
import { $ } from "bun"
import { watch } from "fs"

export function useGitBranch() {
const [branch, setBranch] = createSignal<string>("")

createEffect(async () => {
const gitCheck = await $`git rev-parse --is-inside-work-tree`.cwd(process.cwd()).quiet().nothrow()
if (gitCheck.exitCode === 0) {
const b = await $`git branch --show-current`.cwd(process.cwd()).quiet().nothrow().text()
setBranch(b.trim())

// Set up watcher for .git/HEAD
const gitHeadPath = `${process.cwd()}/.git/HEAD`
const watcher = watch(gitHeadPath, { persistent: false }, async () => {
const newBranch = await $`git branch --show-current`.cwd(process.cwd()).quiet().nothrow().text()
setBranch(newBranch.trim())
})
onCleanup(() => watcher.close())
}
})

return { branch }
}