Skip to content

hey watch: filter by label and run a command only for that label #487

Description

@TomFaulkner

hey watch already does the right thing for agents: a long-running process, JSON lines as mail lands, --events new, --box, --run-async / --run-sync.

What is missing is a way to subscribe to a label, not a whole box.

Why

HEY labels are the natural whitelist. A contact (or a human in the TUI) applies agent-trades / agent-church; an agent should wake only then. Watching the whole Imbox and filtering after the fact still burns a wake (or a script invocation) on every new posting.

Plus-addresses (you+label@hey.com) auto-label, but many forms reject +, so label-on-contact / manual label is the reliable gate.

This is not a request for IMAP, HTTP webhooks from HEY's servers, or third-party clients. Local hey watch already exists; it just cannot select a label the way it selects --box.

Proposal

hey watch --label 789 --events new
hey watch --label 789 --events new --run-async './wake-agent.sh'
hey watch --label agent-trades --events new --run-sync ./triage.sh

Accept label id (from hey label list) and, if unambiguous, label name.

Event should fire when:

  • new mail arrives already labeled (contact auto-label, label address, or screener+autofile), or
  • an existing thread gains that label (the interesting case for "I tagged this for the agent").

--events new should still mean new-to-this-watch in the same sense as box watch (unseen / unmuted / active since the watch began), plus the label-added case above so a late tag still wakes the helper.

JSON line can stay the current added/updated shape; including label {id,name} on the event would let --run-async scripts route without a second hey label view.

Workaround today

hey watch --box imbox --events new --run-sync then hey thread read / inspect labels and no-op. Works, but every Imbox add pays the script tax, and a label applied to an already-seen thread never fires.

Happy to bikeshed flags (--label vs --in-label) if you want it consistent with hey search --label.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions