Skip to content

An app profile writes drafts and asks HEY to send, which waits for you - #648

Merged
jeremy merged 8 commits into
mainfrom
app-writes
Nov 14, 2026
Merged

jeremy merged 8 commits into
mainfrom
app-writes

Conversation

@jeremy

@jeremy jeremy commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Context

Change

  • Under HEY_EXPERIMENTAL=app, on an app profile:
  • hey screener approve|deny <sender id or address> runs screener.decide. An address is looked up in the app's own Screener, waiting and decided, any case; nobody there is exit 2. The answer is the server's shape (a list of the decided) with meta.id_kind: "sender".
  • hey compose --draft --to --subject -m runs draft.write; hey reply <thread> --draft -m runs draft.reply (<thread> is topic_id from hey box view imbox). Both answer the draft under hey draft list's field names, say nothing has been sent, and suggest hey -P <profile> draft send <id> where HEY would send it.
  • hey draft send <id> runs message.send: it answers meta.status: "pending" with the confirmation and snapshot, says "Waiting in HEY for the person to press Send: nothing has been sent", and exits 9. Any other answer is exit 7, never read as a send.
  • compose and reply without --draft, bulk-reply send and forward are refused before anything happens (exit 1), pointing at --draft and then hey draft send.
  • Flags the door has no field for are refused, not dropped: --cc, --bcc, --attach, --message-html, --from, --no-name-tag and --thread-id on compose; --to, --cc, --bcc, --replace-recipients, --from, --attach, --message-html and --dry-run on reply; --box, --seen, --spam and more than one sender on the Screener.
  • The door's write refusals say what to do: not_an_address, not_saved, not_a_sender, disabled and an id it does not hold (with the ids it would take); saved_not_listed and session_ended are worded as "may have been done", never as refused.
  • hey help exit-codes lists 9 under the gate only.
  • On every profile: hey screener approve|deny also take a sender's email address, looked up among the clearances waiting and then those decided (help, docs/cli.md and the skill say so).
  • Where this follows A profile whose endpoint is the HEY app answers the reads from it #646 over the routing design (routing-design.md, 11-11): the switch is the profile's endpoint: app under HEY_EXPERIMENTAL=app, not --local/HEY_LOCAL under HEY_EXPERIMENTAL=local; envelopes name meta.endpoint: "app", not meta.transport: "local"; the Screener's ids are named by meta.id_kind: "sender", not a contact_id/clearance_id field; the refusal points at --draft in the app's words, not "local mode"; a breadcrumb names -P <profile> where hey local: ask the HEY app on this computer to act for you #640's named --socket.

Verification

  • internal/cmd/app_writes_test.go (21 tests) and four in screener_test.go, against A profile whose endpoint is the HEY app answers the reads from it #646's fake door and a server that fails the test if reached.
  • Each behaviour red first against A profile whose endpoint is the HEY app answers the reads from it #646's head (cfd5879), 18 of 21 new app tests and all 4 server ones; the 3 flag-refusal tests already held there, since A profile whose endpoint is the HEY app answers the reads from it #646 refuses every write, and stay as guards.
  • TestAppWritesNeverReachHEYsServer sets HEY_TOKEN, so a fall-through would reach the server, and runs every verb above, answered and refused by the app; shown red by removing draft send's app branch (2 requests reached the server).
  • make check green; .surface unchanged; GOOS=darwin, windows, linux build.
  • A fresh review in its own context: no High; two Mediums and four Lows. Fixed in the second commit, each red first: an id the app doesn't hold is exit 2 (was 1); a capped address lookup is exit 7, not "not found"; a send cut off by the session's end says nothing has been sent without you; a disabled send with no arg hints the draft. Declined: the Markdown and --ids-only points below. A second review of those fixes found one Medium and one Low in them (the draft named on every send refusal; the cap read from the cursor), fixed in the third commit, each red first; a third review of that fix found no High or Medium.
  • Bot review (cubic, Copilot): 9 threads, 6 fixed (one already by 6724516), 3 declined, 1 in part, with reasons in their threads; fixes in 9154df1, five tests red first.
  • Unrun: a check against a running HEY Linux app with its door open.

Alternatives

  • Turning a send into a draft quietly on the app: rejected, the word send would mean two things.
  • Several senders per screening on the app: refused instead; the door decides one at a time, and a loop would need its own partial-failure report.
  • compose --thread-id --draft mapped to draft.reply: refused, pointing at hey reply <thread> --draft, so a reply has one route.
  • The server's address lookup reads the waiting list and, only if needed, the decided list, each up to 100 pages; an address past that is not found.
  • Breadcrumbs on a server profile keep no -P: unchanged here; only the app's carry it, since an app draft id run on a server profile could name a draft HEY would send at once.
  • -m reaches the door as written, though it is Markdown on the server: the door takes plain text, and converting through htmlutil.ToText drops every link's URL, changing the words the person is asked to send. Written as is, they read every character in HEY's window before pressing Send.
  • --ids-only on a pending send prints the confirmation id, which may be a number: kept, as it is the one id a pending answer has; exit 9 and the stderr line say it waits.
  • A pending send's envelope is ok: true with meta.status: "pending" and exit 9, not an error envelope: nothing failed, and a script tells it apart by the exit code or meta.status, never by ok alone.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 18 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/cmd/app_writes.go Resolved
Comment thread internal/cmd/app_writes.go Resolved
Comment thread skills/hey/SKILL.md Resolved
Comment thread docs/cli.md Resolved
Comment thread internal/cmd/screener.go Resolved
Comment thread internal/cmd/draft.go Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/cmd/endpoint.go">

<violation number="1" location="internal/cmd/endpoint.go:272">
P2: The synthetic `draft` argument is applied to every `message.send` refusal, so no-argument `not_offered` and `unavailable` responses bypass their specific handling. Restrict this default to the `disabled` refusal that needs the draft hint.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/cmd/endpoint.go Resolved
@jeremy
jeremy marked this pull request as ready for review November 12, 2026 19:14
@jeremy
jeremy requested a review from a team as a code owner November 12, 2026 19:14
Copilot AI balanced review requested due to automatic review settings November 12, 2026 19:14

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/cmd/screener_test.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The draft-send hint can lose the selected app profile and trigger an immediate server send without confirmation, while incomplete sender listings can yield incorrect address-lookup results.

2 open issues
What changed in this PR

Extends experimental app profiles from read-only access to screening senders, saving drafts, and requesting sends that wait for confirmation in HEY.

Changes:

  • Routes supported writes to the app while refusing immediate sends and unsupported flags.
  • Adds pending-send output and exit code 9, with actionable app refusal messages.
  • Supports Screener email-address lookup on both endpoints, with documentation and regression tests.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
skills/​hey/​SKILL.md Documents Screener email-address arguments.
internal/​output/​codes.go Defines pending-send error and exit code 9.
internal/​cmd/​screener.go Resolves addresses through paginated clearance listings.
internal/​cmd/​screener_test.go Tests server address lookup and pagination limits.
internal/​cmd/​screener_deny.go Adds address arguments and app routing.
internal/​cmd/​screener_approve.go Adds address arguments and app routing.
internal/​cmd/​root.go Exits cleanly after pending-send output.
internal/​cmd/​reply.go Routes app-profile replies to draft creation.
internal/​cmd/​help_topics.go Lists exit code 9 under the experimental gate.
internal/​cmd/​endpoint.go Enables app writes and maps write refusals.
internal/​cmd/​draft.go Routes app-profile send requests to HEY.
internal/​cmd/​compose.go Routes app-profile composition to draft creation.
internal/​cmd/​app_writes.go Implements app screening, drafts, and pending sends.
internal/​cmd/​app_writes_test.go Tests writes, refusals, output, and server isolation.
internal/​cmd/​app_reads.go Shares draft conversion between reads and writes.
internal/​cmd/​app_endpoint_test.go Updates unsupported-command coverage.
docs/​cli.md Explains screening senders by email address.
AGENTS.md Documents app send restrictions and pending behavior.

Review effort: Balanced

Comment thread internal/cmd/endpoint.go Resolved
Comment thread internal/cmd/app_writes.go Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/cmd/app_writes.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The recovery hint drops the selected -P profile, potentially listing server drafts instead of the saved app draft and misleading users into creating a duplicate.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve the selected profile in the draft recovery hint

internal/​cmd/​endpoint.go:289

When the app profile was selected with -P and the default profile uses the server, this recovery command lists the server's drafts rather than the draft the app just saved. The user can therefore conclude that the save failed and retry, creating a second app draft. Preserve the selected profile with appCommandLine("draft list") in this check-before-retry hint.

2 resolved since last review

Review effort: Balanced

@jeremy
jeremy added this pull request to stack #653 November 14, 2026 04:26
Base automatically changed from app-endpoint to main November 14, 2026 04:27
On a profile whose endpoint is the HEY app (#646), every write was
refused: an agent could read the Imbox, the Screener and the drafts, but
not screen a sender, write a draft or ask for one to go.

Now, under HEY_EXPERIMENTAL=app, on an app profile:
- hey screener approve|deny <sender id or address> runs the door's
  screener.decide; an address is looked up in the app's own Screener,
  waiting and decided, so an agent never meets the app's sender ids.
- hey compose --draft and hey reply <thread> --draft run draft.write
  and draft.reply, and answer the draft under the server's field names
  with hey -P <profile> draft send <id> as its next step.
- hey draft send <id> runs message.send, which the app holds in its
  window until the person presses Send: it answers meta.status pending,
  says "Waiting in HEY ... nothing has been sent" and exits 9, a code
  nothing else exits with; help exit-codes lists 9 under the gate only.
- compose and reply without --draft, bulk-reply send and forward are
  refused before anything happens, pointing at --draft and then hey
  draft send; flags the door has no field for are refused likewise.
- The door's write refusals (not_an_address, not_saved, not_a_sender,
  disabled, an id it does not hold) and its two answers that may have
  done something (saved_not_listed, session_ended) say what to do.

On every profile, hey screener approve|deny also take a sender's email
address, looked up among the clearances waiting, then those decided.

Verified: each behaviour red against #646's head first (18 tests; the
3 flag-refusal guards already held there, #646 refusing every write);
a test with HEY_TOKEN set and a server that fails if reached runs every
verb above, done and refused, and goes red when draft send's app branch
is removed. make check green, .surface unchanged, darwin, windows and
linux build.

Rejected: turning a send into a draft quietly on the app, which would
make send mean two things; several senders per screening on the app,
which the door decides one at a time, so a partial failure would need
its own report.
…hing went

A fresh review of the app's writes found an app profile answering a
sender or draft id the app doesn't hold with exit 1, where the same
sender by address, and the server for an id it doesn't hold, answer 2;
a send cut off by the app's session end worded as "may have been done",
which reads as sent; a disabled send with no arg hinted " takes one
of"; and a Screener address lookup stopped at its 100-page cap answering
not found, which it never searched.

Now an id refusal naming the ids the app holds is exit 2; the cut-off
send says it may be waiting in HEY and nothing has been sent without
you; the hint names the draft; and a capped lookup is exit 7, pointing
at the clearance ID.

Verified: each red first against 60d0455 (four subtests and one test),
then make check green.
… lookup

The second review found the previous commit naming the draft as the
argument of every message.send refusal without one, so an older app's
not_offered got the wrong hint and an unloaded list's unavailable became
a usage error (1) instead of the app's (7); and the address lookup's cap
check reading the cursor, which an empty last page still carries, so a
short Screener could be called past the cap.

Now the draft is named in the disabled case alone, and the cap check
reads collectPages' Truncated.

Verified: three new cases red against f7cf0cf, then make check green.
…the profile

Bot review (cubic, Copilot) found: an app answer saying it decided or
saved something other than what was asked hinted at upgrading hey, and
a non-pending answer to a send said only that it wasn't waiting, where
both may have changed something; the refusal of a verb that sends now
suggested hey draft send without -P, which on a server default profile
runs an app draft id against the server; and an address missing from a
Screener the app lists only part of answered not found, unsearched.

Now those answers say the app may have done something and send you to
HEY before running it again; the refusal names -P <profile>; and an
address missing from a partial list is exit 7, pointing at the sender
ID. The empty-page lookup test's server answers only the PATCH it
expects.

Verified: five tests red against 6724516 first, then make check green.
…e check alike

A review of 9154df1 found the hint for an address missing from a
partial Screener naming a bare hey screener list, which on a server
default profile lists clearance ids, not the app's senders; and the two
"may have done something" answers wording their check two ways.

Now the hint names -P <profile> and both say "before running it
again". Verified: make check green.
Copilot's review of 9154df1 found the saved_not_listed hint naming a
bare hey draft list, which on a server default profile lists the
server's drafts: the person concludes the save failed and writes the
draft again. Eight more hints on the app's paths named a command the
same way, some of them listing server ids that the next command would
then act on at the server.

Now every hint on the app's paths goes through appCommandLine, so each
names -P <profile>; TestAppHintsNameTheProfile holds it for seven of
them.

Verified: red against ddc0175 (the saved_not_listed case and six of
seven hints), then make check green.
CI's Race Detection, which runs the suite shuffled, failed on
TestAFailedAnswerNamesTheProfile (seed 1794515981961670522): an app
profile run before it left answeringEndpoint set, so withProfileMeta
added meta it expected not to. A second seed, 1794520381712021194,
failed TestAccountOverrideNotice the same way through a leftover cfg.

Now the root-flag reset every CLI test uses restores the endpoint and
the config after each run, and both tests set what they assume.

Verified: both seeds red on thelio before, green after, with four more
shuffled runs green.
A dev build was reported answering hey box view imbox with
meta.endpoint server under an app profile. Run hermetically, the built
binary answers from the app (exit 6 with no door, meta.endpoint app)
with the gate, and refuses without it; it answers server only when the
config holding the profile isn't the one hey reads (XDG_CONFIG_HOME
pointing elsewhere), where there is no app profile to choose.

This test holds the routing for the default profile, -P and
HEY_PROFILE over a server default, with and without the gate, with a
token at hand and a server that fails the test if reached. It passes
on a0f020f's code: a guard, not a fix.
@jeremy
jeremy merged commit 06baf5f into main Nov 14, 2026
24 checks passed
@jeremy
jeremy deleted the app-writes branch November 14, 2026 04:28
jeremy added a commit that referenced this pull request Nov 14, 2026
* origin/main:
  nix: add a CPE for hey-cli (#605)
  An app profile writes drafts and asks HEY to send, which waits for you (#648)
  A profile whose endpoint is the HEY app answers the reads from it (#646)
  deps: bump golang.org/x/sys from 0.49.0 to 0.50.0
  deps: bump github.com/spf13/pflag from 1.0.10 to 1.1.0 (#635)
  deps: bump github.com/itchyny/gojq from 0.12.19 to 0.12.20 (#637)
  deps: bump golang.org/x/sync from 0.24.0 to 0.25.0 (#638)
  deps: bump github.com/sigstore/sigstore-go from 1.3.0 to 1.4.0 (#611)
  deps: bump github.com/yuin/goldmark from 1.8.6 to 1.8.7 (#612)
  ci: bump the github-actions group across 1 directory with 7 updates
  deps: bump go.opentelemetry.io/otel/trace from 1.44.0 to 1.47.0 in the go_modules group across 1 directory (#651)
  Check smoke cleanup across switched-off calendars
  Fail smoke tests when fixture cleanup fails

# Conflicts:
#	internal/cmd/profile.go
#	internal/config/profiles.go
#	internal/config/profiles_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants