Skip to content
Merged
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
7 changes: 5 additions & 2 deletions packages/tui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,11 @@ function App(props: { pair?: DialogPairCredentials }) {
renderer.useMouse = config.data.mouse
})

let active: { id: string; title: string } | undefined
// Update terminal window title based on current route and session
createEffect(() => {
const session = route.data.type === "session" ? data.session.get(route.data.sessionID) : undefined
if (session) active = { id: session.id, title: session.title }
if (!terminalTitleEnabled()) return

if (route.data.type === "home") {
Expand All @@ -535,7 +538,6 @@ function App(props: { pair?: DialogPairCredentials }) {
}

if (route.data.type === "session") {
const session = data.session.get(route.data.sessionID)
if (!session || isDefaultTitle(session.title)) {
renderer.setTerminalTitle("OpenCode")
return
Expand Down Expand Up @@ -1160,10 +1162,11 @@ function App(props: { pair?: DialogPairCredentials }) {

event.on("session.deleted", (evt) => {
if (route.data.type === "session" && route.data.sessionID === evt.data.sessionID) {
const title = active?.id === evt.data.sessionID ? active.title : undefined
route.navigate({ type: "home" })
toast.show({
variant: "info",
message: "The current session was deleted",
message: title ? `Session "${title}" was deleted` : "The current session was deleted",
})
}
})
Expand Down
Loading