Skip to content

fix: print the token path with ~, and colour errors by stderr - #175

Merged
drakulavich merged 3 commits into
mainfrom
fix/tty-paths
Oct 25, 2026
Merged

drakulavich merged 3 commits into
mainfrom
fix/tty-paths

Conversation

@drakulavich

Copy link
Copy Markdown
Owner

Closes #146, closes #150.

What

Why

Both reproduced on main:

  • Without a token, sync printed No Oura access token at /Users/<name>/.oura-token. while doctor printed ~/.oura-token.
  • script -q /dev/null bash -c 'oura-cli sync 2>err.log' (stdout a pty, stderr a file) left ^[[31merror: …^[[39m in err.log. After the fix the file holds plain text, and a pty on both streams is still red.

How checked

🤖 Generated with Claude Code

https://claude.ai/code/session_018qh9xqviBHYmzVtmQWSKqA

drakulavich and others added 2 commits October 25, 2026 14:12
doctor shortened the path with homePath (#130); the client's TOKEN_MISSING
and multi-line TOKEN_INVALID messages printed it in full. README's error
table now shows the short form.

Closes #146

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qh9xqviBHYmzVtmQWSKqA
apply-color-mode decides chalk's level from stdout, so with stdout on a
terminal and stderr redirected the error envelope carried ANSI codes into
the file. formatError now asks shouldDisableColor about stderr, the stream
it writes to, as the hint wrap already measures stderr's width.

Closes #150

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qh9xqviBHYmzVtmQWSKqA
@drakulavich

Copy link
Copy Markdown
Owner Author

Codex review (gpt-6-luna, final, ebcf1cc..122d2c7):

Reviewed origin/main...HEAD across the six files in scope. The token messages use the existing display-only homePath helper, and JSON errors return before applying color. No Required or Optional findings.

The two touched test files passed: 53 tests, 0 failures. git diff --check was clean. The pre-existing assets/demo.gif working-tree change was left untouched.

Simplification: not needed

Verdict: Approve

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with one non-blocking test gap from the previous review.

Findings

  1. P2 Stderr choice stays untested ▶

Summary

The PR shortens home-directory token paths in errors and prevents colour codes in redirected stderr.

  • Token errors shorten home-folder paths to ~.
  • Text errors color their heading based on stderr.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/lib/errors.test.ts
Comment on lines +123 to +124
expect(formatError(new CliError('BAD_ARGS', 'boom'), 'table', undefined, false).text).toBe('error: boom');
expect(formatError(new CliError('BAD_ARGS', 'boom'), 'table', undefined, true).text).toBe('\u001b[31merror: boom\u001b[39m');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Stderr choice stays untested

Both calls pass colour explicitly, so neither checks the stderr-based default that fixes #150. Changing process.stderr.isTTY back to process.stdout.isTTY would leave this test passing. Add a test with different stdout and stderr TTY states, and omit the fourth argument.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@drakulavich
drakulavich merged commit 2adfe29 into main Oct 25, 2026
2 checks passed
@drakulavich
drakulavich deleted the fix/tty-paths branch October 25, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant