Skip to content

Show "Fork from here" button on the mobile chat#4413

Merged
kevin-dp merged 1 commit into
mainfrom
kevin/fork-at-message-mobile
Jun 2, 2026
Merged

Show "Fork from here" button on the mobile chat#4413
kevin-dp merged 1 commit into
mainfrom
kevin/fork-at-message-mobile

Conversation

@kevin-dp
Copy link
Copy Markdown
Contributor

@kevin-dp kevin-dp commented May 26, 2026

Follow-up to #4410: extends the per-message "Fork from here" affordance to the mobile chat (and any other surface that mounts agents-server-ui via an Expo "use dom" embed).

What changes

Two source files, both in packages/agents-server-ui:

  1. src/components/views/ChatView.tsxChatLogView (the view the mobile embed mounts under view='chat-log') now computes the same forkFromHereByInboxKey map that ChatView already had on the web side. It pulls db from useEntityTimeline, forkEntity from useElectricAgents, walks visibleRows to find the latest preceding completed runs row's pointer, and threads the per-row callback to EntityTimeline. Without this, UserMessage rendered in the mobile embed never received an onForkFromHere prop and the button stayed off the DOM regardless of CSS.

  2. src/components/UserMessage.module.css — adds a touch-targeted reveal rule scoped via :global(html[data-electric-mobile-dom='true']) .forkButton { opacity: 1 }. Touch devices don't fire :hover, and .bubble:focus-within only kicks in after a tap, so without the override the button stayed invisible until interaction. The reveal lives inside the CSS module (rather than a sibling stylesheet that targets the hashed class by substring) so whichever pipeline is in play — Vite for the web/desktop bundles, Metro for the Expo DOM embed — hashes .forkButton consistently with the JSX.

The mobile package itself doesn't change. The embed already mounts ChatViewEntityTimelineUserMessage, the fork POST already routes through serverFetch() running in the embed's JS context, and post-fork navigation already routes through onRequestOpenEntityopenSession(target). Once ChatLogView produces the callback map and CSS makes the button visible, the whole flow lights up.

Why split from #4410

#4410 was framed as the web/desktop release. The mobile surface depends on the same wiring but ships separately so the web work can land without being held by mobile-specific UX polish. Once both merge, the affordance is uniform across web, desktop, and mobile.

Test plan

  • Build + run Fork at message: re-roll a session from an earlier point in its history #4410's base. Start the mobile app with pnpm -C packages/agents-mobile ios.
  • Open any session with at least two completed runs.
  • The second user-message bubble shows the GitFork icon at full opacity, top-right corner of the bubble.
  • Tap it. The app navigates to a new entity URL ending in -fork-<hash>; the new session contains only the first exchange.
  • Send a new prompt in the fork; it runs independently.
  • First user message in a chat shows no button. While Horton is streaming a reply, the triggering message shows no button. Button returns after ✓ done.
  • On desktop and web, hover-reveal still works as before (the mobile rule is scoped via the data-electric-mobile-dom attribute the embed sets).

🤖 Generated with Claude Code

@kevin-dp kevin-dp changed the title Surface Fork from here in the mobile DOM embed Show "Fork from here" button on the mobile chat May 26, 2026
@kevin-dp kevin-dp force-pushed the kevin/fork-at-message-mobile branch from 5a459e3 to 56c6823 Compare May 26, 2026 13:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Electric Agents Desktop Builds

Build artifacts for commit b30d2c9.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Passed Installer
Linux x64 Passed AppImage / deb

Workflow run

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.47%. Comparing base (0be3760) to head (5e2d693).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...agents-server-ui/src/components/views/ChatView.tsx 0.00% 19 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0be3760) and HEAD (5e2d693). Click for more details.

HEAD has 24 uploads less than BASE
Flag BASE (0be3760) HEAD (5e2d693)
unit-tests 10 2
packages/y-electric 1 0
typescript 10 2
packages/start 1 0
packages/agents-mcp 1 0
packages/electric-ax 1 0
packages/agents 1 0
packages/react-hooks 1 0
packages/experimental 1 0
packages/typescript-client 1 0
Additional details and impacted files
@@                    Coverage Diff                     @@
##           kevin/fork-at-message    #4413       +/-   ##
==========================================================
- Coverage                  47.36%   35.47%   -11.90%     
==========================================================
  Files                        253      184       -69     
  Lines                      19797    13822     -5975     
  Branches                    6230     4674     -1556     
==========================================================
- Hits                        9377     4903     -4474     
+ Misses                     10401     8904     -1497     
+ Partials                      19       15        -4     
Flag Coverage Δ
packages/agents ?
packages/agents-mcp ?
packages/agents-server 73.49% <ø> (ø)
packages/agents-server-ui 6.16% <0.00%> (-0.02%) ⬇️
packages/electric-ax ?
packages/experimental ?
packages/react-hooks ?
packages/start ?
packages/typescript-client ?
packages/y-electric ?
typescript 35.47% <0.00%> (-11.90%) ⬇️
unit-tests 35.47% <0.00%> (-11.90%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kevin-dp kevin-dp marked this pull request as ready for review May 26, 2026 13:26
Copy link
Copy Markdown
Contributor

@msfstef msfstef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably have smaller comments

@kevin-dp kevin-dp force-pushed the kevin/fork-at-message branch from f8313f9 to 0be3760 Compare May 27, 2026 06:45
@kevin-dp kevin-dp force-pushed the kevin/fork-at-message-mobile branch 2 times, most recently from 1e0c3f1 to 5e2d693 Compare May 27, 2026 06:53
@kevin-dp kevin-dp force-pushed the kevin/fork-at-message branch 3 times, most recently from 5997c95 to 2085be1 Compare June 2, 2026 09:14
Base automatically changed from kevin/fork-at-message to main June 2, 2026 13:00
Two pieces:

1. `ChatLogView` (the view the mobile DOM embed mounts under
   `view='chat-log'`) now computes the same `forkFromHereByInboxKey`
   map that `ChatView` has on the web. Without this the embed's
   `EntityTimeline` received no per-row callbacks and `UserMessage`
   stayed without the button regardless of any CSS.
2. `UserMessage.module.css` gains a scoped reveal —
   `:global(html[data-electric-mobile-dom='true']) .forkButton { opacity: 1 }`
   — so the button is visible by default on touch (the web's
   `.bubble:hover` rule never fires there). Placing the rule inside
   the CSS module (rather than in a sibling stylesheet that targets
   the hashed class by substring) means whichever bundler is in play
   — Vite for the web/desktop bundles, Metro for the Expo DOM embed —
   hashes `.forkButton` consistently with the JSX.

The mobile package itself doesn't change. The embed already mounts
`ChatView` → `EntityTimeline` → `UserMessage`, the fork POST already
routes through `serverFetch()` in the embed's JS context, and
post-fork navigation already routes through `onRequestOpenEntity` →
`openSession(target)`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kevin-dp kevin-dp force-pushed the kevin/fork-at-message-mobile branch from 5e2d693 to b30d2c9 Compare June 2, 2026 13:05
@kevin-dp kevin-dp merged commit 4e2cc22 into main Jun 2, 2026
16 checks passed
@kevin-dp kevin-dp deleted the kevin/fork-at-message-mobile branch June 2, 2026 13:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Electric Agents Mobile Build

Android preview build for commit b30d2c9.

Platform Profile Status Build
Android preview Passed EAS build

Workflow run

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.

2 participants