Skip to content

Commit 95bfe4a

Browse files
committed
feat(opencode): add click to rename session in TUI sidebar
- Add hover effect to session title in sidebar (grey background) - Add click handler that opens rename dialog - Pass dialog context to Sidebar component - Use onMouseUp to avoid dialog close conflicts Fixes anomalyco#13242
1 parent c6ec2f4 commit 95bfe4a

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/routes/session/index.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ export function Session() {
11051105
<Show when={sidebarVisible()}>
11061106
<Switch>
11071107
<Match when={wide()}>
1108-
<Sidebar sessionID={route.sessionID} />
1108+
<Sidebar sessionID={route.sessionID} dialog={dialog} />
11091109
</Match>
11101110
<Match when={!wide()}>
11111111
<box
@@ -1117,7 +1117,7 @@ export function Session() {
11171117
alignItems="flex-end"
11181118
backgroundColor={RGBA.fromInts(0, 0, 0, 70)}
11191119
>
1120-
<Sidebar sessionID={route.sessionID} />
1120+
<Sidebar sessionID={route.sessionID} dialog={dialog} />
11211121
</box>
11221122
</Match>
11231123
</Switch>

‎packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useSync } from "@tui/context/sync"
2-
import { createMemo, For, Show, Switch, Match } from "solid-js"
2+
import { createMemo, createSignal, For, Show, Switch, Match } from "solid-js"
33
import { createStore } from "solid-js/store"
44
import { useTheme } from "../../context/theme"
55
import { Locale } from "@/util/locale"
@@ -11,8 +11,10 @@ import { useKeybind } from "../../context/keybind"
1111
import { useDirectory } from "../../context/directory"
1212
import { useKV } from "../../context/kv"
1313
import { TodoItem } from "../../component/todo-item"
14+
import type { DialogContext } from "../../ui/dialog"
15+
import { DialogSessionRename } from "../../component/dialog-session-rename"
1416

15-
export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
17+
export function Sidebar(props: { sessionID: string; overlay?: boolean; dialog?: DialogContext }) {
1618
const sync = useSync()
1719
const { theme } = useTheme()
1820
const session = createMemo(() => sync.session.get(props.sessionID)!)
@@ -63,6 +65,8 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
6365
const directory = useDirectory()
6466
const kv = useKV()
6567

68+
const [titleHovered, setTitleHovered] = createSignal(false)
69+
6670
const hasProviders = createMemo(() =>
6771
sync.data.provider.some((x) => x.id !== "opencode" || Object.values(x.models).some((y) => y.cost?.input !== 0)),
6872
)
@@ -83,9 +87,22 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
8387
<scrollbox flexGrow={1}>
8488
<box flexShrink={0} gap={1} paddingRight={1}>
8589
<box paddingRight={1}>
86-
<text fg={theme.text}>
87-
<b>{session().title}</b>
88-
</text>
90+
<box
91+
backgroundColor={titleHovered() ? theme.borderSubtle : undefined}
92+
paddingLeft={titleHovered() ? 1 : 0}
93+
paddingRight={titleHovered() ? 1 : 0}
94+
onMouseOver={() => setTitleHovered(true)}
95+
onMouseOut={() => setTitleHovered(false)}
96+
onMouseUp={() => {
97+
if (props.dialog) {
98+
props.dialog.replace(() => <DialogSessionRename session={props.sessionID} />)
99+
}
100+
}}
101+
>
102+
<text fg={theme.text}>
103+
<b>{session().title}</b>
104+
</text>
105+
</box>
89106
<Show when={session().share?.url}>
90107
<text fg={theme.textMuted}>{session().share!.url}</text>
91108
</Show>

0 commit comments

Comments
 (0)