Repository navigation
fix(mobile): mute stale agent status and disable Stop while disconnected (STA-3333) - #12496
brennanb2025 wants to merge 12 commits into
Conversation
The working row kept animating "Agent is working" and Stop stayed live after the transport dropped, so pre-disconnect status read as live activity and a Stop tap could not reach the PTY. Derive staleness from the debounced composer lock so connection blips don't flicker the row. Refs STA-3333.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds shared native-chat stop availability checks. The mobile controller exposes transport liveness and Stop-target writability. The mobile chat view delays disconnected status for 600 ms, passes stale state to the working indicator, and disables the Stop control when stopping is unavailable. The working indicator hides dots, stops animations, and displays “Agent status stale” while stale. Tests cover these behaviors and recovery transitions. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
…bel readable Two defects in the first cut of this fix, both found in review. The composer lock latches on the first non-null reason and never unlatches between reasons, so once a lease wait had held its 600ms, a later drop to 'disconnected' flipped the row instantly with no hold at all. Reconnect always lands on 'waiting' first — the lease clears its ready handles on disconnect — so a flapping link strobed the label, tore down and rebuilt the dot animation, and toggled Stop at flap rate. Staleness now runs its own 600ms hold on 'disconnected'; `lockReason` and the composer are untouched, and recovery stays immediate. Dimming the row to 0.55 opacity dropped the label from 5.62:1 to 2.53:1 against bgBase, under AA and even under the large-text floor, on the one element left carrying the state once the dots go. The existing 0.55 uses are all inactive controls, which WCAG exempts; informational text is not. The label swap and the removed dots already read as "not live", so the dim is gone. Also drops a vacuous assertion: `onStop` was asserted un-called without any press being attempted, under a Pressable mocked as a bare host string, so it passed with the guard deleted. Refs STA-3333.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/session/MobileAgentWorkingIndicator.test.ts (1)
1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftDo not extend deprecated
react-test-renderercoverage.React 19 deprecates
react-test-renderer. The new suite suppresses its warning, and the new chat-view cases extend the same test path. Port these additions to the repository’s React Native Testing Library setup if it exists.
mobile/src/session/MobileAgentWorkingIndicator.test.ts#L1-L3: replace the new deprecated renderer import.mobile/src/session/MobileAgentWorkingIndicator.test.ts#L25-L34: remove warning suppression after migration.mobile/src/session/MobileAgentWorkingIndicator.test.ts#L50-L58: render through the supported test utility.mobile/src/session/MobileNativeChatView.test.ts#L168-L268: move the new stale-status cases to the supported test utility.Based on library documentation, React 19 deprecates
react-test-rendererand recommends React Testing Library.#!/usr/bin/env sh set -eu # Verify whether React Native Testing Library is already configured and locate # all current React Test Renderer usage before selecting the migration scope. git grep -n -I -C 2 \ -e 'react-test-renderer' \ -e '`@testing-library/react-native`' \ -- package.json ':(glob)**/package.json' || true git grep -n -I -C 2 \ -e 'react-test-renderer' \ -e '`@testing-library/react-native`' \ -- \ ':(glob)**/*.test.ts' \ ':(glob)**/*.test.tsx' \ ':(glob)**/*.spec.ts' \ ':(glob)**/*.spec.tsx' || true
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2b52c68e-55ed-475e-a01c-cc8c4cbf2b5b
📒 Files selected for processing (5)
mobile/src/session/MobileAgentWorkingIndicator.test.tsmobile/src/session/MobileAgentWorkingIndicator.tsxmobile/src/session/MobileNativeChatView.test.tsmobile/src/session/MobileNativeChatView.tsxmobile/src/session/mobile-native-chat-view-styles.ts
… path The row rewrites itself from "Agent is working" to "Agent status stale" with no live region, so screen-reader users got no cue for the exact state this change exists to communicate (WCAG 2.1 SC 4.1.3). Matches the send-error banner's existing pattern in this view. Also covers the anti-flicker guarantee itself: a link that recovers inside the 600ms hold must cancel the armed timer, not merely lose the race with it.
Deleting the prop, or the plausible-looking `stale ? 'polite' : 'none'`, both left every case green. The contract is that the mode is constant — Android drops the announcement if it is switched on in the same commit as the content change — so it has to be asserted in both renders.
Merge current main, preserve its native-chat streaming changes, and keep Stop action safety aligned across desktop and mobile. Mobile now disables an unreachable Stop immediately while retaining the short visual hold for stale status feedback.\n\nRefs STA-3333.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Senior review follow-upFound and fixed two scoped issues after integrating current main:
The sole current-main conflict retained both the new streaming regression case and the stale-status cases. Focused tests passed (16 desktop/shared, 14 mobile), both typechecks passed, and changed-code quality, React Doctor, formatting, oxlint, and max-lines checks are clean. Pushed in 766a473 and 77092a9. |
|
Final UI QA on
The final same-model review is CLEAN, including a clean synthetic merge with current |
…-stale-agent-status # Conflicts: # mobile/src/session/MobileNativeChatView.tsx # mobile/src/session/use-mobile-native-chat-controller.ts
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
This older disconnected-chat patch can be closed as part of rebuilding phone chat on current main. Preserve the remaining work to show accurate activity and Stop availability when the connection drops. |




Summary
When the mobile transport drops, the last agent status is cached and Stop cannot reach the terminal. This PR makes that state honest:
src/shared/native-chat-action-availability.ts. Mobile supplies canonical transport liveness and the controller's exactinputSendablewrite gate instead of inferring either from the composer lock.The hold runs only on connection transitions; this adds no polling, stream-path work, or message-list re-render dependency.
Split from #12373. This is an independent, main-based PR with no Git dependency on that larger QA sweep.
Refs STA-3333.
Screenshots
Electron — live agent
Validated in the real Electron app through CDP: the working row animates and Stop is enabled while the target is writable.
iPhone — disconnected agent
Validated on the real iOS development build with Orca's emulator tooling: after the mock WebSocket is stopped, the row reads Agent status stale, the dots are absent, and AX reports Stop the agent disabled.
Testing
Final reviewed head:
95edf5950dThe focused tests cover the 600 ms hold, timer cancellation, synchronous recovery, re-disconnect hold restart, lease-wait Stop gating, animation cleanup/restart, and the real socket-loss case where composer lock state is not yet available.
Review
The same-model senior review loop was rerun after every finding until explicitly CLEAN. It also verified a clean synthetic merge with current
mainafter the adjacent STA-3332 changes landed; both features are retained.Review fixes included:
No security, dependency, IPC/RPC, platform, SSH, folder-workspace, or hot-path performance surface is added.