Skip to content

feat: add multi-region context scopes - #234

Merged
YoungJinJung merged 2 commits into
DevopsArtFactory:mainfrom
youngjinjung-linq:feature/issue-233-multi-region-contexts
Aug 5, 2026
Merged

feat: add multi-region context scopes#234
YoungJinJung merged 2 commits into
DevopsArtFactory:mainfrom
youngjinjung-linq:feature/issue-233-multi-region-contexts

Conversation

@youngjinjung-linq

@youngjinjung-linq youngjinjung-linq commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Separate AWS authentication identity from resource location and let one context switch between multiple configured regions.

  • add preferred structured auth and resources context sections
  • preserve full compatibility with legacy flat context fields
  • add a global R region picker that keeps account and role unchanged
  • reuse the active AWS credentials provider when recreating regional clients
  • keep shell exports and startup behavior anchored to the configured default region
  • update the add-context flow, help, status bar, tests, and documentation

Closes #233

Configuration

contexts:
  - name: production
    auth:
      type: sso
      sso_start_url: https://example.awsapps.com/start
      sso_region: us-east-1
      sso_account_id: "123456789012"
      sso_role_name: AdministratorAccess
    resources:
      default_region: ap-northeast-2
      regions:
        - us-east-1
        - eu-west-1

The default region is automatically included in the selectable list. Contexts without a region list retain the existing single-region behavior.

Verification

  • go vet ./...
  • make test
  • make build
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added support for structured authentication and resource-region configuration.
    • Added multiple resource regions per context, with runtime switching via R.
    • Added a region picker with active-region indicators and navigation support.
    • Added region switching while preserving existing authentication credentials.
    • Context filtering now searches across all configured regions.
  • Documentation

    • Updated English and Korean documentation with configuration, fallback, and region-switching guidance.
    • Documented continued support for legacy configuration fields.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@youngjinjung-linq, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ed46ceef-2146-4ae0-9fb4-6d5f4674d682

📥 Commits

Reviewing files that changed from the base of the PR and between 1fb2e40 and d9315fe.

📒 Files selected for processing (9)
  • README.md
  • internal/app/app.go
  • internal/app/context_add.go
  • internal/app/context_add_test.go
  • internal/app/help.go
  • internal/app/screen_region.go
  • internal/app/screen_region_test.go
  • internal/auth/setup.go
  • internal/auth/setup_test.go

Walkthrough

The change separates authentication settings from resource-region settings. Context loading supports structured and legacy fields. AWS repositories can switch regions while reusing credentials. The TUI adds a multi-region picker and R shortcut.

Changes

Multi-region resource contexts

Layer / File(s) Summary
Structured context resolution
internal/config/config.go, internal/config/config_test.go, README.md, docs/architecture.*.md
Nested auth and resources fields resolve with legacy fields into normalized region lists. Documentation describes region selection and fallback behavior.
Context creation and SSO synchronization
internal/app/context_add.go, internal/app/context_add_test.go, internal/auth/setup.go
Context creation stores default and additional regions. SSO setup normalizes regions and preserves them when contexts are reused.
Regional AWS repository creation
internal/services/aws/repository.go, internal/services/aws/repository_test.go
ForRegion creates regional clients while retaining the existing profile and credentials.
TUI resource-region switching
internal/app/app.go, internal/app/screen_region.go, internal/app/screen_context.go, internal/app/messages.go, internal/app/help.go, internal/app/styles.go, internal/app/screen_region_test.go
The TUI adds a resource-region picker, global R shortcut, active-region status display, and runtime repository switching.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • DevopsArtFactory/unic#232: Extends SSO and resource-region separation with nested context fields and multi-region configuration.

Suggested reviewers: nathanhuh, youngjinjung

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% 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 title uses the required feat: prefix and clearly describes the multi-region context scope change.
Description check ✅ Passed The description explains the change, linked issue, configuration, compatibility behavior, and validation commands; the checklist headings are omitted.
Linked Issues check ✅ Passed The changes satisfy issue #233 by adding multi-region contexts, region switching, credential reuse, compatibility handling, tests, and documentation.
Out of Scope Changes check ✅ Passed The code, tests, UI updates, and documentation changes are directly related to the multi-region context objectives.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/app/context_add.go (1)

20-53: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the focused context-add input on screen for short terminals.

viewContextAdd renders completed fields, the current input, a confirmation line, and the help bar as one block. For the expanded SSO form, add windowing that reserves the appropriate screen chrome and keeps m.addFieldIdx in the visible area, using visibleLines := max(m.height-N, 5).

🤖 Prompt for 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.

In `@internal/app/context_add.go` around lines 20 - 53, Update viewContextAdd to
window the expanded SSO form instead of rendering all fields unconditionally.
Reserve space for the confirmation line and help bar, calculate visibleLines as
max(m.height-N, 5) with the appropriate chrome count, and choose the field slice
so m.addFieldIdx remains visible while preserving the current input and
completed-field rendering.

Sources: Coding guidelines, Path instructions

🤖 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.go`:
- Around line 531-541: Update the region-switch eligibility logic used by the R
shortcut in app.go and help.go to use the same shared helper. The helper must
require non-nil m.cfg, multiple configured regions, no focused input or
text-entry screen, and must reject every active-request screen, including
screenLoading and screenInspectorScanning; use it both to open the picker and to
show the shortcut in help.

In `@internal/app/screen_region_test.go`:
- Around line 12-63: The region-picker tests currently omit updateRegionPicker
navigation and error paths. Extend coverage around updateRegionPicker to verify
q and esc restore regionPrevScreen, cursor movement updates the selected index,
selecting the active region completes the switch, and repository-creation
failures are handled; inject a mock repository/client seam for the failure test
rather than relying on AWS configuration.

In `@internal/app/screen_region.go`:
- Around line 84-92: Update the region-row rendering in the surrounding region
list function to write the region text with its existing row style and render
the “(active)” marker separately with dimStyle. Preserve cursor and selected-row
styling for the region text while ensuring the active label remains dimmed in
both selected and unselected rows.

In `@internal/auth/setup.go`:
- Around line 355-358: Update the Resources initialization in the generated SSO
context setup to persist only the regions after the normalized default region,
rather than the full base.Regions list. Keep DefaultRegion assigned from region
and slice base.Regions past its index when setting Regions.

In `@README.md`:
- Around line 173-185: Synchronize the preferred structured SSO example under
the production configuration with the required-fields table: verify the actual
CLI/TUI SSO configuration contract, then either add auth.profile to the example
if required or update the sso row to mark profile optional. Keep the
documentation consistent with the implemented behavior.

---

Outside diff comments:
In `@internal/app/context_add.go`:
- Around line 20-53: Update viewContextAdd to window the expanded SSO form
instead of rendering all fields unconditionally. Reserve space for the
confirmation line and help bar, calculate visibleLines as max(m.height-N, 5)
with the appropriate chrome count, and choose the field slice so m.addFieldIdx
remains visible while preserving the current input and completed-field
rendering.
🪄 Autofix

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: 0279db6e-4625-4969-b331-21d8c9fe52f8

📥 Commits

Reviewing files that changed from the base of the PR and between 2231960 and 1fb2e40.

📒 Files selected for processing (17)
  • README.md
  • docs/architecture.en.md
  • docs/architecture.ko.md
  • internal/app/app.go
  • internal/app/context_add.go
  • internal/app/context_add_test.go
  • internal/app/help.go
  • internal/app/messages.go
  • internal/app/screen_context.go
  • internal/app/screen_region.go
  • internal/app/screen_region_test.go
  • internal/app/styles.go
  • internal/auth/setup.go
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/services/aws/repository.go
  • internal/services/aws/repository_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: test
🧰 Additional context used
📓 Path-based instructions (6)
**/*.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/context_add_test.go
  • internal/app/screen_context.go
  • internal/app/screen_region.go
  • internal/config/config_test.go
  • internal/app/screen_region_test.go
  • internal/app/styles.go
  • internal/services/aws/repository.go
  • internal/app/help.go
  • internal/services/aws/repository_test.go
  • internal/auth/setup.go
  • internal/app/context_add.go
  • internal/app/app.go
  • internal/config/config.go
  • internal/app/messages.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/context_add_test.go
  • internal/app/screen_context.go
  • internal/app/screen_region.go
  • internal/config/config_test.go
  • internal/app/screen_region_test.go
  • internal/app/styles.go
  • internal/services/aws/repository.go
  • internal/app/help.go
  • internal/services/aws/repository_test.go
  • internal/auth/setup.go
  • internal/app/context_add.go
  • internal/app/app.go
  • internal/config/config.go
  • internal/app/messages.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/context_add_test.go
  • internal/config/config_test.go
  • internal/app/screen_region_test.go
  • internal/services/aws/repository_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/context_add_test.go
  • internal/config/config_test.go
  • internal/app/screen_region_test.go
  • internal/services/aws/repository_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/context_add_test.go
  • internal/app/screen_context.go
  • internal/app/screen_region.go
  • internal/app/screen_region_test.go
  • internal/app/styles.go
  • internal/app/help.go
  • internal/app/context_add.go
  • internal/app/app.go
  • internal/app/messages.go
docs/**

⚙️ CodeRabbit configuration file

docs/**: Documentation must match implemented behavior. When both English and
Korean docs are updated, verify that they preserve the same meaning.

Files:

  • docs/architecture.en.md
  • docs/architecture.ko.md
internal/services/aws/**

⚙️ CodeRabbit configuration file

internal/services/aws/**: For AWS integration code, focus on SDK client interface mockability,
paginator usage, nil/empty response handling, AWS pointer conversion,
stable list ordering, and user-facing error messages.

Files:

  • internal/services/aws/repository.go
  • internal/services/aws/repository_test.go
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
🔇 Additional comments (16)
internal/config/config.go (1)

64-77: LGTM!

Also applies to: 80-96, 112-112, 160-223, 255-310, 343-358, 418-439

internal/config/config_test.go (1)

6-6: LGTM!

Also applies to: 279-334

README.md (1)

215-227: LGTM!

Also applies to: 354-354

docs/architecture.en.md (1)

196-198: LGTM!

docs/architecture.ko.md (1)

196-198: LGTM!

internal/app/context_add.go (1)

128-170: LGTM!

internal/app/context_add_test.go (1)

39-43: LGTM!

internal/auth/setup.go (1)

321-335: LGTM!

Also applies to: 346-354, 363-393

internal/app/styles.go (1)

112-116: LGTM!

internal/services/aws/repository.go (1)

377-415: LGTM!

internal/services/aws/repository_test.go (1)

8-10: LGTM!

Also applies to: 44-65

internal/app/app.go (1)

109-109: LGTM!

Also applies to: 188-189, 573-574, 733-734

internal/app/help.go (1)

723-728: LGTM!

Also applies to: 974-975

internal/app/messages.go (1)

68-71: LGTM!

internal/app/screen_context.go (1)

66-72: LGTM!

internal/app/screen_region.go (1)

13-78: LGTM!

Also applies to: 94-97

Comment thread internal/app/app.go
Comment thread internal/app/screen_region_test.go Outdated
Comment thread internal/app/screen_region.go
Comment thread internal/auth/setup.go
Comment thread README.md
@YoungJinJung
YoungJinJung merged commit cf9c5f5 into DevopsArtFactory:main Aug 5, 2026
2 checks passed
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.

feat: add multi-region resource scopes to contexts

2 participants