feat(tui): add dynamic terminal window title (#5112)

This commit is contained in:
Saatvik Arya 2025-12-07 02:19:11 +05:30 committed by GitHub
parent 2e5c2d5e98
commit 3ec34ee3dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View file

@ -169,6 +169,26 @@ function App() {
console.log(JSON.stringify(route.data))
})
// Update terminal window title based on current route and session
createEffect(() => {
if (route.data.type === "home") {
renderer.setTerminalTitle("opencode")
return
}
if (route.data.type === "session") {
const session = sync.session.get(route.data.sessionID)
if (!session || SessionApi.isDefaultTitle(session.title)) {
renderer.setTerminalTitle("opencode")
return
}
// Truncate title to 40 chars max
const title = session.title.length > 40 ? session.title.slice(0, 37) + "..." : session.title
renderer.setTerminalTitle(`oc | ${title}`)
}
})
const args = useArgs()
onMount(() => {
batch(() => {

View file

@ -7,6 +7,8 @@ export const { use: useExit, provider: ExitProvider } = createSimpleContext({
init: (input: { onExit?: () => Promise<void> }) => {
const renderer = useRenderer()
return async (reason?: any) => {
// Reset window title before destroying renderer
renderer.setTerminalTitle("")
renderer.destroy()
await input.onExit?.()
if (reason) {