Skip to content

fix: suppress banner in completion and redirected output#1376

Closed
Alix-007 wants to merge 3 commits intosipeed:mainfrom
Alix-007:fix/issue-1305-banner-stdout
Closed

fix: suppress banner in completion and redirected output#1376
Alix-007 wants to merge 3 commits intosipeed:mainfrom
Alix-007:fix/issue-1305-banner-stdout

Conversation

@Alix-007
Copy link
Contributor

Summary

  • suppress the startup banner for completion, __complete, and __completeNoDesc
  • skip banner output when stdout is redirected so scripted usage stays clean
  • add PICOCLAW_NO_BANNER and unit coverage for the new guard paths

Fixes #1305

Testing

  • go test ./cmd/picoclaw -run TestShouldPrintBanner

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2026

CLA assistant check
All committers have signed the CLA.

@sipeed-bot sipeed-bot bot added type: bug Something isn't working go Pull requests that update go code labels Mar 11, 2026
Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

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

PR #1376 Review: suppress banner in completion and redirected output

✅ Strengths

  1. Clean logic: Extracted banner printing condition into a standalone shouldPrintBanner() function with clear responsibilities
  2. Test coverage: Added 4 sub-tests covering main scenarios
  3. Environment variable support: PICOCLAW_NO_BANNER provides flexible user control
  4. Cross-platform: Uses golang.org/x/term for reliable terminal detection

⚠️ Issues & Suggestions

1. Incomplete environment variable value handling

func bannerDisabledByEnv() bool {
    value := strings.TrimSpace(strings.ToLower(os.Getenv(noBannerEnv)))
    switch value {
    case "", "0", "false", "no", "off":
        return false
    default:
        return true
    }
}

Issue: Tests only cover "1", but not "true", "yes", "on" which are common truthy values.

Suggestion: Either add test cases for these values, or unify the logic:

func bannerDisabledByEnv() bool {
    value := strings.TrimSpace(strings.ToLower(os.Getenv(noBannerEnv)))
    switch value {
    case "", "0", "false", "no", "off":
        return false
    case "1", "true", "yes", "on":
        return true
    default:
        return true
    }
}

2. Test cases could be more comprehensive

Suggested additions:

  • Test "true", "yes", "on" env values
  • Test empty args []string{"picoclaw"} (no subcommand)
  • Test unknown subcommand behavior

3. Minor: Constant grouping

noBannerEnv mixed with color constants feels semantically inconsistent. Consider moving it to a separate group.


📝 Summary

Category Rating
Code Quality ⭐⭐⭐⭐ Good
Test Coverage ⭐⭐⭐ Basic, could be improved
Design ⭐⭐⭐⭐ OK
Maintainability ⭐⭐⭐⭐ Good

Verdict: This is a quality PR with clear logic that solves a real problem. Suggest adding env value test cases before merging.

Request changes mainly for the test coverage improvement, but the core implementation is solid. 👍

@Alix-007
Copy link
Contributor Author

CLA has been signed.

This PR is currently blocked because the PR workflow is in action_required and no jobs have started yet for this fork PR.
Could a maintainer please approve the workflow run?

There are 4 related small bugfix PRs from the same contributor also waiting on workflow approval: #1377, #1378, #1379, #1380.

@Alix-007
Copy link
Contributor Author

Thanks for the careful review and the concrete suggestions.

I pushed an update on this branch to address the coverage gaps you called out:

  • added tests for true, yes, and on
  • added coverage for the root command with no subcommand
  • added coverage for an unknown subcommand
  • moved PICOCLAW_NO_BANNER into its own constant declaration for clarity

I also re-ran:

  • go test ./cmd/picoclaw -run TestShouldPrintBanner

Please take another look when you have a moment.

@Alix-007
Copy link
Contributor Author

Quick follow-up on the fork workflow approvals: besides the earlier batch, the additional small-fix PRs #1384, #1385, #1386, #1391, #1392, and #1393 are also still showing action_required / no jobs created on the PR workflow. When you have time, could you approve workflows for those as well so CI can start? Thanks.

@Alix-007
Copy link
Contributor Author

Added another batch of focused fixes in #1398, #1399, #1400, #1401, #1402, #1403, and #1404. When convenient, could a maintainer please approve fork workflows for these as well so the PR checks can start? Thank you.

@Alix-007
Copy link
Contributor Author

Addressed the requested banner coverage gap on this branch.

Updates:

  • retained the existing truthy env cases (true, yes, on)
  • added normalization coverage for mixed-case and whitespace-padded values (" TrUe ", "\tON\n")
  • root-command and unknown-subcommand behavior is already covered on this PR branch

I could not run go test ./cmd/picoclaw -run TestShouldPrintBanner -count=1 locally in this environment because go is not available on PATH here, but this is a test-only change scoped to cmd/picoclaw/main_test.go.

Please take another look when convenient.

@Alix-007
Copy link
Contributor Author

Added four more small bug-fix PRs that are currently in the same action_required state and still need maintainer workflow approval before checks can start: #1443, #1444, #1445, and #1446. When convenient, could a maintainer approve GitHub Actions for these fork PRs as well? Thank you.

@Alix-007
Copy link
Contributor Author

New low-risk fix PRs are up and all five are currently mergeable=true but still blocked with no checks created yet, so they likely need maintainer approval to run fork workflows as well:

When you have a moment, could you approve workflow execution for these too? Thanks.

xuwei-xy pushed a commit to xuwei-xy/picoclaw that referenced this pull request Mar 14, 2026
@Alix-007
Copy link
Contributor Author

The review items should be addressed on the branch now:

  • added normalized truthy env-value coverage ( rue, yes, on, mixed case/whitespace)
  • added root-command and unknown-subcommand cases

I also re-ran:

  • go test ./cmd/picoclaw -run TestShouldPrintBanner -count=1`n
    Could you take another look when you have time?

@Alix-007
Copy link
Contributor Author

Closing this old review thread for queue hygiene. The requested changes were addressed long ago, but the branch is now part of an old, workflow-polluted queue and no longer worth carrying as an active PR. If the fix is still desired, I can rebuild it cleanly from current main.

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

Labels

go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] new banner print to STDOUT, break completion flow

3 participants