Skip to content

feat(threads): cite inline in the composer - #591

Merged
nixuuu merged 1 commit into
devfrom
feat/inline-citations
Nov 12, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/inline-citations

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Change

Cite now inserts an atomic citation token at the composer's saved caret, so quoted passages can sit between sentences. The floating action, desktop selection context menu and shortcut use the same insertion path. Tokens show a compact excerpt, reveal the full passage and source on hover/focus, and open an editor with a source action. They survive composer copy/paste and undo, render inline in sent user bubbles, and replace the old tray on web and mobile. Mobile uses the existing JS text badge editor without native changes and keeps the system selection menu.

The gateway stores UTF-16 ranges and expands each quote into a clearly delimited block at that position for Claude, Codex and Grok. Proto fields are additive; older clients retain their existing quote-note format. Source references are owner-scoped, and queue editing preserves or replaces citation ranges. Old saved drafts normalize to inline tokens when opened.

The collapsed composer omits the separate citation count: excerpts already appear in the first draft line. Attachment and mention counts remain. Rebased on dev at cafed16af, retaining #589's measured composer coverage and expand/collapse animations and #592/#593's PR panel changes.

Related: #587

Verification

  • Passed: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, and the web build on the isolated review host.
  • Final focused gateway integration across the stack: 12 tests pass, 122 assertions, no temp leftovers. Covers all three fake CLIs, quote order/placement and persistence, mention shifts, legacy clients, queued edits/removal, invalid ranges, cross-owner rejection and cached PR citations. Full GitHub CI is green: static checks, all four test shards and web/Linux builds.
  • Remote monolithic check:tmp: 2,540 pass, 166 opt-in skips, one existing import memory-budget failure late in the long-lived process. The unchanged 160 MB import test passed in isolation at +127 MB against its 400 MB budget (11 ms scan). The full CI shards pass it too. Both remote runs left no test temp directories.
  • Manual Chromium review: 1, 3 and 10 citations at different positions; edit, atomic deletion, undo/redo, composer copy/paste, long multiline quotes, thread and bot source navigation, sent bubbles and reload. Checked light/dark at desktop, narrow and phone widths. The desktop context menu shows Cite/Copy text, inserts the citation, and restores composer focus; Copy text was verified by pasting into the composer. Final rebased build reviewed. No web UI test suite added.
  • Final development-profile EAS fingerprints, generated with nice -n 19, match the bottom-layer baseline: iOS 86872d18eade9d3c6e0c54b0c328bccd5e5d226c, Android d67c35d4de5511168d4b7c568c1f42c5df4f293d. The iOS fingerprint JSON comparison is empty. Native project generation and both Android/iOS JS exports pass. Expo Doctor passes 19/20 checks; its only finding is newer patch versions for 13 unchanged dependencies. Native device interactions have not been reviewed.

Copy audit

  • Tray controls → Edit citation, Quoted passage, Comment (optional), Jump to source, Cancel, Save: compact sentence case, verb-led actions, and the existing citation/quote glossary distinction. Updated the glossary definition for inline tokens.
  • Icon-only excerpt → Citation: <excerpt> accessibility labels; full passage, author, source kind and time remain available without relying on color or icon shape.
  • Missing-source message → Could not find the source. Try loading earlier messages. (web) / Could not find the source. Retry to load it again. (mobile): states the failure and a recovery action.
  • Desktop native selection menu → Cite / Copy text, with the existing shortcut hint. Could not copy the text. Select it and try again. gives a recovery action; Copied confirms success.
  • Removed redundant citation counters and the separate tray. No new empty states, marketing copy, jargon, or decorative sentences. Short excerpts, typical content and long multiline text reviewed in both themes at the requested widths.

@nixuuu
nixuuu force-pushed the feat/inline-citations branch from bdbf20c to 2241880 Compare November 12, 2026 22:14
@nixuuu
nixuuu added this pull request to stack #595 November 12, 2026 22:25
@nixuuu
nixuuu force-pushed the feat/inline-citations branch 2 times, most recently from 97f3156 to c7b934f Compare November 12, 2026 22:42
@nixuuu
nixuuu force-pushed the feat/inline-citations branch from c7b934f to 43c0dfb Compare November 12, 2026 22:57
@nixuuu
nixuuu marked this pull request as ready for review November 12, 2026 23:32
@nixuuu
nixuuu merged commit 5af512d into dev Nov 12, 2026
13 checks passed
@nixuuu
nixuuu deleted the feat/inline-citations branch November 12, 2026 23:39
nixuuu added a commit that referenced this pull request Nov 12, 2026
)

## Change

Pull request comments, published and pending inline review comments,
review summaries, failed checks/jobs and displayed log excerpts now
offer **Send to agent**. The action adds a PR citation at the thread
composer's saved caret and focuses the composer, so the user can write
around it before sending. Web also offers Cite for a selected passage.
Mobile uses the existing JS text badge and editable-excerpt sheet, with
Cite in the item menu.

Tokens show a PR mark, author and excerpt. Their preview includes the
full quoted passage, repository/PR number, source URL, time and review
file/line. Sent bubbles retain the inline source. The gateway resolves
source metadata from the owner's selected account cache and current
access revision, requires the PR to remain linked to the destination
thread, and includes up to 8,000 characters of cached diff hunk context.
Sending or editing a queued message never fetches from GitHub. Proto
changes are additive.

Stacked on #591 using `gh stack`; the bottom PR targets `dev`. Both
branches were rebased onto `dev` at `cafed16af`, retaining #589's
composer coverage and motion changes plus #592/#593's PR header and
compact picker.

## Verification

- Generated contracts with `bun run gen`; changed files formatted and
linted individually on the local host.
- Added gateway → real worker → fake Claude/Codex/Grok CLI integration
coverage for text position, source metadata, bounded cached diff
context, persistence and no GitHub requests on send. Additional cases
cover failed checks/jobs/log excerpts, foreign-owner sources, missing
resources, unlinked PRs and revoked access revisions.
- Passed remotely: `bun install`, `bun run gen:check`, `bun run
typecheck`, `bun run lint`, `bun run format:check` and the web build.
Final focused gateway integration across both PRs: 12 tests pass, 122
assertions, no temp leftovers. Full GitHub CI is green: static checks,
all four test shards and web/Linux builds. One shard needed a retry
after a computer-move fixture connectivity failure; those cases also
passed in the full remote run.
- Remote monolithic `check:tmp`: 2,540 pass, 166 opt-in skips, one
existing import memory-budget failure late in the long-lived process.
The unchanged 160 MB import test passed in isolation at +127 MB against
its 400 MB budget (11 ms scan). The full CI shards pass it too. Both
remote runs left no test temp directories.
- Manual Chromium review with fixtures: failed check, failed job, log
excerpt, review summary, selected comment and inline code comment; icon
and item-menu actions; insertion between surrounding text; source
metadata; edit, atomic delete/undo; sending multiple source types in
order and inline sent bubbles. Reviewed light/dark, desktop/narrow/phone
widths with long titles and multiline quotes. The phone action closes
the PR sheet and keeps composer focus after navigation. Native device
interactions are unverified.
- Mobile changes are JS-only. Final development-profile EAS
fingerprints, generated with `nice -n 19`, match the bottom PR exactly
on both platforms: iOS `86872d18eade9d3c6e0c54b0c328bccd5e5d226c`,
Android `d67c35d4de5511168d4b7c568c1f42c5df4f293d`. The iOS fingerprint
JSON comparison is empty. Native project generation and both Android/iOS
JS exports pass. Expo Doctor passes 19/20 checks; its only finding is
newer patch versions for 13 unchanged dependencies. No native
configuration or dependency changes.

## Copy audit

- Actions: `Send to agent`, `Cite`, `Item actions`, `Open on GitHub`.
Sentence case, verb-led, shared across surfaces. Send to agent adds a
draft citation and does not submit a message.
- Citation tokens keep `Citation: <excerpt>` accessibility labels. The
preview names the repository, author, time and file/line without relying
on the icon or color.
- Recovery: `Citation source unavailable. Refresh the pull request and
add it again.` and `Quote limit reached. Remove a quote, then retry.`
Each explains the state and gives the next action.
- Reused existing edit/cancel/save copy and compact kit components. No
new empty states or marketing copy. Short, typical and worst-case
excerpts, long PR titles and multiline quotes reviewed at
desktop/narrow/phone widths in light/dark themes.
nixuuu added a commit that referenced this pull request Nov 12, 2026
)

Working sidebar threads gained a neutral fill in #545 that looks too
close to the selected thread, especially in dark mode. Remove that fill
on web and mobile: an unselected working thread now uses its spinner and
Working label, while the current thread retains the selected background
regardless of activity.

Only unselected web thread and Bots conversation rows receive the
lighter hover fill. Keyboard focus keeps its separate outline. Bots
already have no working-only fill; selected bot/group conversations now
retain their selected fill on hover. Keep the normal title/metadata
contrast from #545 and the action swaps, reduced-motion behavior,
reserved slots and gutters from #576. Update the related Polish
documentation; UI copy is unchanged.

Fixes: #545

Validation:
- Rebased onto `dev` at `968757a4c`, including #591 and #594. Reviewed
head: `070efea27b73c7fec7049b1be061c42258e7f17e`. Blame and patches
identify #545 (`1c65b9317`) as introducing the working fill on both
clients. Reviewed #549, #576 and #583; they did not introduce it.
- On the assigned review server, `bun install --frozen-lockfile`, `bun
run gen:check`, full `bun run typecheck`, `bun run lint`, `bun run
format:check` and the production web build pass after the rebase. Svelte
reports zero errors and warnings. Changed-file mobile ESLint, repository
formatting, commitlint and `git diff --check` also pass. No web UI tests
were added or run.
- A single Chromium browser reviewed the production build against a
disposable gateway/database: light/dark at 1440px desktop and 1100px
narrow widths, 288px and 220px sidebars, plus the 393px phone drawer.
Checked working-only, selected-only, selected+working, hover and
keyboard focus in Threads and Bots, including a working side thread and
short/long labels. Working-only rows are transparent; hover uses 4%,
selection uses 6% light / 8% dark, and keyboard focus retains its
separate 2px outline. Selected rows keep their fill on hover. Row bounds
remain fixed and labels do not overflow. Reduced motion gives
zero-duration action swaps. Final navigation reports no console errors.
- The mobile change only removes the `busy ? c.well` background branch
from a TSX file. Native dependencies, configuration, fingerprint
configuration, assets and lockfile are unchanged. Base/head fingerprints
generated on the assigned server with `nice -n 19`, using `expo-updates
fingerprint:generate` and the production/nightly environment, are
identical: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. This uses Expo's underlying
runtime fingerprint engine. The maintainer confirmed that this local
comparison is sufficient for the JS-only change; authenticated EAS
verification is not required. No build or OTA publication was started.
- Browser, gateway, web and disposable database are stopped. Assigned
ports are free. Verification artifacts remain outside the repository.
Ready for review; the maintainer will merge once CI is green.

Copy audit: no UI text changes; no copy audit required.
nixuuu added a commit that referenced this pull request Nov 13, 2026
nixuuu added a commit that referenced this pull request Nov 13, 2026
Cite inserts an inline citation at the saved composer caret and
immediately opens its existing editor, focused on the optional comment.
The same insertion path covers the floating action, selection menu,
keyboard shortcut and PR panel citations. Restored drafts and pasted
citations do not open the editor.

Enter saves from the comment field; Shift+Enter adds a line, and
Cmd/Ctrl+Enter also saves from the passage field. Escape, Cancel and
outside dismissal keep the citation and discard unsaved edits. Closing
returns the caret after the citation; Jump to source keeps its
navigation behavior. Saving the note does not submit the enclosing
message form.

The editor stays horizontally anchored to the new chip and clears the
whole composer text field vertically. An opt-in Popover motion follower
keeps it attached while the composer grows or moves. The existing
top-layer surface, motion tokens and reduced-motion behavior remain in
use.

Fixes: #591

The parent of `5af512dbe` opened `QuoteCommentPopover` from Cite and
saved with unmodified Enter. #591 removed that opening step when
introducing inline tokens. #594 added PR citations afterwards. Mobile
still opens `QuoteEditor` before insertion for transcript and PR
citations; it did not lose the note editor, so no native change is
needed.

## Verification

- Passed with `nice -n 19`: install, generated-code check, final-head
typecheck, lint, formatting and web build. CI is green on
`78bba15c98c8800019224c908c21bef348e2cebe`, including all four test
shards and their temporary-directory checks. The local full `check:tmp
--timeout 60000` finished with **2687 pass, 166 skip, 12 fail** across
505 files; its temporary-directory check passed. All 12 failures are in
the unchanged `tests/integration/computer-moves.test.ts` (peer
reachability/synchronization and HTTP/2 connection errors). The same
file passed completely in CI, including all 20 repeated thread-move
cases; the local cause is not established. The first default-timeout
test run hit 5-second release-script timeouts under host load; it was
stopped and its temporary directory was clean.
- Manual Chromium review: light/dark, 1440×900 desktop and 390×844 phone
widths; short (2 characters), typical (173 characters), long multiline
(~2,000 characters) and maximum (20,000 characters) passages; 1–6
citations in the same message. Verified floating Cite, Alt+Q and the
desktop selection menu; comment autofocus, Enter/Shift+Enter/Cmd+Enter,
Escape/outside dismissal, editing an existing note and the Save button
without sending the message. Outside dismissal retains the citation and
restores the composer caret after it.
- A 25-frame opening sample kept exactly 6 px between the popover and
the text field throughout the composer animation. The panel starts at
opacity 0 in its positioned location. No horizontal overflow at phone
width. Reviewed the existing reduced-motion token and CSS path; no new
animation timings.
- The requested review host already had two review environments, so
review used a private local gateway/database/BFF on non-reserved ports.
The private servers and database were removed and the browser tab
closed. Mobile transcript and PR paths were inspected in code; no native
device review or PR panel account fixture was used.
- No UI test suite added. No user-facing text changed; the copy audit is
not applicable. Documentation describes the restored note editor and
keyboard behavior.
nixuuu added a commit that referenced this pull request Nov 13, 2026
Current `dev` already renders ranged citations inline in sent and queued
mobile messages. Share the pure UTF-16 range helper between composer
spans and sent-message Markdown so both paths retain the same model, and
cover it with five regression tests. Legacy quotes without ranges keep
their block presentation until the queue editor applies
`inlineLegacyQuotes`.

The viewer already shows the full, literal note in a scrollable view.
Keep the same chip convention as web, without an additional note
indicator. No native code, dependencies, configuration or web UI
changes.

## Diagnosis and installed bundle

- The parent of #591 unconditionally rendered every quote through
`MessageQuotes` and passed only mention ranges to Markdown. Its older
protobuf schema also lacked citation ranges. That implementation matches
the reported blocks plus raw placeholders. #591 added both the mobile
range model and inline renderer; #612 retained notes in
`CitationViewer`; #628 changed the web note editor only. The inspected
current-dev rendering path and pure protobuf/range/sentinel tests do not
reproduce the reported model failure. Device rendering remains
unverified, so an older installed bundle is the supported explanation,
not a confirmed observation of the user's installation. No `Fixes`
attribution is warranted.
- The first release containing #591 is `v0.2.0-nightly.146`. Publication
is confirmed in [Mobile release
43333842969](https://github.com/itsoltech/canopy/actions/runs/43333842969):
Android OTA group `e48b25a0-804b-417e-a044-a528b9cb526e`, update
`01a1d239-0f22-7654-ad93-bbfc752d4c00`.
- The later [nightly.147
publication](https://github.com/itsoltech/canopy/actions/runs/43342358688)
is also confirmed: Android OTA group
[`1c21f61a-57a6-4dc3-ba1d-43d357c3d3ef`](https://expo.dev/accounts/itsol/projects/canopy-mobile/updates/1c21f61a-57a6-4dc3-ba1d-43d357c3d3ef),
update `01a1d274-0b11-71a1-9aa6-37106c5b9608`, commit
`31c7f87825b9756d8b1adf677f506519f248f770`. Both Android updates target
runtime `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. A compatible nightly
installation needs to run that OTA or later; a different native runtime
needs a matching build rather than that OTA. Updating desktop alone does
not update the mobile JS bundle.

Related: #591, #612, #628

## Verification

- Passed with `nice -n 19`: install, generated-code check, final-head
typecheck, lint, formatting check, web build, and the full test
inventory through the repository's four `check:tmp` shards: **2753 pass,
166 skip, zero failures**, 513 files, and no test temp leftovers. Shards
1–3 used the standard command; shard 4 passed with `--isolate
--parallel=2`.
- The default local shard 4 twice failed the unchanged startup recovery
test in `prompt-after-turn-end.test.ts` (`backgroundTasks`: expected 2,
received 1). Its entire file passed separately (6 tests), and the full
shard passed with Bun's built-in file isolation. No assertions or
gateway code were changed. The exact interference between files was not
investigated in this mobile change. [Standard GitHub
CI](https://github.com/itsoltech/canopy/actions/runs/43418493981) is
green on `2be705574aeb9b2c6d8785f59af95a81da4211e4`, including all four
default test shards, static checks and builds.
- Tests cover the reported two-note message after protobuf decoding
(including `start: 0`), citation-only and adjacent tokens, reversed
quote order, UTF-16 offsets around emoji and attachments, legacy queue
conversion, truncated labels, and full multiline notes. No UI tests
added.
- `expo-updates fingerprint:generate` before/after JSON comparisons are
empty for both platforms: iOS
`74705db3a68907bc28379bb9b1080a227bc0755b`; Android
`7d38be8f5c9bf842d62060c75820a206f99c87e3` (same local configuration and
environment).
- Device check unavailable: MacStudio returned `Device list failed:
Could not communicate with device support. Try refreshing devices.`
Refreshing once and attempting `device_open` for the requested Android
device returned the same error. No other device session was touched, no
EAS build or OTA was started, and native visual/layout behavior is
unverified.

## Copy audit

No UI copy changed. Existing `Citation`, `Copy quote` and source actions
remain unchanged; labels and notes retain their existing presentation.
The helper tests verify label truncation and unabridged notes, but do
not replace a visual check.
nixuuu added a commit that referenced this pull request Nov 25, 2026
## Change

Citation labels, icons, and focus outlines in sent bot messages now use
the bubble's text color. This makes citations readable on the light
outgoing bubble in dark mode. The citation background uses a subtle tint
of that text color.

## Verification

- Checked the bot chat component in Chromium with fixture messages. The
default dark palette improved from 1.29:1 to 10.28:1. Across all seven
palettes, the minimum was 9.25:1 in dark mode and 10.88:1 in light mode.
- Verified keyboard focus and the full citation preview, and checked
that four citations fit inside the bubble at a 390 px viewport.
- Ran scoped formatting, lint on the edited TypeScript file, and `git
diff --check`. Full verification is left to CI.

Fixes: #591
nixuuu added a commit that referenced this pull request Nov 28, 2026
Clicking a composer citation could start its focus preview during the
press or leave an already visible preview fading over the edit form. The
composer now unmounts the preview and cancels its timer when editing
begins. It restores preview handling after the edit panel closes and
returns focus. Pointer presses also cancel pending hover requests, while
keyboard focus continues to show the preview.

Fixes: #591

Verified with the shared MentionEditor in Chromium. Before the change,
frame sampling recorded both panels during the same frame. After the
change, checked clicking a visible preview, pressing before the hover
delay, holding through that delay, Enter and Space from keyboard focus,
saving a note and previewing it again, and inserting a citation while
another preview was open. A tap at a 390 px emulated touch viewport
opened only the editor. Ran formatting and lint on the edited components
and checked the diff. Full repository verification runs in CI.
nixuuu added a commit that referenced this pull request Nov 29, 2026
## Changes

- Show the user's comment directly after its citation in sent bot chat
and thread messages on web, desktop, iOS, and Android. The full quoted
passage and its source remain in the citation preview.
- Keep the comment as selectable plain text in the web message. The
existing composer preview still shows the draft comment, and the native
full-screen citation viewer retains it for context.

Thanks to @marcinniewinski for reporting this.

Fixes: #591

## Local verification

On Linux, revision `2808c1af6`: formatting and lint passed for all three
changed code files. The diff whitespace check passed.

In Chromium, reproduced the bot chat flow via Reply, Comment, Save, and
Send with a local chat fixture. Verified the sent comment before opening
the citation preview, the full passage in the preview, and the send time
below the message. Separately checked a sent thread message, including a
multiline comment, wrapping at 320 px, a citation without a comment, and
an older citation without inline ranges. In Chrome on an Android
emulator, verified the two sent-message scenarios at 320 px before any
interaction with their citations.

Copy audit (docs/copy.md §8): the previously hidden comment is visible
as the author's literal text, including line breaks, with existing
citation labels. The web citation preview omits the duplicate comment.

## GitHub CI

Pending at opening. Required CI owns repository checks and client
builds. The workflow does not exercise native iOS/Android rendering of
this change. The touch check above covers the web renderer in Android
Chrome.
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