Repository navigation
Built a tool so Happy sessions stop answering with http://localhost:5173 #1826
LonglongLab
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The problem, if you have not hit it yet
Happy put Claude Code on my phone. It did not put my dev server there. Every session ends the same way: "your app is running — open http://localhost:5173". On the phone that address is the phone.
The same wall shows up three more times: screenshots (it cannot see the screen, I cannot show it), credentials (the only channel is the chat box, which is the transcript), and decisions (three options written out as a wall of text I have to answer by typing on a 390 px screen).
So I built mp. MIT, a CLI plus a plugin for Claude Code and Codex: https://github.com/2440893398/mobile-preview
Four commands, all token-gated and short-lived
mp start --port 5173— temporary cloudflared tunnel, 32-byte token in the URL, a link that opens on the phone. Add--devfor a Vite/Webpack server.mp capture --port 5173— a phone-sized screenshot the agent itself reads, with failed requests and console errors folded in.mp secret ask— a form on the phone for a password or API key. No command ever prints the value; the agent runsmp secret run -- npm run deployand gets output with the value redacted.mp interaction ask— a real HTML page for a decision (compare, order, review a draft) instead of a wall of text in a chat bubble.The Happy-specific part, which was the hard part
A skill only fires when the model thinks of it, and it thinks of it from the words the user typed. Nobody on a phone types "use the preview plugin" — they type "send me the link" or "看看效果". So the trigger has to be won in the skill description, and, for when the user does not ask at all, in a
SessionStarthook that says up front: this person is not at this machine, a local address is not a deliverable.Detecting a Happy session was the interesting bit:
CLAUDE_CODE_EXECPATHpointing inside Happy's npm package, anyHAPPY_*variable, orCLAUDE_CODE_ENTRYPOINT=remote_mobile.NO_PROXYandPATH, which makes every local terminal session look remote. That one cost me an afternoon.codex app-serverwith a plain inherited environment, andoriginator: happy-codexlands in the rollout file 8 to 25 seconds in, far too late for a hook. So there the hook walks the process tree, where the happy CLI is always an ancestor.What it cannot do
mp startretries four times and names the cloudflared log when it gives up. The measurements are in the README.Security posture, since this does put a local app on the public internet: 32-byte token, every auth failure returns 404 rather than 403,
/@fs/and.envand.git/blocked in every mode, the session cookie stripped before requests reach your app, and the daemon self-terminates at its TTL. Collected secrets are encrypted in the browser, held in one daemon's memory, and the protocol has no read operation at all.Not affiliated with Happy — just built on top of it.
npm i -g mobile-preview-cli. If it breaks for you, issues are welcome.All reactions