Skip to content

Commit 5d5e184

Browse files
committed
tui: improve session UI with better sidebar toggle and message handling
1 parent 2fbb49a commit 5d5e184

File tree

1 file changed

+23
-23
lines changed
  • packages/opencode/src/cli/cmd/tui/routes/session

1 file changed

+23
-23
lines changed

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,6 @@ export function Session() {
149149
}, 50)
150150
}
151151

152-
// snap to bottom when revert position changes
153-
createEffect((old) => {
154-
if (old !== session()?.revert?.messageID) toBottom()
155-
return session()?.revert?.messageID
156-
})
157-
158-
// snap to bottom when session changes
159-
createEffect(on(() => route.sessionID, toBottom))
160-
161152
const local = useLocal()
162153

163154
function moveChild(direction: number) {
@@ -272,14 +263,18 @@ export function Session() {
272263
const revert = session().revert?.messageID
273264
const message = messages().findLast((x) => (!revert || x.id < revert) && x.role === "user")
274265
if (!message) return
275-
sdk.client.session.revert({
276-
path: {
277-
id: route.sessionID,
278-
},
279-
body: {
280-
messageID: message.id,
281-
},
282-
})
266+
sdk.client.session
267+
.revert({
268+
path: {
269+
id: route.sessionID,
270+
},
271+
body: {
272+
messageID: message.id,
273+
},
274+
})
275+
.then(() => {
276+
toBottom()
277+
})
283278
const parts = sync.data.part[message.id]
284279
prompt.set(
285280
parts.reduce(
@@ -327,7 +322,7 @@ export function Session() {
327322
},
328323
},
329324
{
330-
title: "Toggle sidebar",
325+
title: sidebarVisible() ? "Hide sidebar" : "Show sidebar",
331326
value: "session.sidebar.toggle",
332327
keybind: "sidebar_toggle",
333328
category: "Session",
@@ -879,11 +874,16 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
879874
return (
880875
<>
881876
<For each={props.parts}>
882-
{(part) => {
877+
{(part, index) => {
883878
const component = createMemo(() => PART_MAPPING[part.type as keyof typeof PART_MAPPING])
884879
return (
885880
<Show when={component()}>
886-
<Dynamic component={component()} part={part as any} message={props.message} />
881+
<Dynamic
882+
last={index() === props.parts.length - 1}
883+
component={component()}
884+
part={part as any}
885+
message={props.message}
886+
/>
887887
</Show>
888888
)
889889
}}
@@ -944,7 +944,7 @@ const PART_MAPPING = {
944944
reasoning: ReasoningPart,
945945
}
946946

947-
function ReasoningPart(props: { part: ReasoningPart; message: AssistantMessage }) {
947+
function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: AssistantMessage }) {
948948
const { theme, syntax } = useTheme()
949949
const ctx = use()
950950
return (
@@ -973,7 +973,7 @@ function ReasoningPart(props: { part: ReasoningPart; message: AssistantMessage }
973973
)
974974
}
975975

976-
function TextPart(props: { part: TextPart; message: AssistantMessage }) {
976+
function TextPart(props: { last: boolean; part: TextPart; message: AssistantMessage }) {
977977
const ctx = use()
978978
const { syntax } = useTheme()
979979
return (
@@ -994,7 +994,7 @@ function TextPart(props: { part: TextPart; message: AssistantMessage }) {
994994

995995
// Pending messages moved to individual tool pending functions
996996

997-
function ToolPart(props: { part: ToolPart; message: AssistantMessage }) {
997+
function ToolPart(props: { last: boolean; part: ToolPart; message: AssistantMessage }) {
998998
const { theme } = useTheme()
999999
const sync = useSync()
10001000
const [margin, setMargin] = createSignal(0)

0 commit comments

Comments
 (0)