Skip to content

Grok: parse the composer so hcom term --json reports prompt_empty - #162

Closed
signet-bot-claude wants to merge 1 commit into
aannoo:mainfrom
signet-bot-claude:upstream-pr/grok-composer-prompt-empty
Closed

signet-bot-claude wants to merge 1 commit into
aannoo:mainfrom
signet-bot-claude:upstream-pr/grok-composer-prompt-empty

Conversation

@signet-bot-claude

Copy link
Copy Markdown
Contributor

Problem

hcom term <grok-agent> --json reports prompt_empty: false and input_text: null even when Grok's prompt is empty, because there is no Grok composer parser (get_input_box_text returns None for Grok). Scripts that wait for an empty prompt before typing into an agent therefore never act on Grok agents.

hcom's own Grok delivery goes through the ACP prompt queue and never reads the composer, so delivery is not affected. Only the terminal JSON and the debug prompt glyph change.

How it was observed

hcom 0.7.30 on macOS (arm64), Grok Build (Grok 4.6) at 18x127. A listening Grok agent with unread mail sat at an empty ❯ prompt, yet hcom term --json said prompt_empty: false, so a wake script gated on it never typed.

Fix

ScreenTracker::get_grok_input_text parses Grok's composer: a rounded box over a one-line footer, with the model and approval mode in the bottom border.

 ╭──────────────────────────────────────────────────────────╮
 │ ❯ <user text>                                            │
 ╰──────────────────────── Grok 4.6 (high) · always-approve ─╯
 Ctrl+.:shortcuts
  • The parser is anchored to the bottom of the screen: the bottom border ╰ must sit within the last four rows (counting up from the last non-blank row), and the top border ╭ within 12 rows above it. Boxes in the transcript are never read as the composer.
  • An empty composer is a bare ❯. Grok shows no placeholder, idle or mid-turn.
  • Wrapped input adds │ … │ rows, which are joined with newlines.
  • If the box's first row has no ❯ (a menu or approval in its place), the result is None, which is not empty.

debug_prompt_glyph gains the Grok glyph. The integration_spec comment for Grok is updated to say the composer is parsed for hcom term --json, though gates still do not read it.

Tests

The fixtures are real hcom term --json captures of an idle and a busy Grok screen (18x127). Transcript text is anonymized; the composer and footer rows are as Grok drew them.

  • grok_idle_empty_composer_is_empty_and_ready: the idle capture parses to "", is_prompt_empty and is_ready hold, and the screen dump reports ready, prompt_empty and input_text: "".
  • grok_composer_stays_empty_mid_turn: spinner, subagent panel and transcript above an empty composer.
  • grok_extracts_typed_and_wrapped_drafts
  • grok_without_a_composer_is_not_empty: an approval menu below an old composer-like box.

Results

Local run on this branch (on main 669a067), macOS arm64, rustc 1.99.0 (the repo pins 1.97.1), cargo test --bin hcom with the test names as filters. cargo fmt --check is clean. Clippy and the full suite were not run on this branch.

  • With the fix: all 4 tests pass.
  • With the Grok arm of get_input_box_text back to None, grok_idle_empty_composer_is_empty_and_ready and grok_composer_stays_empty_mid_turn fail. The parser-level draft test and the not-empty test still pass, as expected.

Related

I did not find a matching existing issue in the checked issues, pull requests and discussions. #110 is a merged Codex placeholder-parsing fix. #114 is historical Antigravity composer/banner context; the maintainer reported that newer Antigravity changed its TUI banner and tested successfully on 1.2.11. Neither establishes this PR's failure or fix.

🤖 Generated with Claude Code

Grok had no composer parser, so `hcom term --json` said prompt_empty=false
and input_text=null at an empty prompt, and scripts that wait for an empty
prompt before waking an agent never typed. hcom's own Grok delivery goes
through the ACP prompt queue and never reads the composer, so only the
terminal JSON (and the debug prompt glyph) change.

Parse the boxed `❯` composer, anchored to the bottom of the screen so boxes
in the transcript are never read as the composer. An empty composer is a
bare `❯`; wrapped input adds `│ … │` rows; a menu or approval in its place is
None (not empty).

Tests: real captures of an idle and a busy Grok screen (transcript text
anonymized, composer rows as drawn) read as empty and the idle one reports
ready/prompt_empty/input_text in the dump; typed and wrapped drafts are
extracted; a menu below an old composer-like box is not empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c9a804a-0280-4442-9d0a-2747d433f894
📥 Commits

Reviewing files that changed from the base of the PR and between 669a067 and 1279ee5.

📒 Files selected for processing: 4
  • src/integration_spec.rs
  • src/pty/fixtures/grok_busy_composer.json
  • src/pty/fixtures/grok_idle_composer.json
  • src/pty/screen.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Grok terminal input parsing now extracts composer text, including wrapped drafts. Fixture-based tests cover idle, busy, and missing-composer screens.

Changes: Grok composer parsing

Layer / File(s) Summary
Recognize and parse the Grok composer
src/pty/screen.rs, src/pty/fixtures/grok_*_composer.json, src/integration_spec.rs
Grok prompt recognition and input-text dispatch now use Grok-specific composer parsing. Tests cover empty composers, single-line and wrapped drafts, and missing composers. The integration comment states that hcom term --json parses the composer.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: kiala9

Merge Risk: ⚪ Minimal · up to 1279e

This change lets hcom term --json report an empty prompt for Grok sessions. It does not touch Grok message delivery. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 78.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the Grok composer parsing problem, the implementation, and the related tests. It directly matches the changeset.
Title check Passed The title clearly and concisely identifies the main change: parsing the Grok composer so terminal JSON reports prompt_empty.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 78.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Adds Grok composer parsing so hcom term --json reports empty prompts and visible draft text.

  • Grok's composer now reports empty prompts and typed drafts in terminal JSON.

No actionable issues were found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "Grok: parse the composer so `hcom term -..." · Reviewed by Greptile

aannoo added a commit that referenced this pull request Oct 20, 2026
`hcom term --json` reported `prompt_empty: false` for tools with no
composer parser (Grok, OpenCode, Kilo, Pi, Omp, Hermes) and whenever a
parser found no composer. Scripts read that as "the user has typed
something" and never acted. `prompt_empty` now follows `input_text`:
true/false when the composer was read, null when it was not. The
delivery gate still treats an unread composer as unsafe.

Refs #162
@aannoo

aannoo commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Grok reports null now instead of false it doesn't need a parser
https://github.com/aannoo/hcom/releases/tag/v0.7.31
d98e9d7

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.

2 participants