Skip to content

feat(native): device panel first slice: setup, device list, iOS stream with touch and keys - #61

Merged
rynfar merged 2 commits into
nativefrom
nw/59-device
Nov 2, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/59-device

Conversation

@rynfar

@rynfar rynfar commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Closes #59 (first slice).

Problem

The native client had no Device panel: no way to set up the device hub, list simulators and emulators, or watch and drive one from the right panel.

Approach

Follows the server-streamed Browser tab (#53): wire types and reducers in crates/core, the stream in crates/client, views in a new crates/app/src/device/.

  • core device.rs: DeviceServiceState (EAS and Simlock hosts merged into hosts, bad entries dropped, unknown statuses decode as Unknown), the selectors of DeviceSetup.tsx, DevicePanel.tsx and DeviceHostUpdates.tsx with their copy, and the hub URLs (/api/device-hub, media wsTicket and hostId). device/stream.rs ports the iOS half of client-runtime/src/device/stream.ts (serve-sim touch/button/key/orientation framing, screen config, rawPoint, rotation cycle, HID usages, close handling) plus an MJPEG multipart parser, screenAspect, screenRotation and fitDeviceFrame. right_panel.rs gains the device surface and openDevice.
  • client device_stream.rs: mints a media ticket, reads serve-sim's MJPEG feed (the web's preferMjpeg path) and opens the HID socket once capture runs. Newest frame only through a watch, repeated stills skipped, a refused ticket re-mints at most 3 times in a row, and a refused or silent feed fails with the web's error and a Reconnect.
  • app device/: the Devices controller (subscribeDeviceState per connection, device.list when the tab shows, per-thread open and power-off operations, settings:write gating), DevicePane (warnings, host updates, booting, errors, loading view, list with Open/Start), DeviceScreen (frame decoded and rotated upright off the UI thread, left-drag touches, HID keys and Shift/Control/Option, rail with Home, Rotate and More → Close device panel / Power off device, input-disconnected bar), and DeviceSetupDialog (three-step wizard rendered from the workspace).
  • Entry points: the launcher and the add-surface menu both get "Device" (M), after Linked pull requests, like the web. The web only disables it outside a thread; the native panel always has a thread. While devices are off or not set up, the entry opens setup instead of a tab, as addDeviceSurface does. A device tab that needs setup shows the wizard over it, and dismissing it closes the tab and keeps the panel open (onDismissSetup). Done from the launcher opens the device list.
  • Ways back: Cancel or Escape leaves setup, the hub and agent switches turn back off, a device tab closes or powers its device off, errors and warnings dismiss, and a hidden tab stops its stream.
  • Right panel changes are registration only: a SurfaceKind, a launcher entry, a pane list, and a content arm. The files/ match gets the new arm, and workspace.rs mounts the dialog. Two snapshot-only labels (launcher, device:list) make the evidence below reproducible.

Ledger

PN-DEVICE → partial, Native crates/app/src/device, crates/core/src/device.rs, crates/client/src/device_stream.rs, Issue #59. Not yet: Android, Simlock and EAS video (they stream H.264 or WebRTC; Android shows the web's no-decoder error), 3D phone, Duo and fold controls, device tools, appearance, text size and screenshot, float over chat, agent-opened device tabs, tab rename and platform tab icons.

Evidence

The smoke server has the hub disabled and no simulators. Per the brief, I did not enable the hub, install anything or boot a simulator. I did not open the panel against the real-data server, because its tab probe (device.list) may start helpers there. That means I could not capture the list and stream states in a window. Tests cover them instead.

Screenshots (scratchpad):

  • Real window, a device tab with setup over it: /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/nw59/real-setup.png
  • Launcher with Device (M): /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/nw59/device-launcher.png
  • Setup from the launcher, dark and light: /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/nw59/device-setup-dark.png, /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/nw59/device-setup-light.png

Tests:

  • t3-core device::tests (12): wire decoding, readiness, platform setup copy, grouping and messages, warnings and host updates, setup statuses, payloads and hub URLs, serve-sim framing and remap, socket messages and closes, transports, frame fitting and rotation, and the MJPEG parser (byte by byte, coalesced, no length, oversize resync).
  • right_panel::tests::an_opened_device_takes_the_placeholder_tab_or_fronts_its_own (also covers dismiss keeping the panel open).
  • t3-client device_stream::tests::streams_newest_frames_and_sends_input_once_admitted and a_refused_feed_mints_new_access_then_gives_up, against an in-process fake hub (ticket, MJPEG feed, HID socket).

Probe (cargo run -p t3-client --example device_probe, smoke server, read-only):

subscribeDeviceState: revision=0 hub=Disabled ready=false busy=false onboarded=false agentAccess=false needsSetup=true
  host local (Local, This machine): status=- platforms=[ios=true, android=false]
  sessions=0 booting=0
  setup iOS: ready=true Xcode and iOS Simulator are available.
  setup Android: ready=false Android Emulator is missing from ~/Library/Android/sdk. Install it in Android Studio's SDK Manager.

Gates: cargo clippy --workspace --all-targets -- -D warnings (and with --features snapshot), cargo test --workspace (749 passed), node scripts/gen-theme.ts --check, node --test parity/sync.test.ts, node ../../apps/native/conformance/generate.ts --check, node apps/native/scripts/vendor-icons.ts --check.

@rynfar

rynfar commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Review round 1, fixed in 18646fd:

  1. Revision watermark across a server restart (fixed). Device state now lives in t3_core::device::DeviceFeed. Each subscribeDeviceState snapshot replaces the previous one in arrival order, with no revision comparison, so a resubscribed feed that starts again at 0 wins. Test: device::tests::a_restarted_server_replaces_newer_revisions_and_failures_matter_only_before_a_first_state.
  2. Late device.list/device.configure replies (fixed). Replies are no longer applied to state at all. The web ignores them too, and every change arrives through the subscription. Open and power-off completions now carry an Operations ticket and act only while it belongs to the current connection, so a late open can't open a tab in another environment. Test: device::tests::operations_from_an_earlier_connection_never_apply.
  3. Probe skipped when state arrives after the tab shows (fixed). ProbeGate mounts while the tab is visible, loaded and the hub is on, and probes each time that turns true, including when the first state lands after the tab became visible. The setup wizard uses the same gate (shown, with the hub on). Test: device::tests::the_probe_runs_each_time_it_becomes_active_including_when_state_arrives_late.
  4. Configure errors dropped (partly a false positive). The web doesn't show these to the user. useAtomCommand(deviceEnvironment.configure) reports a failure through reportAtomCommandResult, and with the default console reporter that's only console.warn. Showing new UI copy here would invent behavior the web doesn't have, so I matched the web: native now logs tracing::warn!("device.configure failed"), and the switch keeps showing the state the server holds.

Rebased on fork/native (no new commits). clippy (plain and snapshot) passes, and cargo test --workspace passes 752.

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