mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
feat(tui): add dynamic terminal window title (#5112)
This commit is contained in:
parent
2e5c2d5e98
commit
3ec34ee3dd
2 changed files with 22 additions and 0 deletions
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue