Skip to content

Inbox: pull the open reply box out of Thread.tsx into an Inbox-only view (no change) - #4044

Merged
backnotprop merged 5 commits into
mainfrom
refactor/inbox-replybox-shell
Nov 26, 2026
Merged

backnotprop merged 5 commits into
mainfrom
refactor/inbox-replybox-shell

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

PR 1 of the reply box move (SIZING step 7a, "Inbox-only: pull ReplyBox out of Thread.tsx"). The hosted Spaces app will reuse the Inbox's reply box from the shared package. The box was not a component: it was inline JSX in Thread.tsx (the box.open ? (<>…</>) branch of the foot), and its state was spread through Thread.

This PR moves that JSX, unchanged, into packages/inbox/components/reply/ReplyBox.tsx. The new component is an Inbox-only view shell: props in, callbacks out. Thread keeps every hook, effect, state, ref and handler, and renders <ReplyBox … /> in the same place. Nothing moves to packages/ui or packages/core. No class is renamed and no CSS changes. A person sees no difference.

  • Thread.tsx: 5832 → 5723 lines (ceiling lowered in tests/inbox-size-ceilings.json).
  • ReplyBox.tsx: 326 lines. components/ is not one of the capped folders, and the file is under 1500 lines, so inbox-structure.test.ts needs no entry for it.

Prop surface (56 props)

Group n Props
Words and draft 8 replyText (the ReplyText store, not a value), sendingWords, onChange, onFieldKeyDown, replyToNames, quote, quotedMessage, onRemoveQuote
Recipients 1 recipientPill (a ReactNode built in Thread: a computer's chip leads the words, a phone's sits in the row)
Files 8 files, onRemoveFile, onPutBackFile, onAttachFiles, onShowFiles, dropOver, dropHandlers, onPaste
Voice 1 voice (the whole VoiceHandle)
Skills, mentions, tags 5 skillFilter, commands, tags, onOpenSkills, noSkillsHint
What goes with the reply 10 draftAnswers, draftActions, replySkip, dropped, comments, replySummaryShown, chips (ReactNode), fold, onFold, fitKey
Send, close, discard, restore 8 sending, sendAria, onSend, onClose, onDiscardDraft, onRestoreDraft, routeChoiceOpen, routeChoice (ReactNode)
Notices and conflict lines 9 offerShown, conflict (DraftConflict or null: id, text, Keep mine, Discard mine), takeBack, staleQuestions, onJump, draftStamp (ReactNode), draftNotSaved, errorLine (ReactNode), askerNoteId
Phone or desktop 1 phone
Focus and refs 4 textRef, sendRef, scrollRef, draftAboveRef
Context 1 thread (ChangedNotice and the field's mention thread)

Awkward parts, left for later PRs:

  • Five props are elements that Thread builds with closures of their own: recipientPill, chips, draftStamp, routeChoice and errorLine.
  • onFieldKeyDown holds the ⌘↵ and Esc logic (route choice, sentByChord, send). The conflict.onKeepMine closure holds the Keep mine save. Both stay in Thread, as the brief asks.
  • voice is a controller handle and replyText is a module-level store. Neither is a plain value yet.
  • Three values are derived, not passed:
    • The skip's screen-reader line and ReplyRow's keepOpen read replySkip. This equals the old skipping / skipIds.size / keepOpen: replySkip = { count: keepOpen ? unanswered.length : skipIds.size, keepOpen }, and skipping = !keepOpen.
    • routeChoiceOpen is passed as !!(route.open && asking).
    • The bin's "Discard mine" uses conflict.onDiscard, which is the same discardMine.
  • Two DOM-only helpers are called inside the view: focusReplyFromBox and caretToEndOnFirstFocus. The view also puts focus back in the field after a tile's ×.

How "no change" is proven

packages/inbox/components/reply/replyBoxParity.test.tsx is DOM-gated and listed in tests/dom-test-list.txt. It drives the real ThreadPane over a scripted Inbox: a stubbed fetch with the draft store's compare-and-set, a scripted voice recorder and no server. For each state it compares the outerHTML of .ib-pfoot byte for byte with fixtures in replyBoxParity/. Two things are normalized first: React's _r_N_ useId counter and AM/PM clock times. The fixtures were captured on unmodified main (8c44d10) in this worktree before the move. The same file then passes, 13/13, after the move.

The twelve states: closed foot (empty), closed foot with words kept, open and empty, open with words, a saved draft waiting (Restore draft), "Not saved", the conflict (Keep mine / Discard mine), a file tile, two agents (recipient chip ticked to "2 agents" plus an @Pi tag), a voice note recording, phone with words (Draft line, summary line, row), and phone with two agents.

The test catches real changes: swapping the order of two attributes on .ib-rnote failed exactly the "Not saved" case. To capture the fixtures again after an intended change, run with REPLYBOX_PARITY_WRITE=1 DOM_TESTS=1.

Not run: bun run test:parity:inbox-thread (scripts/inbox-thread-parity.ts). It builds two binaries, starts an Inbox for each and runs Playwright, which the builder rules forbid locally, and no CI workflow runs it. Pixels are therefore not compared here; the DOM test compares markup only.

Tests run locally (one file each, sandboxed)

  • New replyBoxParity.test.tsx: 13 pass, both before the move (capture and re-run) and after it.
  • Existing DOM tests that draw the reply box, all passing:
    • replyBoxTyping 4
    • replyDraftNeverLost 48
    • replyFootPhone 26
    • replyRecipient 35
    • voiceKeptWords 13
    • takeBack 6
    • phoneComposer 15
    • paneFailureKeepsReply 3
    • mentionMenuShows 9
    • fullScreenComposerRenders 2
    • floaters 15
    • agentFacesEverywhere 10
    • ownAgentIcons 6
    • setAgentIcons 11
  • tagAgents.test.tsx starts an Inbox (inbox-dom-server), so it was left to CI.
  • Other checks:
    • tests/inbox-structure.test.ts: 5 pass
    • tests/inbox-thread-parts-host-neutral.test.ts: 3 pass
    • scripts/dom-test-allowlist.test.ts: 1 pass
    • tsc -p packages/inbox and tsc -p apps/inbox: clean

Next (out of scope here)

  • PR 2: strip the module-level singletons the box leans on (replyText store, replyDraft page maps, voice browserDeps) and add a VoiceTransport seam.
  • PR 3: a useReplyComposer controller that owns the box's state and handlers, so Thread passes one object and the ReactNode props become data.
  • PR 4: move the shell to @plannotator/ui (host-neutral rules, the CSS generator, phoneComposer.css).

The open reply box was inline JSX in Thread.tsx. It is now
components/reply/ReplyBox.tsx, drawn from props with callbacks out;
Thread keeps every hook, effect, state and handler and renders
<ReplyBox ... />. Same DOM: replyBoxParity.test.tsx compares the
thread foot's outerHTML in twelve states with fixtures captured on
main before the move. Thread.tsx goes from 5832 to 5723 lines.
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 25, 2026
…/inbox-replybox-shell

# Conflicts:
#	packages/inbox/components/Thread.tsx
#	tests/dom-test-list.txt
#	tests/inbox-size-ceilings.json
…/inbox-replybox-shell

# Conflicts:
#	tests/dom-test-list.txt
…/inbox-replybox-shell

# Conflicts:
#	tests/inbox-size-ceilings.json
@backnotprop
backnotprop marked this pull request as ready for review November 26, 2026 07:00
@backnotprop
backnotprop merged commit 1a31af1 into main Nov 26, 2026
53 checks passed
backnotprop added a commit that referenced this pull request Nov 26, 2026
Main moved the open reply box out of Thread.tsx into components/reply/ReplyBox.tsx
(#4044). The branch's change to that box goes there now: the row's paperclip is the
+ menu (compose/ReplyPlusMenu.tsx), and ReplyBox takes an onCanvas prop that Thread
passes as onOpenCanvas. replyBoxParity's ten open-box goldens hold the + in the clip's
place.

useCanvasReply stays a hook of ThreadPane, not of ReplyBox: send() reads its sketch,
and a part from the canvas opens the box while the box is closed. To keep Thread.tsx
at its size ceiling without raising it, Thread imports the hook through
thread/replyBox.ts, which re-exports it, instead of on an import line of its own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant