Commit d4f908a
Shubham Agarwal
refactor(mobile-app): anchor Metro session on the dev-server port
Identify a Metro session by the port it listens on instead of a
self-reported sessionId + heartbeat. The port is the number the QR
encodes, the device dials, and the debugger probes, and it is the only
session fact with external ground truth: the OS knows which process
holds a listening socket.
This catches a failure a heartbeat cannot. When our Metro dies and a
different project's Metro takes over the port, the recorded state still
"matches itself", so /debug-app would tail a stale log and report the
app healthy. status now returns port-taken and the skill refuses to
diagnose from it.
Liveness collapses to one probe (lsof on POSIX, netstat -ano on
Windows), replacing heartbeat freshness, ownership recheck, startup
grace, and stale-marking. portListenerPids distinguishes confirmed-empty
from unprobeable, so a host without lsof falls back to PID liveness
rather than reporting false conflicts.
Removed as redundant:
- directory locks and reclaim tokens; a port bind is already an OS-level
mutex, leaving a small start/stop lock
- heartbeat interval, stateBlocksDuplicateStart, confirmOwnedProcess,
markStaleIfNeeded
- logGeneration counters and --generation; a cursor past EOF can only
mean rotation
- the clean verb; stop plus rm is equivalent
- sessionId; runner-PID-scoped writes give the same clobber protection
The capture pipe is unchanged and still load-bearing: Metro output
exists only on its stdout, so the runner keeps owning the child and
redacting before persisting. Redaction tests are untouched.
Also fixes a handoff race introduced while reducing the runner: it
claimed a session by writing its own PID over whatever it read, so a
stale runner could adopt and clobber a newer session. It now waits until
state already names its own PID and exits otherwise.
Net -367 lines. 33/33 script tests and all repository validators pass.1 parent d969aad commit d4f908a
6 files changed
Lines changed: 650 additions & 973 deletions
File tree
- plugins/mobile-apps
- scripts
- tests
- skills
- create-mobile-app
- debug-app
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
0 commit comments