Skip to content

Commit 87054ee

Browse files
committed
fix flickering/layout shift during work
1 parent 81245c2 commit 87054ee

File tree

1 file changed

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

1 file changed

+5
-55
lines changed

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

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
For,
77
Match,
88
on,
9-
onCleanup,
10-
onMount,
119
Show,
1210
Switch,
1311
useContext,
@@ -45,7 +43,6 @@ import type { TaskTool } from "@/tool/task"
4543
import { useKeyboard, useRenderer, useTerminalDimensions, type BoxProps, type JSX } from "@opentui/solid"
4644
import { useSDK } from "@tui/context/sdk"
4745
import { useCommandDialog } from "@tui/component/dialog-command"
48-
import { Shimmer } from "@tui/ui/shimmer"
4946
import { useKeybind } from "@tui/context/keybind"
5047
import { Header } from "./header"
5148
import { parsePatch } from "diff"
@@ -64,8 +61,6 @@ import { Clipboard } from "../../util/clipboard"
6461
import { Toast, useToast } from "../../ui/toast"
6562
import { useKV } from "../../context/kv.tsx"
6663
import { Editor } from "../../util/editor"
67-
import { Global } from "@/global"
68-
import fs from "fs/promises"
6964
import stripAnsi from "strip-ansi"
7065

7166
addDefaultParsers(parsers.parsers)
@@ -106,6 +101,10 @@ export function Session() {
106101
return messages().findLast((x) => x.role === "assistant" && !x.time.completed)?.id
107102
})
108103

104+
const lastAssistant = createMemo(() => {
105+
return messages().findLast((x) => x.role === "assistant")
106+
})
107+
109108
const dimensions = useTerminalDimensions()
110109
const [sidebar, setSidebar] = createSignal<"show" | "hide" | "auto">(kv.get("sidebar", "auto"))
111110
const [conceal, setConceal] = createSignal(true)
@@ -513,7 +512,6 @@ export function Session() {
513512
return
514513
}
515514

516-
console.log(text)
517515
const base64 = Buffer.from(text).toString("base64")
518516
const osc52 = `\x1b]52;c;${base64}\x07`
519517
const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
@@ -846,7 +844,7 @@ export function Session() {
846844
</Match>
847845
<Match when={message.role === "assistant"}>
848846
<AssistantMessage
849-
last={pending() === message.id}
847+
last={lastAssistant()?.id === message.id}
850848
message={message as AssistantMessage}
851849
parts={sync.data.part[message.id] ?? []}
852850
/>
@@ -975,13 +973,6 @@ function UserMessage(props: {
975973
function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; last: boolean }) {
976974
const local = useLocal()
977975
const { theme } = useTheme()
978-
const sync = useSync()
979-
const status = createMemo(
980-
() =>
981-
sync.data.session_status[props.message.sessionID] ?? {
982-
type: "idle",
983-
},
984-
)
985976
return (
986977
<>
987978
<For each={props.parts}>
@@ -1014,46 +1005,6 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
10141005
</box>
10151006
</Show>
10161007
<Switch>
1017-
<Match when={props.last && status().type !== "idle" && false}>
1018-
<box paddingLeft={3} flexDirection="row" gap={1} marginTop={1}>
1019-
<text fg={local.agent.color(props.message.mode)}>{Locale.titlecase(props.message.mode)}</text>
1020-
<Shimmer text={props.message.modelID} color={theme.text} />
1021-
{(() => {
1022-
const retry = createMemo(() => {
1023-
const s = status()
1024-
if (s.type !== "retry") return
1025-
return s
1026-
})
1027-
const message = createMemo(() => {
1028-
const r = retry()
1029-
if (!r) return
1030-
if (r.message.includes("exceeded your current quota") && r.message.includes("gemini"))
1031-
return "gemini 3 way too hot right now"
1032-
if (r.message.length > 50) return r.message.slice(0, 50) + "..."
1033-
return r.message
1034-
})
1035-
const [seconds, setSeconds] = createSignal(0)
1036-
onMount(() => {
1037-
const timer = setInterval(() => {
1038-
const next = retry()?.next
1039-
if (next) setSeconds(Math.round((next - Date.now()) / 1000))
1040-
}, 1000)
1041-
1042-
onCleanup(() => {
1043-
clearInterval(timer)
1044-
})
1045-
})
1046-
return (
1047-
<Show when={retry()}>
1048-
<text fg={theme.error}>
1049-
{message()} [retrying {seconds() > 0 ? `in ${seconds()}s ` : ""}
1050-
attempt #{retry()!.attempt}]
1051-
</text>
1052-
</Show>
1053-
)
1054-
})()}
1055-
</box>
1056-
</Match>
10571008
<Match
10581009
when={
10591010
(props.message.time.completed &&
@@ -1535,7 +1486,6 @@ ToolRegistry.register<typeof EditTool>({
15351486

15361487
const ft = createMemo(() => filetype(props.input.filePath))
15371488

1538-
createEffect(() => console.log(props.metadata.diagnostics))
15391489
const diagnostics = createMemo(() => {
15401490
const arr = props.metadata.diagnostics?.[props.input.filePath ?? ""] ?? []
15411491
return arr.filter((x) => x.severity === 1).slice(0, 3)

0 commit comments

Comments
 (0)