feat(cli): suppress newsletter prompt in non-interactive sessions#4258
Open
eyalb181 wants to merge 1 commit into
Open
feat(cli): suppress newsletter prompt in non-interactive sessions#4258eyalb181 wants to merge 1 commit into
eyalb181 wants to merge 1 commit into
Conversation
9a5691d to
d1dba82
Compare
The newsletter prompt is meant for humans who can act on it (clicking through to subscribe). Surfacing it to an automated caller — a CI pipeline, an AI coding agent like Claude Code or Cursor, or any stdout-captured invocation — has two failure modes: 1. The prompt is noise in the agent's tool output, eating context tokens and potentially confusing the model (e.g. interpreting ">> mirrord newsletter" as an instruction to run that command). 2. The persisted session counter ticks once per run regardless of who's running. An agent doing trial-and-error workflows can blow through every prompt threshold (5, 20, 100) in a single session — meaning when a human user later sits down at the same machine, the prompts they'd otherwise see have already fired and been missed. Add an `interactive_session` module with a heuristic that returns false for: - `MIRRORD_PROGRESS_MODE=json` or `=off` (output being parsed) - Stderr not connected to a TTY (output piped/captured) - Well-known CI / agent env vars set: CI, GITHUB_ACTIONS, CIRCLECI, GITLAB_CI, BUILDKITE, JENKINS_URL, TRAVIS, TF_BUILD, CLAUDECODE, CURSOR_AGENT, AIDER_CHAT When the heuristic returns false, `suggest_newsletter_signup` returns early without bumping `session_count`, preserving the human user's prompt cadence. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d1dba82 to
8a44ce6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Suppresses the in-CLI newsletter prompt in non-interactive sessions (CI, AI agent runners, piped output). The session counter is not bumped either, so automated runs don't push human users past prompt thresholds before a human ever sees one.
Detected via
MIRRORD_PROGRESS_MODE, stderr TTY status, and well-known CI / agent env vars (CI, GITHUB_ACTIONS, CIRCLECI, GITLAB_CI, BUILDKITE, JENKINS_URL, TRAVIS, TF_BUILD, CLAUDECODE, CURSOR_AGENT, AIDER_CHAT).Validation
Tested end-to-end against the staging cluster from a Claude Code agent session (
CLAUDECODE=1, stderr piped). Withsession_countprimed near a prompt threshold:session_countsession_countTest plan
mirrord exec→ prompt fires when threshold reachedCI=true mirrord exec→ no prompt, no counter bumpmirrord exec | cat→ no prompt🤖 Generated with Claude Code