fix(web): keep onboarding and mobile natal board on one aligned overlay

Put the compact board trigger in the chat header, keep the sheet above the composer on iOS, and align onboarding messages with the intake card on the session column.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-20 23:54:20 +08:00
parent d3833356c7
commit 8b8e5214f9
7 changed files with 147 additions and 16 deletions
@@ -2,6 +2,7 @@
import { ArrowUp, Square } from "lucide-react";
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { parseAgentReply } from "@/lib/agent-reply";
import type { ChatMessage, ChatMessageView } from "@/lib/chat-message-view";
import {
@@ -262,9 +263,14 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
const [compactBoard, setCompactBoard] = useState(false);
const [boardOpen, setBoardOpen] = useState(false);
const [boardDiff, setBoardDiff] = useState(() => diffRectificationBoard(null, null));
const [headerSlot, setHeaderSlot] = useState<HTMLElement | null>(null);
const boardId = useId();
const boardTitleId = useId();
useLayoutEffect(() => {
setHeaderSlot(document.querySelector("[data-rectification-header-slot]"));
}, []);
useLayoutEffect(() => {
const query = window.matchMedia(`(max-width: ${RECTIFICATION_BOARD_SPLIT_MIN_PX - 1}px)`);
const update = () => {
@@ -682,11 +688,21 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
: undefined;
const canSend = !busy && !readonly && !regeneratingMessageKey;
const boardPeek = compactBoard && !boardOpen ? (
<RectificationBoardPeek
result={candidateResult}
expanded={boardOpen}
boardId={boardId}
onOpen={toggleBoard}
/>
) : null;
return (
<div
ref={workspace}
className={`rectification-workspace${compactBoard ? " is-compact" : ""}${boardOpen ? " is-board-open" : ""}`}
>
{headerSlot && boardPeek ? createPortal(boardPeek, headerSlot) : null}
<div className="rectification-workspace__chat" inert={compactBoard && boardOpen ? true : undefined}>
<section ref={conversation} className="conversation is-rectification" aria-label="生时校正对话" aria-busy={busy || regeneratingMessageKey !== null}>
<div className="message-list">
@@ -777,14 +793,6 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
</section>
<div className="composer-wrap">
{compactBoard && (
<RectificationBoardPeek
result={candidateResult}
expanded={boardOpen}
boardId={boardId}
onOpen={toggleBoard}
/>
)}
<form className="composer" onSubmit={submit}>
<Textarea
ref={composer}
@@ -271,6 +271,7 @@ export function RectificationBoardPeek({
<button
className="rectification-board-peek"
type="button"
aria-label={peek.detail ? `${peek.title}${peek.detail}` : peek.title}
aria-expanded={expanded}
aria-controls={boardId}
onClick={onOpen}