Skip to content

fix(composer): normalize NBSP so an idle claude composer is not read as pending - #27

Merged
Bre77 merged 1 commit into
mainfrom
fm/fm-afk-inject-wedge-investigate
Jul 22, 2026
Merged

Bre77 merged 1 commit into
mainfrom
fm/fm-afk-inject-wedge-investigate

Conversation

@Bre77

@Bre77 Bre77 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Intent

Away-mode escalations kept wedging on the primary claude-on-herdr pane even while it was confirmed genuinely idle (2026-07-16/17, 07-20 for ~9h, 07-21 for ~2h) - a different shape from the earlier ghost-text wedges, since pane_is_busy was false throughout, ruling out the "defers mid-turn" explanation.

Reproduced live in an isolated Herdr lab session (never the live default session): a freshly launched, genuinely idle claude --dangerously-skip-permissions pane (herdr 0.7.4, claude 2.1.217). Reading the exact bytes fm_backend_herdr_composer_state itself reads showed the composer row is the bare ❯ prompt glyph followed by a NON-BREAKING SPACE (U+00A0), with no ANSI styling at all - a different root cause from the two already-fixed ghost-text incidents. fm_composer_classify_content's trim and glyph-strip logic uses bash's [:space:] class, which does not match U+00A0, so the trailing NBSP survived every trim and the row read pending forever, even though housekeeping's batch-flush/max-defer retries were already re-probing on a bounded cadence the whole time.

Fix: fm_composer_classify_content (bin/fm-composer-lib.sh) normalizes a literal U+00A0 to a plain space before its trim/glyph-strip logic runs. This is the single shared owner every adapter delegates to (tmux, herdr, orca, cmux), so no per-adapter change was needed, and real typed text (including an incidental interior NBSP) still reads pending.

Also checked, not reproduced: the brief for this investigation named a claim that escalate_flush fails to clear state/.subsuper-escalations on success, causing duplicate re-injection. Reading the current code shows it already truncates the buffer and clears the wedge marker unconditionally on every successful inject_msg, through the one function every call site uses - left unchanged.

Also noted, not fixed (separate, pre-existing, out of scope): a bare dead-shell prompt glyph followed by a plain trailing space ("$ ", not just the exact "$") already misread as empty before this change too, via the same late glyph-strip fallback. Documented in docs/herdr-backend.md for a follow-up fix.

What changed

  • bin/fm-composer-lib.sh: fm_composer_classify_content normalizes NBSP to a plain space before trimming/glyph-stripping.
  • docs/herdr-backend.md: incident writeup with the live repro evidence, root cause, and the two checked-but-not-reproduced/not-fixed items above.
  • Tests: tests/fm-composer-lib.test.sh (byte-exact NBSP cases at the shared-owner level), tests/fm-backend-herdr.test.sh (the real captured row shape through the herdr adapter).

Testing

  • bin/fm-lint.sh (pinned ShellCheck 0.11.0): clean.
  • Live verification against the isolated Herdr lab pane: fm_backend_herdr_composer_state returned pending before the fix and empty after, against the real pane's real bytes.
  • Full tests/*.test.sh suite (83 files, including real tmux/herdr e2e): run three times, standalone and via fm-fork-deliver.sh's gate. Every affected file (fm-composer-lib, fm-composer-ghost, fm-backend-herdr, fm-daemon, fm-backend-orca, fm-backend-cmux, fm-afk-inject-e2e, fm-afk-inject-herdr-e2e) is green every run. The full-suite runs each surfaced one different, unrelated flake (fm-afk-launch.test.sh's launcher-signal test - reproduces identically on unmodified origin/main; and, on separate runs, an OpenCode-plugin test and a herdr-workspace-per-home e2e test, both green again in isolation immediately after) - sandbox resource-contention timing under 175 real e2e scripts back-to-back, not a regression from this change. This PR's own gate run scopes --check to the affected suite above plus lint for a deterministic pass.

…as pending

Away-mode injection wedged for hours on a genuinely idle primary
claude-on-herdr pane (2026-07-16 through 07-21), a different shape from the
earlier ghost-text wedges since pane_is_busy was confirmed false throughout.

Reproduced live in an isolated Herdr lab session: the idle composer's own
row is a bare prompt glyph followed by a NON-BREAKING SPACE (U+00A0), with
no ANSI styling at all. fm_composer_classify_content's trim/glyph-strip
logic uses bash's [:space:] class, which does not match U+00A0, so the
byte survived every trim and the row read pending forever even though the
daemon's retry loop was already re-probing on a bounded cadence.

Normalize a literal U+00A0 to a plain space before that logic runs, in the
one shared classifier every adapter (tmux, herdr, orca, cmux) delegates to.

Also checked, not reproduced: a claimed escalate_flush buffer-clear bug -
the current code already clears the buffer unconditionally on success.
Also noted, not fixed: a separate pre-existing gap where a bare dead-shell
prompt plus a plain trailing space already misread as empty, documented in
docs/herdr-backend.md for a follow-up.
@Bre77
Bre77 merged commit e9bdf10 into main Jul 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant