mirror of
https://github.com/different-ai/openwork.git
synced 2026-11-23 12:51:42 +08:00
fix(chat): keep the thread still when a message is sent (#7583)
A sent message hid its hover actions row while it was the last message of a running turn. That is exactly the moment between the run starting and the first reply arriving, so on every send the message lost the row's height and the thread dropped, then jumped back when the reply appeared. The row now always renders (it stays hidden until hover), so the sent message keeps one height through the whole send. Signed-off-by: Jalil <reachjalil@gmail.com>
This commit is contained in:
1 parent
a0d6d580f3
commit
dfbbc0aac5
2 files changed
+14
-9
No files matched your search
@@ -755,7 +755,6 @@ AssistantMessage.displayName = "AssistantMessage"
|
||||
|
||||
type UserMessageProps = {
|
||||
message: UIMessage
|
||||
isStreaming: boolean
|
||||
}
|
||||
|
||||
function fileBytes(part: FileUIPart) {
|
||||
@@ -976,7 +975,7 @@ function renderUserText(text: string, highlightQuery: string | undefined, refere
|
||||
}
|
||||
|
||||
const UserMessage = React.memo(
|
||||
({ message, isStreaming }: UserMessageProps) => {
|
||||
({ message }: UserMessageProps) => {
|
||||
const { onRevertToUserMessage, onEditUserMessage, highlightQuery, readOnly } = useMessageList()
|
||||
const references = useSessionReferencesMaybe()
|
||||
const wall = messageAutoAccessWall(message.metadata)
|
||||
@@ -1066,7 +1065,7 @@ const UserMessage = React.memo(
|
||||
})}
|
||||
</MessageContent>
|
||||
) : null}
|
||||
{!isStreaming && !wall && (
|
||||
{!wall && (
|
||||
<MessageActions
|
||||
className="flex items-center gap-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100 max-lg:opacity-100 pointer-coarse:opacity-100"
|
||||
>
|
||||
@@ -1161,10 +1160,7 @@ const MessageComponent = React.memo(
|
||||
}
|
||||
|
||||
return (
|
||||
<UserMessage
|
||||
message={message}
|
||||
isStreaming={isStreaming}
|
||||
/>
|
||||
<UserMessage message={message} />
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ function reloadedTurn(): UIMessage {
|
||||
return message
|
||||
}
|
||||
|
||||
async function render(messages: UIMessage[], onEditUserMessage: (...args: unknown[]) => void) {
|
||||
async function render(messages: UIMessage[], onEditUserMessage: (...args: unknown[]) => void, status: "ready" | "streaming" = "ready") {
|
||||
const container = document.createElement("div")
|
||||
document.body.append(container)
|
||||
const root = createRoot(container)
|
||||
@@ -58,7 +58,7 @@ async function render(messages: UIMessage[], onEditUserMessage: (...args: unknow
|
||||
dispatchAction: () => {}, setPrompt: () => {}, onRevertToUserMessage: () => {},
|
||||
onForkAtMessage: () => {}, onEditUserMessage,
|
||||
onMcpReconnect: async () => {}, onMcpReopenAuthorization: async () => {},
|
||||
children: createElement(MessageList, { messages, status: "ready", activityStatus: "idle" }),
|
||||
children: createElement(MessageList, { messages, status, activityStatus: status === "streaming" ? "responding" : "idle" }),
|
||||
}),
|
||||
}) }) })))
|
||||
return container
|
||||
@@ -85,3 +85,12 @@ test("Edit restores the chips as composer tokens and mentions", async () => {
|
||||
expect(calls[0]?.[1]).toBe("[connect-skill meeting-analysis|Meeting analysis|OpenWork|skill:meeting-analysis] today's meeting@explore")
|
||||
expect(calls[0]?.[2]).toMatchObject({ mentions: { explore: "agent" } })
|
||||
})
|
||||
|
||||
// Hiding the row while the run starts, then showing it again when the first
|
||||
// reply arrives, made the thread drop and come back on every send.
|
||||
test("a just-sent message keeps its action row while the reply starts", async () => {
|
||||
const container = await render([reloadedTurn()], () => {}, "streaming")
|
||||
const bubble = container.querySelector('[data-message-role="user"]')
|
||||
const labels = [...(bubble?.querySelectorAll("button") ?? [])].map((button) => button.getAttribute("aria-label"))
|
||||
expect(labels).toEqual(["Copy message", "Edit message", "Revert"])
|
||||
})
|
||||
Reference in new issue
Block a user