Skip to content

fix(hooks): validate statusLine against schema, not truthy#209

Open
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d:fix/statusline-detection-schema
Open

fix(hooks): validate statusLine against schema, not truthy#209
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d:fix/statusline-detection-schema

Conversation

@d123d
Copy link
Copy Markdown

@d123d d123d commented Apr 17, 2026

Problem

`hooks/caveman-activate.js:118`:

```js
if (settings.statusLine) {
hasStatusline = true;
}
```

Plain truthy check. Passes on any non-falsy value — strings (`"todo"`, `"true"`), numbers, arrays, partial objects (e.g. `{"type": "command"}` with no `command`), malformed shapes.

Consequence: user edits `settings.json`, types something wrong, the statusline doesn't actually work, but the nudge is suppressed — so the user gets no feedback about why their badge is broken.

Fix

Validate against the real schema:

```js
const sl = settings && settings.statusLine;
if (sl && sl.type === 'command' && typeof sl.command === 'string' && sl.command.length > 0) {
hasStatusline = true;
}
```

  • `sl.type === 'command'` — Claude Code statusline type
  • `typeof sl.command === 'string' && sl.command.length > 0` — must have a non-empty command to actually run

Backward compat

Correctly-configured `statusLine` still passes (unchanged behavior). Malformed/partial `statusLine` now correctly triggers the setup nudge.

Verify

```
node --check hooks/caveman-activate.js
```

Passes.

Before: 'if (settings.statusLine)' accepts any truthy value — strings
like 'todo', numbers, arrays, malformed objects, partial shapes. All
of those suppress the statusline setup nudge even though no working
statusline is configured.

After: check against the real schema that settings.json expects:
  - settings.statusLine.type === 'command'
  - settings.statusLine.command is a non-empty string

Happy path unchanged (a correctly-configured statusLine still skips
the nudge). Edge cases that were silently suppressing the nudge now
correctly trigger it.

node --check passes.
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