Skip to content

fix(agents): surface agent shortcut windows on mobile#585

Merged
jaylfc merged 1 commit into
devfrom
fix/mobile-agent-shortcuts
Jun 4, 2026
Merged

fix(agents): surface agent shortcut windows on mobile#585
jaylfc merged 1 commit into
devfrom
fix/mobile-agent-shortcuts

Conversation

@jaylfc
Copy link
Copy Markdown
Owner

@jaylfc jaylfc commented Jun 4, 2026

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) calls openWindow(...) but never sets activeWindowId. On mobile, App.tsx only 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 a taos:activate-window event; App.tsx listens and calls setActiveWindowId(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 build clean; 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.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Warning

Review limit reached

@jaylfc, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 48dee912-5423-4343-bbe6-b8d8a4cecfa8

📥 Commits

Reviewing files that changed from the base of the PR and between 683b80a and 26408cd.

📒 Files selected for processing (2)
  • desktop/src/App.tsx
  • desktop/src/apps/AgentsApp.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mobile-agent-shortcuts

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread desktop/src/App.tsx
// 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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

Comment thread desktop/src/App.tsx
const wid = (e as CustomEvent<{ windowId?: string }>).detail?.windowId;
if (wid) setActiveWindowId(wid);
};
window.addEventListener("taos:activate-window", handler);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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(() => {
  // ...
}, []);

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented Jun 4, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
desktop/src/App.tsx 162 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.

SUGGESTION

File Line Issue
desktop/src/App.tsx 165 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(() => {
  // ...
}, []);
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
None
Files Reviewed (2 files)
  • desktop/src/App.tsx - 2 issues
  • desktop/src/apps/AgentsApp.tsx - 0 issues

Reviewed by nemotron-3-super-120b-a12b-20230311:free · 466,546 tokens

@jaylfc jaylfc merged commit 7762678 into dev Jun 4, 2026
7 checks passed
@jaylfc jaylfc deleted the fix/mobile-agent-shortcuts branch June 4, 2026 22:17
@github-project-automation github-project-automation Bot moved this from Todo to Done in TinyAgentOS Roadmap Jun 4, 2026
jaylfc added a commit that referenced this pull request Jun 4, 2026
…ting (#589)

Replace the blind CustomEvent cast with a runtime check that windowId is a
string, and add the stable setActiveWindowId to the effect deps. Addresses the
kilo nits on #585 (no behaviour change — the cast was already guarded).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant