feat(sidechat): collapse the pre-fork context behind one divider line
A side thread opens on its own question, so the inherited exchange belongs behind a boundary, not on the first screen: rendered open it read as if the side thread had asked the parent's question. The fork block is now a native disclosure, closed on first render and controlled through its toggle event (React would otherwise reset the DOM's own `open` on the next poll render). Collapsed, the block is exactly the opening divider: the summary carries the `sideChatForkDivider` copy and the chevron, never any inherited text. Expanded, the body keeps the established order — the question in the user bubble, the answer as assistant prose through the same markdown renderer, both verbatim — then the closing `sideChatForkDividerEnd` line. With no answer the body is the question and the closing line only. The block stays chrome: it is not a transcript row, the row count does not move when it opens or closes, and it adds no button or link beyond the summary.
This commit is contained in:
1 parent
0bc77c551f
commit
0bc07a016c
3 files changed
+269
-164
No files matched your search
@@ -759,10 +759,11 @@
|
||||
}
|
||||
|
||||
/* ── motion vocabulary (crossfade only, ≤200ms; loops reduced-motion off) */
|
||||
/* The pre-fork context. NOT a card: a divider line, then the parent's last
|
||||
* exchange rendered as this thread's own messages (the `sidechatUser` bubble
|
||||
* and the `sidechatAssistant` prose carry their own look), so the block only
|
||||
* spaces the pieces and cannot drift from the conversation below it. */
|
||||
/* The pre-fork context. NOT a card: a native disclosure whose collapsed line is
|
||||
* the opening divider, and whose body is the parent's last exchange rendered as
|
||||
* this thread's own messages (the `sidechatUser` bubble and the
|
||||
* `sidechatAssistant` prose carry their own look), so the block only spaces the
|
||||
* pieces and cannot drift from the conversation below it. */
|
||||
.sidechatForkPoint {
|
||||
flex: none;
|
||||
display: flex;
|
||||
@@ -771,6 +772,33 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* The disclosure's line: the divider's hairline-and-copy chrome (see below)
|
||||
* plus the chevron instead of the marker, so the closed block reads as one
|
||||
* boundary line and nothing else. */
|
||||
.sidechatForkPointLine {
|
||||
padding: 1px 0;
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidechatForkPointLine::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidechatForkPoint[open] .sidechatForkPointLine .sidechatRowChevron {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* The expanded body: the inherited exchange at the rhythm the block has always
|
||||
* used (8px between the pieces), inside the disclosure so a closed block hides
|
||||
* it natively. */
|
||||
.sidechatForkPointBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* The boundary: a hairline either side of the localized copy, so the reader
|
||||
* sees where the inherited conversation ends. */
|
||||
.sidechatForkDivider {
|
||||
|
||||
+55
-32
@@ -557,15 +557,14 @@ function TurnFold(props: {
|
||||
}
|
||||
|
||||
/**
|
||||
* The pre-fork context, rendered as the conversation it was.
|
||||
* The pre-fork context, tucked behind one divider line.
|
||||
*
|
||||
* The reader's verdict on the card that shipped first was that this should not
|
||||
* be a card at all: two matching divider lines bracket the block — the first
|
||||
* says where it came from, the last where the inherited context stops — and the
|
||||
* parent's last exchange between them looks exactly like the messages under it:
|
||||
* the question as this thread's own user bubble, the answer as its own assistant
|
||||
* prose, both through the same markdown renderer (and the same prose pass) the
|
||||
* rows use, both carried verbatim. Nothing here expands or collapses.
|
||||
* A side thread opens on the side question, as if the conversation began there;
|
||||
* the inherited exchange is CONTEXT, not conversation — rendered permanently
|
||||
* open it pushes the reader's own question off the first screen and reads as if
|
||||
* THIS thread had asked it. So the block is a native disclosure: collapsed it is
|
||||
* one line of divider chrome, expanded it is the parent's last exchange between
|
||||
* the opening and closing divider lines.
|
||||
*/
|
||||
function ForkBlock(props: {
|
||||
/** The parent's last question, verbatim. */
|
||||
@@ -577,33 +576,57 @@ function ForkBlock(props: {
|
||||
/** The view's row prose pass (image destinations, then local links). */
|
||||
rewrite: (text: string) => string
|
||||
}): React.ReactNode {
|
||||
// `<details>` is controlled: React would otherwise reset the DOM's own
|
||||
// `open` on the next render (the transcript re-renders on every poll), so the
|
||||
// toggle event — the only reliable report of a native open/close — is the
|
||||
// single source of truth.
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<div className={css.sidechatForkPoint} data-sidechat-fork-point="">
|
||||
<div className={css.sidechatForkDivider} data-sidechat-fork-divider="">
|
||||
<details
|
||||
className={css.sidechatForkPoint}
|
||||
data-sidechat-fork-point=""
|
||||
open={open}
|
||||
onToggle={event => setOpen(event.currentTarget.open)}
|
||||
>
|
||||
{/* The collapsed line IS the opening divider: the same hairline-and-copy
|
||||
chrome as the closing one, plus the disclosure's own chevron. It never
|
||||
carries inherited text — the line says where the context came from,
|
||||
not what was said in it. */}
|
||||
<summary
|
||||
className={clsx(css.sidechatForkDivider, css.sidechatForkPointLine)}
|
||||
data-sidechat-fork-divider=""
|
||||
>
|
||||
{t('sideChatForkDivider')}
|
||||
<span className={css.sidechatRowChevron}>
|
||||
<IconChevronRightOutlineRegular size={12} />
|
||||
</span>
|
||||
</summary>
|
||||
{/* The body stays mounted (a closed `<details>` hides it natively), so
|
||||
expanding costs no refetch and the exchange is already there. */}
|
||||
<div className={css.sidechatForkPointBody}>
|
||||
{props.user === undefined
|
||||
? null
|
||||
: (
|
||||
// The same presentation block a user row renders, so the inherited
|
||||
// question can never drift from the thread's own bubbles.
|
||||
<div className={css.sidechatUser} data-sidechat-fork-question="">
|
||||
<MarkdownText {...markdownTextProps(props.rewrite(props.user), props.labels)} />
|
||||
</div>
|
||||
)}
|
||||
{props.answer === undefined || props.answer === ''
|
||||
? null
|
||||
: (
|
||||
<div className={css.sidechatAssistant}>
|
||||
<MarkdownText {...markdownTextProps(props.rewrite(props.answer), props.labels)} />
|
||||
</div>
|
||||
)}
|
||||
{/* The same line closes the block: the inherited context stops here, so
|
||||
what follows reads as this thread's own conversation again. */}
|
||||
<div className={css.sidechatForkDivider} data-sidechat-fork-divider-end="">
|
||||
{t('sideChatForkDividerEnd')}
|
||||
</div>
|
||||
</div>
|
||||
{props.user === undefined
|
||||
? null
|
||||
: (
|
||||
// The same presentation block a user row renders, so the inherited
|
||||
// question can never drift from the thread's own bubbles.
|
||||
<div className={css.sidechatUser} data-sidechat-fork-question="">
|
||||
<MarkdownText {...markdownTextProps(props.rewrite(props.user), props.labels)} />
|
||||
</div>
|
||||
)}
|
||||
{props.answer === undefined || props.answer === ''
|
||||
? null
|
||||
: (
|
||||
<div className={css.sidechatAssistant}>
|
||||
<MarkdownText {...markdownTextProps(props.rewrite(props.answer), props.labels)} />
|
||||
</div>
|
||||
)}
|
||||
{/* The same line closes the block: the inherited context stops here, so
|
||||
what follows reads as this thread's own conversation again. */}
|
||||
<div className={css.sidechatForkDivider} data-sidechat-fork-divider-end="">
|
||||
{t('sideChatForkDividerEnd')}
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user