Skip to content

An always-on second brain you talk to. Voice notes in Telegram → typed, linked knowledge in your Obsidian vault. Runs 24/7 on the Claude subscription you already have.

fix(session): dismiss the periodic feedback survey instead of stalling

smixs1bc3eccb0809
diff --git a/src/d_brain/services/claude_session.py b/src/d_brain/services/claude_session.py
index 831afb2..1e2ad3e 100644
--- a/src/d_brain/services/claude_session.py
+++ b/src/d_brain/services/claude_session.py
@@ -36,6 +36,7 @@ from d_brain.services.tmux_parse import (
PaneState,
classify_state,
extract_reply,
+ has_survey_prompt,
is_complete,
is_idle,
is_working,
@@ -452,6 +453,15 @@ class ClaudeSession:
else:
idle_streak = 0
+ # The periodic "How is Claude doing?" survey pollutes the
+ # chrome and once made the stall detector interrupt a live
+ # turn. Dismiss it (0) and never count it as a stall.
+ if has_survey_prompt(cap):
+ self._tmux("send-keys", "-t", self._target, "0")
+ last_active = self._clock()
+ self._sleep(self._poll_interval)
+ continue
+
# Stall model: silence is NOT a hang signal — a quiet task
# still shows the working spinner. Stuck == no visible turn
# (and no completion) for longer than stall_timeout.
diff --git a/src/d_brain/services/tmux_parse.py b/src/d_brain/services/tmux_parse.py
index 67242b2..44c14f9 100644
--- a/src/d_brain/services/tmux_parse.py
+++ b/src/d_brain/services/tmux_parse.py
@@ -163,6 +163,19 @@ def is_working(text: str) -> bool:
return bool(_WORKING_RE.search(_chrome(text)))
+_SURVEY_RE = re.compile(r"How is Claude doing this session\?")
+
+
+def has_survey_prompt(text: str) -> bool:
+ """True iff the periodic feedback survey is on screen.
+
+ Claude Code occasionally shows "How is Claude doing this session?
+ 1: Bad 2: Fine 3: Good 0: Dismiss" — it pollutes the chrome and must be
+ dismissed (key 0), never treated as a stalled turn.
+ """
+ return bool(_SURVEY_RE.search(text))
+
+
def is_idle(text: str) -> bool:
"""True iff the session sits at an idle input prompt (no active turn).
diff --git a/tests/test_claude_session.py b/tests/test_claude_session.py
index 34b10b8..40a43b2 100644
--- a/tests/test_claude_session.py
+++ b/tests/test_claude_session.py
@@ -498,3 +498,23 @@ def test_inflight_claimed_before_session_startup(tmp_path, clock):
assert seen["at_startup"] is not None
assert seen["at_startup"].startswith("maint-process")
+
+
+def test_ask_dismisses_feedback_survey_instead_of_stalling(tmp_path, clock):
+ # Claude Code periodically shows "How is Claude doing this session?" —
+ # it polluted the chrome, the stall detector fired Escape and the user
+ # got a session error. The session must press 0 (Dismiss) and carry on.
+ survey = (
+ "● How is Claude doing this session? (optional)\n"
+ " 1: Bad 2: Fine 3: Good 0: Dismiss\n" + READY
+ )
+ fake = FakeTmux(
+ [READY, survey, THINKING, _complete("rid00001")], exists=True
+ )
+ s = make_session(tmp_path, fake, clock)
+ res = s.ask("привет")
+ assert res.status == "ok"
+ pressed = [c for c in fake.sent_keys() if c[-1] == "0"]
+ assert pressed, "survey was not dismissed with 0"
+ escapes = [c for c in fake.sent_keys() if c[-1] == "Escape"]
+ assert not escapes, "stall interrupt fired instead of dismissing survey"
diff --git a/tests/test_tmux_parse.py b/tests/test_tmux_parse.py
index e0485ec..1677b9b 100644
--- a/tests/test_tmux_parse.py
+++ b/tests/test_tmux_parse.py
@@ -378,3 +378,16 @@ def test_classify_onboarding_theme_as_logged_out():
" Syntax theme: ansi (ctrl+t to disable)\n"
)
assert classify_state(theme) == PaneState.LOGGED_OUT
+
+
+def test_survey_prompt_detected():
+ from d_brain.services.tmux_parse import has_survey_prompt
+
+ pane = (
+ "● How is Claude doing this session? (optional)\n"
+ " 1: Bad 2: Fine 3: Good 0: Dismiss\n"
+ "❯\n"
+ " ⏵⏵ bypass permissions on (shift+tab to cycle)\n"
+ )
+ assert has_survey_prompt(pane)
+ assert not has_survey_prompt("❯\n ⏵⏵ bypass permissions on\n")