fix(agents): surface agent shortcut windows on mobile#585
Conversation
Tapping a container-terminal / TUI / dashboard shortcut did nothing on mobile: handleShortcutLaunch called openWindow() but never set activeWindowId, and the mobile shell only renders a window when it is the active window (desktop renders all windows regardless). Dispatch a 'taos:activate-window' event with the new window id on mobile; App.tsx listens and sets it active. No-op on desktop.
|
Warning Review limit reached
More reviews will be available in 23 minutes and 49 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
| // id; on desktop the window manager already renders it, so this just focuses. | ||
| useEffect(() => { | ||
| const handler = (e: Event) => { | ||
| const wid = (e as CustomEvent<{ windowId?: string }>).detail?.windowId; |
There was a problem hiding this comment.
WARNING: Unsafe type assertion
The code assumes e is a CustomEvent<{ windowId?: string }> without validation. If the event has a different structure, this could cause runtime errors when accessing .detail?.windowId.
Consider adding a validation check:
if (!(e instanceof CustomEvent) || !('detail' in e)) return;
const wid = e.detail.windowId;
Or use a safer type guard:
| const wid = (e as CustomEvent<{ windowId?: string }>).detail?.windowId; | ||
| if (wid) setActiveWindowId(wid); | ||
| }; | ||
| window.addEventListener("taos:activate-window", handler); |
There was a problem hiding this comment.
SUGGESTION: Add dependency to useEffect
Although setActiveWindowId is stable and safe to omit, explicitly including it in the dependency array improves code clarity and follows exhaustive-deps rule:
useEffect(() => {
// ...
}, [setActiveWindowId]); // or comment why it's omitted
Alternatively, add a comment explaining why it's safe to omit:
// setActiveWindowId is stable (state setter from useState)
useEffect(() => {
// ...
}, []);
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
The code assumes Consider adding a validation check: Or use a safer type guard. SUGGESTION
Although Alternatively, add a comment explaining why it's safe to omit: Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (2 files)
Reviewed by nemotron-3-super-120b-a12b-20230311:free · 466,546 tokens |
The agent shortcut buttons (container-terminal / TUI / dashboard) below an agent's name rendered and the tap fired, but nothing appeared on mobile.
Root cause
handleShortcutLaunch(AgentsApp.tsx) callsopenWindow(...)but never setsactiveWindowId. On mobile,App.tsxonly renders a window (MobileAppWindow) when it's the active window; desktop renders all windows via the window manager regardless — which is why it worked on desktop but not mobile. The launch POST succeeded; the window just never surfaced.Fix
After
openWindow()returns the new window id, on mobile dispatch ataos:activate-windowevent;App.tsxlistens and callssetActiveWindowId(wid). Applied to both shortcut paths (browser dashboard + terminal/TUI). No-op on desktop (the manager already renders it; this just focuses).Verification
npm run buildclean; existing AgentsApp desktop + mobile vitest suites pass (25). The window-surfacing itself is best confirmed live on a phone — flagged for the Pi test pass.