Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(pane): skip the stats banner in a pane child

Jack Rudenko7a210bffcf89
diff --git a/packages/cli/src/stats.test.ts b/packages/cli/src/stats.test.ts
index 903492b3..659ef846 100644
--- a/packages/cli/src/stats.test.ts
+++ b/packages/cli/src/stats.test.ts
@@ -81,6 +81,22 @@ describe("stats module — showMonthlyBanner", () => {
expect(stderrOutput).toContain("claudish");
});
+ it("does not show the first-run banner in a pane child, and leaves it due for a terminal run", async () => {
+ const cfg = { version: "1.0.0", defaultProfile: "default", profiles: {} };
+ writeFileSync(CONFIG_FILE, JSON.stringify(cfg), "utf-8");
+ const { showMonthlyBanner } = await import("./stats.js");
+
+ // the claudish a create_session / team pane launcher started (pane-launch.ts env)
+ showMonthlyBanner({ CLAUDISH_PANE_CHILD: "1", CLAUDISH_PANE_CWD: "/tmp" });
+ expect(stderrOutput).toBe("");
+ const after = JSON.parse(require("node:fs").readFileSync(CONFIG_FILE, "utf-8"));
+ expect(after.stats?.lastMonthlyPrompt).toBeUndefined();
+
+ // a person at a terminal still sees it
+ showMonthlyBanner({});
+ expect(stderrOutput).toContain("Help improve claudish");
+ });
+
it("does not show banner when CLAUDISH_STATS=0", async () => {
process.env.CLAUDISH_STATS = "0";
stderrOutput = "";
diff --git a/packages/cli/src/stats.ts b/packages/cli/src/stats.ts
index 0244d871..2e4ed3bd 100644
--- a/packages/cli/src/stats.ts
+++ b/packages/cli/src/stats.ts
@@ -15,6 +15,7 @@
* Env var override: CLAUDISH_STATS=0|false|off disables all collection.
*/
+import { isPaneChild } from "./pane/child-env.js";
import { loadConfig, saveConfig } from "./profile-config.js";
import { parseModelSpec } from "./providers/model-parser.js";
import {
@@ -321,10 +322,15 @@ export async function flushStats(): Promise<void> {
* - First run (never prompted): opt-in nudge
* - Monthly — enabled: thank-you
* - Monthly — disabled: re-engagement nudge
+ *
+ * Never in a pane child (`isPaneChild`): its stderr is the headless pane's screen, which
+ * no person reads, and the boot classifier fails the session on the banner as a
+ * `first_run_dialog`. `lastMonthlyPrompt` stays unset, so the next run at a terminal
+ * still shows it.
*/
-export function showMonthlyBanner(): void {
+export function showMonthlyBanner(env: Record<string, string | undefined> = process.env): void {
try {
- if (isStatsDisabledByEnv()) return;
+ if (isStatsDisabledByEnv() || isPaneChild(env)) return;
const profileConfig = loadConfig();
const consent = profileConfig.stats;