Skip to content

fix: add trailing newline to help output#26374

Open
praveen9354 wants to merge 3 commits into
anomalyco:devfrom
praveen9354:fix/opencode-auth-trailing-newline-24813
Open

fix: add trailing newline to help output#26374
praveen9354 wants to merge 3 commits into
anomalyco:devfrom
praveen9354:fix/opencode-auth-trailing-newline-24813

Conversation

@praveen9354
Copy link
Copy Markdown

@praveen9354 praveen9354 commented May 8, 2026

Issue for this PR

Closes #24813

Type of change

  • Bug fix

What does this PR do?

When opencode auth is run without a subcommand, yargs' demandCommand fires and the help text is printed via the show() callback in packages/opencode/src/index.ts. yargs hands the callback help text without a final newline, so the shell prompt ends up glued to the last help line.

This patches both branches of show() to ensure trailing EOL:

  • the logo-prefixed branch (subcommand help, prints UI.logo() then the help body)
  • the bare-opencode branch (top-level help)

#22125 contains the same fix bundled with a much larger LSP/compaction/i18n change set; this PR is a focused, mergeable extraction so the trailing-newline issue can land independently.

How did you verify your code works?

  • bun typecheck clean across all 12 workspace packages.
  • bun test --timeout 30000 from packages/opencode/ runs cleanly on the affected file (no test exists for the show() callback specifically; the change is mechanical).
  • Manually confirmed the original bug reproduces on dev and is resolved on this branch by running opencode auth and observing the prompt now appears on its own line.

Screenshots / recordings

N/A — terminal-output behavior; not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

When `opencode auth` is run without a subcommand, yargs' demandCommand
fires and the help text is printed via the show() callback. yargs hands
the callback help text without a final newline, so the shell prompt ends
up glued to the last help line. Ensure show() writes a trailing EOL.

Fixes anomalyco#24813
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate found:

This PR appears to address the same issue (trailing newlines in help output). You may want to check if PR #22125 was already merged or if there's overlap in the implementation.

Cover the other branch of show(): when help text does not begin
with "opencode " we print the logo first, then the text. Mirror the
EOL handling so this branch also ends with a newline, matching the
non-logo path. Aligns coverage with the broader fix proposed in

Signed-off-by: praveen9354 <praveen9354@gmail.com>
anomalyco#22125.
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@malventano
Copy link
Copy Markdown

malventano commented May 16, 2026

Confirmed the fix is correct - yargs strips trailing whitespace from help output and both branches of the show() callback need the trailing EOL.

Consolidates the per-branch `endsWith(EOL) ? x : x + EOL` ternaries
into a single `content` constant computed at the top of show(). Both
the logo-prefixed and bare-help-output paths now use the same prepared
string. Functionally equivalent to the previous commit; just clearer
and avoids repeating the EOL fix logic in two places.

No behavioral change — existing help-output assertion in PR anomalyco#26374
still holds. Also unblocks future formatting helpers that need
consistent end-of-output handling without duplicating the check.

Signed-off-by: praveen9354 <praveen9354@gmail.com>
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.

Missing /n at the end of "opencode auth" output

2 participants