Skip to content

CF-3: answer an agent's questions from the iPhone, through the Mac's broker - #373

Merged
BunsDev merged 1 commit into
mainfrom
cf3-phone-answers
Oct 22, 2026
Merged

BunsDev merged 1 commit into
mainfrom
cf3-phone-answers

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Part of #276 (CF-3), tracker #273; coordinated with #279 (CF-6). Slice 1: answering questions from the phone. Slices 2 and 3 are docs, in #369.

Mac (apps/desktop)

Who gets a card

A phone that names question in x-modex-item-kinds (the header paired desktops already send) gets the question card from phoneItem:

  • the questions, blocking;
  • once it closes, answers, answeredBy, delivery or withdrawn.

Answers pass through publicAnswers again, so a secret is always "(hidden)". Phones that name nothing, such as Companion 0.3.0 (8), keep the text notice and cannot answer.

The answer endpoint

POST /v1/threads/:id/answer-question { itemId, answers } calls the runner's answerQuestion with by: "phone". That is the same broker and the same refusals as the desktop:

Case Response
Malformed body 400, reaches nothing
invalid 400 with the runner's text ("Token needs an answer.")
already-resolved, withdrawn, unknown, wrong-identity, changed-action 409 with reason and the desktop card's sentence
No question broker 501

/answer still never answers a question.

Secrets

Secrets are never logged, echoed or saved. index.ts wires answerQuestion behind the same restart/draft-recovery guards as answer. Paired desktops already reach thread:answer-question through the host. mobile-commands.ts only discovers slash commands, so it needed no change.

iPhone (apps/ios)

  • Requests. Every request sends X-Modex-Item-Kinds.
  • The card. A native QuestionCard:
    • option rows with Other;
    • text fields;
    • a secure field for a secret;
    • VoiceOver labels and selected state.
  • Sending. Nothing is sent until every question is answered. What is missing is shown on the card, not as a connection alert. A secret is sent exactly as typed.
  • Closed cards say how they closed, in the desktop card's words.
  • Unsent answers live only in memory, by thread and card. They are dropped when the card closes, when the thread goes away, or when the Mac is forgotten or replaced.
  • TestFlight. The upload is Val's. Until then, phones keep the notice.

Tests (red first)

Area Before After
New desktop tests 6 failed pass
QuestionCardTests (iPhone) did not compile 9 pass
  • companion.test.ts: card vs notice by header, secret hidden, runner call with by: "phone", 400/409 mapping per reason, malformed bodies, 501.
  • request-journal.test.ts, with a real runner, Codex fixture, journal and paired phone:
    • desktop vs phone on one question, each order: one accepted, the loser already-resolved (409 for the phone), Codex hears one answer, the journal and the phone name the winner;
    • a phone-answered secret is absent from every file under MODEX_HOME, emitted events, journal rows, the phone's view and captured stdout/stderr/console;
    • after Stop, a phone answer is a 409 withdrawn.
  • iPhone QuestionCardTests: decode and closed states, answers sent (secret whitespace, Other), the refusal on the card, a 409 that rereads and drops the closed draft, drafts across threads and on disconnect, nothing in UserDefaults, the kinds header.
  • iPhone UI (CompanionFlowTests), against the real companion and runner fixture: an incomplete answer refused on the card, choose an option, type a secret in the secure field. The agent reports the secret matched exactly, and the card reads "Answered on your phone" with "(hidden)". The fixture logs card ids only.

Local results on 16e94c9 (main 0e674e7)

Command Result
pnpm build, pnpm typecheck pass
pnpm test (first run) 1 failure: the claude-lifecycle timeout below
pnpm test (rerun) exit 0: desktop 1,811 passed, 16 skipped; other stages 117 + 16 + 21 + 10 + 16 passed
pnpm test:e2e exit 0: desktop 388 passed, 6 skipped (25.7 min); site 7 passed
iPhone unit (iPhone 18 Pro simulator, iOS 27.0) 56 passed
Scripts/test-e2e.sh 43 UI tests, 0 failures; the paired flow passed in 160 s

The first pnpm test failure. claude-lifecycle's "an unconfirmed stop keeps the worktree…" hit its 6 s limit while the iPhone build or e2e shared the machine. It passed alone (25/25) and in the rerun. The test creates real worktrees and does not involve the companion.

Not done here:

Waiting for Val's go-ahead before merging.

🤖 Generated with Claude Code

…(CF-3)

The companion now carries native question cards to a phone that names the `question` item kind in
`x-modex-item-kinds`, the header paired desktops already send, and takes the phone's answers through
`POST /v1/threads/:id/answer-question`. That calls the runner's `answerQuestion` with `by: "phone"`, so
the phone gets the same refusals as the desktop: `invalid` is a 400 with the runner's text, every other
refusal a 409 with its reason, and the CLI hears one answer when the desktop and the phone race.
Answers may hold a secret: the companion never logs them or echoes them, and a card's answers go
through `publicAnswers` again on the way out. Phones that name no kinds keep the text notice.

The iPhone app draws the card natively: option rows with Other, text fields, and a secure field for a
secret. Nothing is sent until every question is answered, and what is missing is said on the card.
Unsent answers live only in memory, by thread and card, and are dropped when the card closes, its
thread goes away, or the Mac is forgotten.

Tests first: companion routing and refusals, desktop/phone races on a real Codex question in both
orders, a phone-answered secret kept out of files, events, the journal, the phone view and logs, Stop
withdrawing the card, iPhone model tests, and the paired simulator flow answering a question.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 22, 2026 8:26pm UTC

Request Review

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main 0e674e7 cf3-phone-answers 16e94c9 +/-
65% 65% 0%
View coverage of the 3 most impacted files.
File main 0e674e7 cf3-phone-answers 16e94c9 +/-
apps/desktop/sr...ckends/codex.ts 97% 97% 0%
apps/desktop/sr...ngine/runner.ts 98% 98% 0%
apps/desktop/sr...ne/companion.ts 97% 98% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

This branch was successfully deployed

1 active deployment
Preview — 16e94c96 Deployed Oct 22, 2026 by vercel[bot]
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