Skip to content

feat(mobile): attach photos to posts in a group room - #47361

Merged
AmoabaKelvin merged 1 commit into
mainfrom
mobile-group-room-photos
Nov 23, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
mobile-group-room-photos

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

A group room on the phone now opens as a web page, the way a chat does. That lets the room's + button pick photos, shrink them, and send them with the post.

Files Added Deleted Net
Test 0 0 0 0
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​456 $\color{#cf222e}{\Huge{\mathbf{−}}}$​296 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​160

What Changed

Before: the phone drew the group room as its own native screen. The composer had no + for photos. The photo shrink only runs inside the phone's web pages, so a native + would have failed every time with "Attach failed".

After: the room is a page route, as a chat is. The threads and tabs, the combined Items list, Manage members, the offline bar, other computers' answers and the "use " notice for mixed groups all look the same. The composer's + opens the photo library. Each photo is shrunk on the page and uploaded to the host under the group's first member's session, the same as the desktop's group composer. Each photo gets an [Image #N] in the text, and bots.groups.send carries its path, so the photo arrives with the post.

How it works:

  • Route. app/h/[hostId]/group/[groupId].tsx now mounts the page shell for /h/<host>/group/<group>. A .web sibling renders the room. mobile-web-page-routes.mjs declares the route: Back and item hops, Copy, and the three photo verbs, as a chat's.
  • Photos. The item comment's photo hook is now use-bot-draft-images.ts, shared by item comments and the room. It keeps its photos in chat's draft store. Uploads are gated on bots.group-attachments.v1, so an older host only takes text. A send takes its photos out of the draft at once, and a refused send puts them back after anything picked since.

Moving the room onto a page meant fixing what the page does differently:

  • Delete group. Alert.alert does nothing on a page, so the delete confirm is now a drawer. Home's group menu had the same silent bug (Delete group… did nothing), and it now uses the drawer too.
  • Keyboard. The page draws under the keyboard, so the room lifts its composer by the keyboard height the shell reports, as the chat dock does (useMobileSessionKeyboardLift).
  • Scrolling. The page's ScrollView reports no drags. A scroll right after a touch now counts as the reader's, so new replies no longer pull a reader back to the bottom.
  • Drafts. Each room is its own page, and its memory is gone after Back. Unsent text and photos are now saved like a chat tab's draft: one row per group, rooms as tabs, so a draft is still there when you come back.

Why

The photo shrink needs the page's canvas, so photos only work on a page. Moving the room keeps one copy of its code. The alternatives were sending photos without shrinking them (large phone photos fail the host's limits) or leaving photos out. Kelvin picked this option on 2026-11-23.

Pattern followed: the chat route's shell-mount and .web split (mobile/app/h/[hostId]/automations.tsx:10 and accounts.web.tsx:4); item comment photos (MobileBotItemCommentBox.tsx:185); the chat dock's keyboard lift (use-mobile-session-keyboard-lift.ts:8); a drawer instead of an alert (ConfirmModal, as MobileBotSettingsTab.tsx:180 does).

Linked Issue

None. This comes from the phone parity work (group posts with photos).

Visual Proof

Page harness: the real page bundle in Chromium, with a shell double for the phone, 393×852 at 2x. "Before" is main's room code on the same harness. On main the room is a native screen made of the same components.

Composer: + for photos (before / after)

Photo attached, then sent: the photo arrives with the post

Keyboard open (300 pt keyboard drawn in grey; before / after)

Home › group long-press › Delete group… (before: the menu closes and nothing happens; after: the confirm drawer)

In the room: Delete group…, and a draft with a photo still there after the page reloads

Testing

  • Page harness (real bundle in Chromium, shell double with this route's grants), dark and light:

    • The room, its menu, New thread, Items, Manage members, and a mixed group with other computers' answers all render.
      • picks a photo, uploads it to agentSessionAttachment.* under member session m-0, and bots.groups.send carries images: [path].
    • Delete in the room and from Home sends bots.groups.delete.
    • A draft with a photo comes back after a page reload (device store double).
    • Touch-scrolling up and then posting keeps the scroll position (scrollTop 341 → 341). Main's room code snaps to the bottom (340 → 1080).
  • build-mobile-web-app-bundle and verify-mobile-web-app-bundle pass: 11,366,495 of 11,436,032 eager bytes, 92 chunks.

  • pnpm check:changed passes, and so do mobile typecheck and oxlint.

  • Not run on a device: this Mac has no iOS simulator runtime installed. The native route file follows automations.tsx and accounts.tsx exactly.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

No tests added. The behaviour lives in page rendering and the shell, and was checked in the page harness above.

Performance

None measurable. The room's code was already in the page bundle, since every route file is bundled. The page grows by about 7.6 KiB of eager code. Draft saves reuse chat's debounced row writes, one row per group.

Risk

Level: Medium

  • Older desktops. A phone with this build opens a group on an older desktop, whose page bundle doesn't list this route. It sees the "update Orca on your computer" screen instead of the old native room. Every page route behaves this way (mobile-web-page-routes.mjs header; feat(mobile): draw the host Accounts screen from the desktop's page #30020 retired native fallbacks). Groups only shipped in v1.4.265, and desktops update quickly.
  • Older phones. Older phones keep their native room and see no change.
  • Back out with a plain revert. Saved group drafts stay in the device store as rows that nothing reads.

AI Disclosure

Review

Two review rounds (Codex and Claude). Fixed: drafts lost after Back, photo state around a send, one draft row per group, and reader scroll on the page. Not changed: the native fallback for older desktops. That is the page-route policy above, and the move was approved.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Mobile only. No host or RPC changes: the phone already had bots.groups.send with images and the attachment upload methods.
  • Cross-platform: the keyboard lift follows the chat dock on iOS and Android.
  • Remote/SSH: not affected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The group-room route now uses a mobile web shell and retains direct screen rendering on web. Group-room drafts are scoped by host, group, and room. The room and item-comment composers use shared image-draft handling, including upload, send, and refused-send behavior. Group deletion uses a confirmation component. Web transcript scrolling now reports distance from the tail and recent reader interaction.

Merge Risk: Low · up to ba7ac

Photo attachments in group rooms and item comments have a few edge cases: markers can point at the wrong photo after a refused send or a saved draft, and item comment images can mix across hosts when item IDs collide. These are small and fixable; address them before or soon after merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(mobile): attach photos to posts in a group room" matches the main change. The PR moves the mobile group room to a page route so the composer's + button can pick and shrink photos, and …
Description check Passed The description follows the repository template closely. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream bounda…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(mobile): attach photos to posts in a group room" matches the main change. The PR moves the mobile group room to a page route so the composer's + button can pick and shrink photos, and uploads them with the group post. The title is specific and concise, follows the conventional-commit style, and names the platform and feature.

Full details: Description check

Explanation

The description follows the repository template closely. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It explains the before and after behavior, the mechanism, the alternatives considered, and the rollback path. The Linked Issue section says 'None' and gives a reason rather than an issue link, and the Level field under Risk is filled as Medium. The AI Disclosure section is empty, which the template permits for internal contributors. The template asks for a linked issue for outside contributors, so the missing issue link is the main gap.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f2001720-cccc-458e-a550-935110130907
Commits

Reviewing files that changed from the base of the PR and between eec5df0 and d9816c2.

Files selected for processing: 15

  • config/scripts/build/mobile-web-app/mobile-web-page-routes.mjs
  • mobile/app/h/[hostId]/group/[groupId].tsx
  • mobile/app/h/[hostId]/group/[groupId].web.tsx
  • mobile/src/bots/MobileBotGroupDeleteConfirm.tsx
  • mobile/src/bots/MobileBotGroupRoom.tsx
  • mobile/src/bots/MobileBotGroupTranscript.tsx
  • mobile/src/bots/items/MobileBotItemCommentBox.tsx
  • mobile/src/bots/items/use-bot-item-comment-images.ts
  • mobile/src/bots/mobile-bot-group-delete.ts
  • mobile/src/bots/use-bot-draft-images.ts
  • mobile/src/bots/use-mobile-bot-group-composer.tsx
  • mobile/src/bots/use-mobile-bot-group-draft.ts
  • mobile/src/bots/use-mobile-bot-group-editor.tsx
  • mobile/src/session/native-chat/composer/drafts/mobile-native-chat-draft-store.ts
  • mobile/src/session/native-chat/transcript/viewport/use-mobile-native-chat-tail-follow.ts
Files with no reviewable changes: 2

  • mobile/src/bots/items/use-bot-item-comment-images.ts
  • mobile/src/bots/mobile-bot-group-delete.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +190 to +191
returnRefused: (sent: readonly BotDraftImage[]) =>
change(draftKey, (current) => [...current, ...sent])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Remap restored [Image #N] markers when photos were picked during the send.

A photo picked while a send is in flight can take [Image #1] in the composer. If that send is refused, the room appends the refused text after it, so the restored text keeps the old [Image #1] for photo A. returnRefused then places A after B, which gives the image order [B, A]. The restored text now has two [Image #1] markers, and [Image #1] resolves to B. A's caption refers to the wrong photo.

Restore the text and the images in the same final order. Each restored marker must match its image's position in the restored list. For this case, A's marker must become [Image #2]. When no photo was picked after A, keep [Image #1]. Apply the remap on the refusal path in MobileBotGroupRoom.tsx where the text is restored, and keep returnRefused in use-bot-draft-images.ts consistent with it.

skillOrigin: text === '' ? undefined : drafts.get(scope)?.skillOrigin,
images: inputs.images.flatMap(({ path }) => (sending.has(path) ? [] : [{ path }])),
// A photo still uploading (no path yet) is saved once it lands.
images: inputs.images.flatMap(({ path }) => (!path || sending.has(path) ? [] : [{ path }])),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Quick win

Remap saved draft text to the photos that are saved.

saved() keeps the text's [Image #N] markers unchanged, but it saves only the photos that have a path and are not already in a send. A photo still uploading has a marker in the text but no saved image. After restore, the remaining markers point at the wrong photos, and a marker can point at a missing one. Remap the text from all current photo ids to the saved photo ids before it is stored.

Suggested fix

--- "a/mobile/src/session/native-chat/composer/drafts/mobile-native-chat-draft-store.ts"
+++ "b/mobile/src/session/native-chat/composer/drafts/mobile-native-chat-draft-store.ts"
@@ -260,14 +260,19 @@
       const sending = new Set(
         inFlight.flatMap((send) => [...send.images, ...send.files]).map((chip) => chip.path)
       )
       const inputs = readMobileNativeChatDraftInputs(scope)
-      const text = userText(scope)
+      const kept = inputs.images.filter(({ path }) => path && !sending.has(path))
+      const text = queuedEditTextForKeptImages(
+        userText(scope),
+        inputs.images.map(({ id }) => id),
+        kept.map(({ id }) => id)
+      )
       const draft: MobileNativeChatSavedDraft = {
         text,
         skills: text === '' ? [] : inputs.skills,
         skillOrigin: text === '' ? undefined : drafts.get(scope)?.skillOrigin,
-        // A photo still uploading (no path yet) is saved once it lands.
-        images: inputs.images.flatMap(({ path }) => (!path || sending.has(path) ? [] : [{ path }])),
+        // A photo still uploading (no path yet) is saved once it lands; its marker is dropped now.
+        images: kept.flatMap(({ path }) => (path ? [{ path }] : [])),
         files: savedMobileNativeChatFiles(inputs.files).filter((file) => !sending.has(file.path)),
         inFlight,
         queued: savedMobileNativeChatOfflineSends(scope, inFlight)

@AmoabaKelvin
AmoabaKelvin force-pushed the mobile-group-room-photos branch from d9816c2 to ba7ac11 Compare November 23, 2026 10:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7ca9265-2bc7-471e-ba71-7845f2090109
Commits

Reviewing files that changed from the base of the PR and between d9816c2 and ba7ac11.

Files selected for processing: 2

  • mobile/src/bots/items/MobileBotItemCommentBox.tsx
  • mobile/src/session/native-chat/transcript/viewport/use-mobile-native-chat-tail-follow.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

const photos = useBotDraftImages({
client,
uid,
draftKey: uid,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Quick win

Key image drafts by host as well as item UID.

The image draft key at line 196 uses only uid. The text draft at line 110 uses botItemCommentDraftKey(hostId, item.uid), because two hosts can hold items with the same ID. If two hosts have items with the same UID, an image attached on one host can appear in the other host's comment box. Sending then includes a path from the other host's session.

Use the same host-qualified key for the image draft:

Suggested fix

--- "a/mobile/src/bots/items/MobileBotItemCommentBox.tsx"
+++ "b/mobile/src/bots/items/MobileBotItemCommentBox.tsx"
@@ -191,10 +191,10 @@
       focusMobileNativeChatTextDestination(scope)
       run()
     })
   const photos = useBotDraftImages({
     client,
-    draftKey: uid,
+    draftKey: botItemCommentDraftKey(hostId, uid),
     sessionId: attachTo,
     editText: (change) => (shownDrafts.get(key) ?? setText)(change(drafts.get(key) ?? '')),
     showToast
   })
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
draftKey: uid,
draftKey: botItemCommentDraftKey(hostId, uid),

@AmoabaKelvin
AmoabaKelvin merged commit 2d68746 into main Nov 23, 2026
58 checks passed
radut added a commit to radut/orca that referenced this pull request Nov 23, 2026
Upstream's group room page (stablyai#47361) and item comment box pass the attach button's old
onAttachImage prop; renamed to onAttachImages. Tests upstream removed (stablyai#46786) stay removed.
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