From d7c2d5db3bc261764b415f0e6c50f1d5908a99a6 Mon Sep 17 00:00:00 2001
From: Adam <2363879+adamdotdevin@users.noreply.github.com>
Date: Thu, 5 Feb 2026 14:42:56 -0600
Subject: fix(app): hide prompt input when there are perms or questions
(#12339)
---
packages/ui/src/components/session-turn.tsx | 89 ++++++++---------------------
1 file changed, 23 insertions(+), 66 deletions(-)
(limited to 'packages/ui/src')
diff --git a/packages/ui/src/components/session-turn.tsx b/packages/ui/src/components/session-turn.tsx
index 5c4678701..5ea9f64bb 100644
--- a/packages/ui/src/components/session-turn.tsx
+++ b/packages/ui/src/components/session-turn.tsx
@@ -10,7 +10,6 @@ import {
} from "@opencode-ai/sdk/v2/client"
import { useData } from "../context"
import { type UiI18nKey, type UiI18nParams, useI18n } from "../context/i18n"
-import { findLast } from "@opencode-ai/util/array"
import { Binary } from "@opencode-ai/util/binary"
import { createEffect, createMemo, createSignal, For, Match, on, onCleanup, ParentProps, Show, Switch } from "solid-js"
@@ -84,6 +83,7 @@ function AssistantMessageItem(props: {
responsePartId: string | undefined
hideResponsePart: boolean
hideReasoning: boolean
+ hidden?: () => readonly { messageID: string; callID: string }[]
}) {
const data = useData()
const emptyParts: PartType[] = []
@@ -104,13 +104,22 @@ function AssistantMessageItem(props: {
parts = parts.filter((part) => part?.type !== "reasoning")
}
- if (!props.hideResponsePart) return parts
+ if (props.hideResponsePart) {
+ const responsePartId = props.responsePartId
+ if (responsePartId && responsePartId === lastTextPart()?.id) {
+ parts = parts.filter((part) => part?.id !== responsePartId)
+ }
+ }
- const responsePartId = props.responsePartId
- if (!responsePartId) return parts
- if (responsePartId !== lastTextPart()?.id) return parts
+ const hidden = props.hidden?.() ?? []
+ if (hidden.length === 0) return parts
- return parts.filter((part) => part?.id !== responsePartId)
+ const id = props.message.id
+ return parts.filter((part) => {
+ if (part?.type !== "tool") return true
+ const tool = part as ToolPart
+ return !hidden.some((h) => h.messageID === id && h.callID === tool.callID)
+ })
})
return
@@ -140,7 +149,6 @@ export function SessionTurn(
const emptyFiles: FilePart[] = []
const emptyAssistant: AssistantMessage[] = []
const emptyPermissions: PermissionRequest[] = []
- const emptyPermissionParts: { part: ToolPart; message: AssistantMessage }[] = []
const emptyQuestions: QuestionRequest[] = []
const emptyQuestionParts: { part: ToolPart; message: AssistantMessage }[] = []
const idle = { type: "idle" as const }
@@ -253,48 +261,18 @@ export function SessionTurn(
})
const permissions = createMemo(() => data.store.permission?.[props.sessionID] ?? emptyPermissions)
- const permissionCount = createMemo(() => permissions().length)
const nextPermission = createMemo(() => permissions()[0])
- const permissionParts = createMemo(() => {
- if (props.stepsExpanded) return emptyPermissionParts
-
- const next = nextPermission()
- if (!next || !next.tool) return emptyPermissionParts
-
- const message = findLast(assistantMessages(), (m) => m.id === next.tool!.messageID)
- if (!message) return emptyPermissionParts
-
- const parts = data.store.part[message.id] ?? emptyParts
- for (const part of parts) {
- if (part?.type !== "tool") continue
- const tool = part as ToolPart
- if (tool.callID === next.tool?.callID) return [{ part: tool, message }]
- }
-
- return emptyPermissionParts
- })
-
const questions = createMemo(() => data.store.question?.[props.sessionID] ?? emptyQuestions)
const nextQuestion = createMemo(() => questions()[0])
- const questionParts = createMemo(() => {
- if (props.stepsExpanded) return emptyQuestionParts
-
- const next = nextQuestion()
- if (!next || !next.tool) return emptyQuestionParts
-
- const message = findLast(assistantMessages(), (m) => m.id === next.tool!.messageID)
- if (!message) return emptyQuestionParts
-
- const parts = data.store.part[message.id] ?? emptyParts
- for (const part of parts) {
- if (part?.type !== "tool") continue
- const tool = part as ToolPart
- if (tool.callID === next.tool?.callID) return [{ part: tool, message }]
- }
-
- return emptyQuestionParts
+ const hidden = createMemo(() => {
+ const out: { messageID: string; callID: string }[] = []
+ const perm = nextPermission()
+ if (perm?.tool) out.push(perm.tool)
+ const question = nextQuestion()
+ if (question?.tool) out.push(question.tool)
+ return out
})
const answeredQuestionParts = createMemo(() => {
@@ -499,14 +477,6 @@ export function SessionTurn(
onCleanup(() => clearInterval(timer))
})
- createEffect(
- on(permissionCount, (count, prev) => {
- if (!count) return
- if (prev !== undefined && count <= prev) return
- autoScroll.forceScrollToBottom()
- }),
- )
-
let lastStatusChange = Date.now()
let statusTimeout: number | undefined
createEffect(() => {
@@ -664,6 +634,7 @@ export function SessionTurn(
responsePartId={responsePartId()}
hideResponsePart={hideResponsePart()}
hideReasoning={!working()}
+ hidden={hidden}
/>
)}
@@ -674,20 +645,6 @@ export function SessionTurn(
- 0}>
-
-
- {({ part, message }) => }
-
-
-
- 0}>
-
-
- {({ part, message }) => }
-
-
-
0}>
--
cgit v1.2.3