Skip to content

Hook command breaks when the statusLine command is wrapped (--hook appended outside bash -c quotes) #623

Closed

Description

@herman925

syncWidgetHooks and the install flow build the hook command as `${statusCommand} --hook` (dist 2.2.30, lines 63815 and 73334). If the statusLine command is a wrapper such as bash -c 'head -1 | ccstatusline', the result is bash -c 'head -1 | ccstatusline' --hook. bash takes --hook as $0, so ccstatusline never receives the flag.

Effect

On UserPromptSubmit, ccstatusline runs in render mode and prints the full statusline. Claude Code adds UserPromptSubmit stdout to the model context, so the model sees a statusline on every turn. The hook payload has no context_window, so the Context widget falls back to DEFAULT_CONTEXT_WINDOW_SIZE = 200000. On 1M-context models the model reads, for example, "272k/200k (100%)" and believes its context is full. Each prompt also triggers an extra usage lookup, and the usage widgets showed [Rate limited].

Repro

  1. Set statusLine to bash -c 'head -1 | ccstatusline' and enable the Skills widget, so ccstatusline installs its hooks.
  2. Run:
    echo '{"hook_event_name":"UserPromptSubmit","session_id":"x","prompt":"hi"}' | bash -c 'head -1 | ccstatusline' --hook
    
    It prints a statusline.
  3. With the flag inside the quotes (bash -c 'head -1 | ccstatusline --hook') it prints nothing, as intended.

Suggested fix

Build the hook command independently of the statusLine string (for example, resolve the ccstatusline invocation itself), or detect a bash -c '…' wrapper and insert --hook inside it. A defensive option: make render mode print nothing when the stdin JSON carries hook_event_name.

Note: a manual fix to settings.json is overwritten the next time syncWidgetHooks runs, because it strips and re-adds the managed hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions