Skip to content

fix: avoid startup SSO login#223

Open
nathanhuh wants to merge 2 commits into
mainfrom
fix/221-startup-sso-passive
Open

fix: avoid startup SSO login#223
nathanhuh wants to merge 2 commits into
mainfrom
fix/221-startup-sso-passive

Conversation

@nathanhuh
Copy link
Copy Markdown
Contributor

@nathanhuh nathanhuh commented May 27, 2026

Summary

  • Keep TUI startup passive for SSO contexts when login would be required.
  • Skip startup caller identity loading if the SSO token cache is missing or expired.
  • Preserve explicit SSO login behavior when switching to an SSO context.
  • Document passive startup behavior in README.

Related Issues

Closes #221

Validation

  • make test
  • make build

Checklist

  • Scope is focused
  • Branch name follows docs/branch-naming-harness.md
  • Documentation harness reviewed (docs/documentation-harness.md)
  • README updated if user-facing behavior changed
  • Relevant docs/ pages updated if architecture, auth, config, or workflow changed
  • Tests/validation included
  • Breaking changes documented

Summary by CodeRabbit

  • New Features

    • SSO context startup is now passive: the context picker loads without automatic login prompts; login is only triggered when explicitly selecting an SSO context or when credentials are needed for a workflow.
  • Documentation

    • Updated README to document the new SSO startup behavior.

Review Change Stack

- skip startup caller identity lookup when SSO login would be required
- keep context switching SSO login behavior unchanged
- document passive SSO startup behavior

Closes #221
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@nathanhuh, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 54 minutes. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ac03906a-fd4b-465d-8fca-1fcde91ffb9d

📥 Commits

Reviewing files that changed from the base of the PR and between 8e10a9b and 2cc6587.

📒 Files selected for processing (1)
  • internal/app/app_test.go

Walkthrough

Model.Init() now conditionally skips caller-identity loading at startup when SSO session checks indicate login is required, preventing interactive AWS SSO authentication. Identity loads only when the SSO cache is valid or for non-SSO auth types. Tests and README document the new passive startup behavior.

Changes

Conditional SSO Startup

Layer / File(s) Summary
Conditional startup caller-identity logic
internal/app/app.go
appLoadCallerIdentityFn wraps m.loadCallerIdentity() for reuse. Model.Init() calls loadStartupCallerIdentity(), which skips identity loading when cfg is nil or when SSO session check returns LoginRequired, otherwise delegates to caller-identity loading.
Test coverage for startup SSO behavior
internal/app/app_test.go
Three test functions validate startup behavior: one confirms identity loading is skipped when SSO login is required (cache missing), another confirms identity loads when SSO cache is valid, and a third confirms non-SSO auth types still load identity at startup.
User-facing documentation update
README.md
README clarifies that TUI startup is passive for SSO contexts, loading the context picker without launching aws sso login, with login prompted only on explicit context selection/setup or when AWS-backed workflows require credentials.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix: avoid startup SSO login' follows the conventional commit format with 'fix:' prefix and clearly describes the main change.
Description check ✅ Passed The PR description follows the template with all required sections filled out: Summary, Related Issues, Validation, and Checklist all completed with relevant details.
Linked Issues check ✅ Passed The changes fully implement the acceptance criteria from #221: preventing startup SSO login, loading contexts passively, skipping caller identity when token cache is missing, and including tests for SSO startup behavior.
Out of Scope Changes check ✅ Passed All code changes are directly aligned with the objective of making TUI startup passive for SSO contexts; README documentation and test coverage support the stated changes without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/221-startup-sso-passive

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

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

This PR successfully implements passive SSO startup behavior to prevent interactive login prompts at TUI startup. The implementation correctly checks SSO session validity before attempting to load caller identity, falling back to an empty identity message when login would be required. The changes are well-tested with comprehensive unit tests covering all three scenarios: missing SSO cache, valid SSO cache, and non-SSO auth types. No defects found that would block merge.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/app/app_test.go`:
- Around line 154-227: Add a test that asserts loadStartupCallerIdentity()
treats a failing SSO session check like the LoginRequired case: set
contextCheckSSOSessionFn to return an error (and flip a local checkCalled flag),
stub appLoadCallerIdentityFn to set loadCalled if invoked, call New(...) and
invoke m.loadStartupCallerIdentity()(), then assert the returned msg is a
callerIdentityMsg, checkCalled is true and loadCalled is false; remember to save
and restore the original contextCheckSSOSessionFn and appLoadCallerIdentityFn in
a defer like the other tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7a14abd9-b9b7-4b26-8633-9a452e6aca58

📥 Commits

Reviewing files that changed from the base of the PR and between 321ab19 and 8e10a9b.

📒 Files selected for processing (3)
  • README.md
  • internal/app/app.go
  • internal/app/app_test.go
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
README.md

📄 CodeRabbit inference engine (CLAUDE.md)

README.md: When adding, modifying, or deleting features, always update README.md in parallel with code changes
Update Currently Implemented Features table in README.md: add new services/features, update status changes (🚧→✅), remove deleted items
Update TUI Key Bindings table in README.md when key bindings are added, changed, or deleted
Update Usage section in README.md when new CLI commands or flags are added
Update Configuration section in README.md when configuration format changes

Files:

  • README.md

⚙️ CodeRabbit configuration file

README.md: Verify that README changes match actual CLI/TUI behavior and that
Currently Implemented Features, TUI Key Bindings, Usage, and
Configuration content stay aligned with code changes.

Files:

  • README.md
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: Use lipgloss for styled TUI output — column-aligned tables with dimmed labels in Go implementation files
Implement scroll windowing with formula: visibleLines := max(m.height-N, 5) in Go TUI implementation

Files:

  • internal/app/app.go
  • internal/app/app_test.go

⚙️ CodeRabbit configuration file

**/*.go: For Go reviews, look beyond compilation and prioritize nil pointer risks,
context propagation, AWS SDK pagination, error wrapping, deterministic
sorting, and stable table/detail rendering. For new AWS service work,
verify that repository interfaces, model mapping, app integration, and
tests are updated together.

Files:

  • internal/app/app.go
  • internal/app/app_test.go
internal/app/**

⚙️ CodeRabbit configuration file

internal/app/**: For Bubble Tea screen changes, verify message routing, key handling,
filter target resets, height-based windowing, help text, and back/home
navigation against the existing screen patterns.

Files:

  • internal/app/app.go
  • internal/app/app_test.go
**/*_test.go

📄 CodeRabbit inference engine (CLAUDE.md)

Tests use mock client interfaces (see rds_test.go pattern) in Go test files

Files:

  • internal/app/app_test.go

⚙️ CodeRabbit configuration file

**/*_test.go: Check that tests cover API errors, mapping edge cases, and navigation
state transitions, not only happy paths. Prefer mock-based tests that do
not depend on external AWS calls.

Files:

  • internal/app/app_test.go
🔇 Additional comments (3)
README.md (1)

193-194: LGTM!

internal/app/app.go (1)

274-302: LGTM!

internal/app/app_test.go (1)

229-256: LGTM!

Comment thread internal/app/app_test.go
- assert failed SSO session checks skip startup identity loading
- cover the same passive behavior as missing SSO cache
@nathanhuh
Copy link
Copy Markdown
Contributor Author

/q review

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

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

This PR implements passive SSO startup behavior for the TUI, preventing automatic aws sso login prompts during initialization. The implementation is clean with comprehensive test coverage.

Key Changes:

  • Adds loadStartupCallerIdentity() that checks SSO cache validity before loading caller identity
  • Introduces appLoadCallerIdentityFn variable for improved testability
  • Provides thorough test coverage for SSO cache scenarios
  • Documents the passive SSO behavior in README

The code correctly handles the different SSO session states (cache missing, check failure, valid cache) and preserves existing behavior for non-SSO authentication types. All changes follow existing patterns in the codebase.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

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.

fix: avoid interactive SSO login during TUI startup

1 participant