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.
Python ai-agentsai-automationclaudeclaude-codeebbinghausknowledge-graphllmmemory-systemobsidianpersonal-assistantpkmproductivitypythonsecond-braintelegram-botvoice-assistant
feat(parse): is_idle() — turn-completion signal independent of bypass footer
smixsd73459f021d8
diff --git a/src/d_brain/services/tmux_parse.py b/src/d_brain/services/tmux_parse.pyindex e41d833..d2fccee 100644--- a/src/d_brain/services/tmux_parse.py+++ b/src/d_brain/services/tmux_parse.py@@ -114,12 +114,33 @@ _LOGGED_OUT_RE = re.compile(_FOOTER_RE = re.compile(r"bypass permissions on")_IDLE_RE = re.compile(r"(?m)^\s*❯")_STARTING_RE = re.compile(r"Claude Code v\d", re.I)+# Active-turn marker. The TUI shows "(esc to interrupt)" next to its spinner+# for the whole turn, so its absence + an idle ❯ is the idle signal. The+# bypass footer is ALWAYS on screen under --dangerously-skip-permissions and+# must never be used as an idle signal by itself.+_WORKING_RE = re.compile(r"esc to interrupt")def _chrome(text: str) -> str:return "\n".join(text.splitlines()[-_CHROME_LINES:])+def is_idle(text: str) -> bool:+ """True iff the session sits at an idle input prompt (no active turn).++ Unlike READY in classify_state (anchored on the always-present bypass+ footer), this checks the chrome for an idle ``❯`` AND the absence of the+ working spinner — usable as a turn-completion signal for prompts that+ produce no marker pair.+ """+ if not text.strip():+ return False+ chrome = _chrome(text)+ if _WORKING_RE.search(chrome):+ return False+ return bool(_IDLE_RE.search(chrome))++def classify_state(text: str) -> PaneState:"""Classify the pane into a coarse state.diff --git a/tests/test_tmux_parse.py b/tests/test_tmux_parse.pyindex 0563e09..a137f5c 100644--- a/tests/test_tmux_parse.py+++ b/tests/test_tmux_parse.py@@ -303,3 +303,40 @@ def test_extract_reply_works_for_skill_invocation_turn():)assert is_complete(pane, rid)assert extract_reply(pane, rid) == "Заметка сохранена: thoughts/ideas/autograph.md"+++# ── is_idle (turn-completion signal independent of the bypass footer) ──────++_FOOTER = (+ "────────────────────\n❯\n────────────────────\n"+ " hello | Opus 4.8 (1M context) | ~/p\n"+ " ⏵⏵ bypass permissions on (shift+tab to cycle)\n"+)+_WORKING = " ✻ Working… (esc to interrupt)\n"+++def test_is_idle_true_on_empty_input_prompt():+ from d_brain.services.tmux_parse import is_idle++ assert is_idle("transcript above\n" + _FOOTER)+++def test_is_idle_false_while_working():+ from d_brain.services.tmux_parse import is_idle++ assert not is_idle("transcript\n" + _WORKING + _FOOTER)+++def test_is_idle_false_when_footer_present_but_thinking():+ """The bypass footer is ALWAYS on screen under --dangerously-skip-+ permissions, so it must never be treated as an idle signal by itself."""+ from d_brain.services.tmux_parse import is_idle++ pane = "long transcript\n" + _WORKING + " ⏵⏵ bypass permissions on (shift+tab to cycle)\n"+ assert not is_idle(pane)+++def test_is_idle_false_on_empty_pane():+ from d_brain.services.tmux_parse import is_idle++ assert not is_idle("")