Skip to content

feat(conversation): let a workspace show content after the latest message - #4174

Draft
gilgtm wants to merge 1 commit into
mainfrom
needs-you/workspace-trailing-slot
Draft

gilgtm wants to merge 1 commit into
mainfrom
needs-you/workspace-trailing-slot

Conversation

@gilgtm

@gilgtm gilgtm commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A plugin page that shows a channel in ui.Workspace can now put content after the latest message, such as a card that asks the reader for a decision. It follows the pattern of #4071 and #4072: a new optional prop, detected through a frozen ctx.conversation.workspaceSlots flag. Nothing changes unless a page passes the prop.

trailing?: {
  restHeight: number;
  content(state: { expanded: boolean; toggle(): void }): ReactNode;
};

FOUNDATION files: src/features/conversation/contracts.ts (the prop and its doc comment, +8 lines) and src/features/conversation/service.tsx (workspaceSlots = Object.freeze({ trailing: true }) and its type, +8 lines). Whichever of this PR, #4071 and #4072 lands second merges its flag into the same object.

Behavior

The contract applies to a channel target only; a thread target ignores trailing.

  • Rest: the content sticks to the bottom of the history with its first restHeight pixels in view, just below the latest message. This rest position is the timeline's latest position for following, Jump to latest, the at-bottom test, the scroll after a send, and catch-up reading. Rows that the content covers are not read.
  • Growing: scrolling past the latest message grows the content into view until its end shows. There is no stop at rest on a fast scroll. Scrolling up leaves the content at its rest height over older history. The reader keeps their place in the content through new messages, older pages and resizes. While the content is expanded, the Jump pill appears only when new messages arrive.
  • toggle():
    • When not expanded, it scrolls to the content's top with 100px of history above it. The gap narrows to a third of a shorter history, and never below the rest height. If the whole content fits, it scrolls to the content's end.
    • When expanded, it scrolls back to rest.
    • It jumps without animation under reduced motion.
    • state.expanded is true past the rest position.
  • Reveals: a reveal of a message near the end stops at the latest message, short of the content.
  • Layout details:
    • While trailing content is present, the feed drops its 2px end inset, so a position: sticky; bottom: 0 footer inside the content sits flush on the history's bottom edge.
    • The scroll range ends on a whole pixel, which keeps that footer from rising by up to a pixel.
    • The content's own margins count toward its measured height (display: flow-root).

Docs: docs/plugin-architecture.md and docs/plugin-authoring-guide.md. The guide advises an opaque sticky footer, and a box-shadow outline rather than a bottom border, because a sticky element sits inside its box's border.

Validation

  • Vitest: messages, channels and conversation pass (5,206 tests). New unit tests cover:

    • covered rows not being read, and catch-up at rest (use-reading.test.ts);
    • channel-only routing (ConversationTab.test.tsx, PageTabs.test.tsx);
    • the slot flag (service.test.tsx).
  • Browser: 11 new cases (22 runs across both engines) in tests/browser/conversation-workspace.spec.mjs (trailing content), which pass on Chromium and WebKit. Each one needs real layout, sticky positioning and scroll ranges, which jsdom can't provide.

    • Rest, Growing, a live message while Growing, resize, and Jump.
    • Full brief for a long card (card top 100px below) and a short card (end of range), then Hide.
    • Reduced motion.
    • A short history narrowing the gap.
    • A reveal of the latest message.
    • A resize at rest, narrower and then wider, staying at rest.
    • A follower's small scroll above the latest message, kept as the card grows.
    • Removing a grown card in place.
    • A live resize at rest: 30 steps narrower and then 30 wider, faster than the timeline renders, staying at rest after each direction.
    • Rows changing height during the toggle's smooth scroll, for Full brief and then Hide.
  • Fail-then-pass checks:

    • Reverting the toggle target and the inset fails 6 cases.
    • Moving the reveal clamp back after the hold fails the reveal case (6 of 6 repeats).
    • Removing the expanded reset fails the removal case.
    • Removing flow-root fails three cases.
    • Without the resize check in the position record, the resize-at-rest case fails on both engines: a resize kept the old end offset, which was recorded as a place 48px past the latest message.
    • Realigning a follower to the latest message instead of keeping their gap fails the small-scroll case on both engines: the hold undid a 40px scroll at once.
    • Before the tail observer deferred to the card's hold, the live-resize case failed on both engines. The observer scrolled to the latest message using the card's previous extent, so after widening the reader was left past rest by the card's shrink.
    • Hosted CI failed the live-resize case on every run (the reader 144px off rest at 860px). The timeline's first frame after a size change sampled the offset as reader input, so the rows rewrapping read as the reader moving past the latest message; follow stopped and nothing realigned. It now samples that movement as layout unless input is under way. With the test resizing without frame waits, it failed 2 of 4 local Chromium repeats before the fix and passed 16 of 16 (both engines, two workers) after. It is a timing repro: without the fix it can pass on a fast machine. Broader checks after the fix: scroll, channel-opening and this spec pass on Chromium, WebKit and both measurement projects (44 cases), and the 3,673 src/features/messages unit tests pass.
    • Before layout retargeted the toggle's scroll, the toggle case failed on both engines with the card's top at 271px instead of 100px. Rows measuring mid-scroll made the hold assign the offset, which cut the animation short. This is the failure the two Full brief cases showed on Linux Chromium CI.
  • CI: the React feat: persist sidebar preferences in packaged desktop #440 failures ("useEffectEvent called during render") in navigation-thread-history, inbox-parity, initial-position, right-pane-dismissal, thread-unread and channel-opening came from this PR. use-reading called the trailing edge through an effect event, and unread attention reaches it while rows render. The edge is now a ref, and those specs pass on both engines. main passes them.

  • Other specs: history-loading, history-prefix, timeline-setup and navigation-channel-history pass on both engines. One existing WebKit case, timeline-setup "wheel baseline", failed 1 of 3 on repeat. It uses static page.setContent and doesn't load this code, and it passed 4 of 4 on the base revision.

  • Native (packaged macOS app, local relay, throwaway plugin): an annotated run covered:

    • rest with a flush footer;
    • growing via simulated wheel input;
    • Hide;
    • Full brief landing 100px down;
    • a peer's live message keeping the place;
    • a composer send landing above the resting card, checked on the relay.

    That run found the collapsed-margin bug fixed here.

  • Not verified:

    • Real trackpad momentum in WKWebView. The scenario uses a DOM wheel event plus a scroll.
    • A browser journey for read state, which the unit tests cover.
    • An older-page prepend while expanded.

🤖 Generated with Claude Code

…test message

A plugin page that shows a channel through `ui.Workspace` can pass
`trailing: { restHeight, content({ expanded, toggle }) }` to show a card,
such as a decision to make, over the end of the channel timeline. The host
advertises the slot with `ctx.conversation.workspaceSlots.trailing`; a thread
target and older hosts ignore it.

The card scrolls in its own sheet over the history. At rest its first
`restHeight` pixels sit below the latest message, which a box of that height
keeps above it. A wheel or touch over the card grows it, then slides it up
off the view's top; the history never moves. Over the history above a grown
card, the history scrolls as usual. `toggle()` grows the card to 60px below
the view's top, re-aiming if the layout settles mid-scroll, and back. Jump to
latest and a send return the card to rest. Jump to latest stays above the
card's visible top, and rows under the card aren't marked read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gil Birman <gil@squareup.com>
@gilgtm
gilgtm force-pushed the needs-you/workspace-trailing-slot branch from 2b9781d to 9ae351e Compare November 23, 2026 18:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant