Skip to content

refactor: decompose screen_reachability updateConfig nested switch - #263

Merged
YoungJinJung merged 3 commits into
mainfrom
refactor/issue-205-reachability-update-config
Aug 14, 2026
Merged

refactor: decompose screen_reachability updateConfig nested switch#263
YoungJinJung merged 3 commits into
mainfrom
refactor/issue-205-reachability-update-config

Conversation

@YoungJinJung

Copy link
Copy Markdown
Contributor

Summary

Implements #205: updateConfig in screen_reachability.go handled field navigation, protocol selection, character input validation, and submission in one nested switch.

  • The key switch now dispatches to focused helpers: configMaxField() (single source of truth for the manual-IP extra field), adjustConfigProtocol(), deleteConfigChar(), appendConfigChar() (digit/IP charset validation unchanged), and submitConfig() (advance from the protocol field, run analysis from input fields).
  • Behavior is unchanged; the duplicated maxField computation that appeared three times is gone.

Testing

  • go test ./... passes; new unit tests cover max-field derivation, protocol clamping (including no-op off the protocol field), port/IP character validation with backspace, and enter-advance vs. analysis-start.
  • make build passes.

Closes #205

Split the nested-switch updateConfig into focused helpers:
configMaxField (manual-IP destinations expose an extra field),
adjustConfigProtocol, deleteConfigChar, appendConfigChar (with the
existing digit/IP charset validation), and submitConfig (advance from
the protocol field, start analysis from input fields). Key handling
behavior is unchanged and each piece now has direct unit tests.

Closes #205

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BFhLrnpVxivu62cC3k9NZB
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 27 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: f552d91f-ef9c-4f93-861a-ec9ec7400fc1

📥 Commits

Reviewing files that changed from the base of the PR and between 2a15628 and 0d8dd76.

📒 Files selected for processing (2)
  • internal/app/screen_reachability.go
  • internal/app/screen_reachability_config_test.go

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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This refactoring successfully decomposes the nested switch logic in updateConfig into focused helper methods. The changes eliminate duplicated maxField computations and improve code maintainability while preserving the original behavior. Unit tests provide good coverage of the new helper functions.

One minor simplification suggested for the condition in submitConfig() where redundant logic can be removed without affecting functionality.


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.

Comment thread internal/app/screen_reachability.go Outdated
// submitConfig advances from the protocol field to the next input field, and
// starts the analysis when pressed on an input field.
func (rm *reachabilityModel) submitConfig(m *Model) (tea.Model, tea.Cmd) {
if rm.configField == 0 && rm.configField < rm.configMaxField() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The condition rm.configField == 0 && rm.configField < rm.configMaxField() contains redundant logic. Since configMaxField() returns either 1 or 2, the check rm.configField < rm.configMaxField() is always true when rm.configField == 0. Simplify to if rm.configField == 0 for clarity.

Suggested change
if rm.configField == 0 && rm.configField < rm.configMaxField() {
if rm.configField == 0 {

@YoungJinJung YoungJinJung left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

과설계 관점 리뷰: 기존 동작 53줄을 단일 호출 helper 여러 개로 분해해 production code가 16줄 늘었습니다. 기존 redundant-condition 코멘트와 별개입니다.

Comment thread internal/app/screen_reachability.go Outdated
return 1
}

func (rm *reachabilityModel) adjustConfigProtocol(delta int) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[P3] shrink: adjustConfigProtocol, deleteConfigChar, appendConfigChar, submitConfig는 모두 이 switch에서 한 번만 호출되고 재사용/독립 상태가 없습니다. 분해 후 로직을 이해하려면 네 함수를 왕복해야 하고 production code는 16줄 순증가했습니다. 반복되던 max-field 계산만 helper로 남기고 나머지는 switch에 두는 편이 더 짧고 직접적입니다. net: -16 lines possible.

YoungJin and others added 2 commits August 14, 2026 09:22
Address review: adjustConfigProtocol, deleteConfigChar,
appendConfigChar, and submitConfig were each called exactly once, so
the decomposition added indirection without reuse. The logic is back
in the key switch; only configMaxField remains as a helper since the
max-field computation was the piece duplicated three times. Tests now
drive updateConfig through key messages, pinning the same behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BFhLrnpVxivu62cC3k9NZB
@YoungJinJung

Copy link
Copy Markdown
Contributor Author

Addressed: folded the four single-call helpers back into the key switch and kept only configMaxField() — the piece that was actually duplicated three times. Tests were rewritten to drive updateConfig through key messages, so the same behavior (protocol clamping, charset validation, enter-advance vs. analysis-start) stays pinned without depending on helper seams.

@YoungJinJung
YoungJinJung merged commit b904184 into main Aug 14, 2026
@YoungJinJung
YoungJinJung deleted the refactor/issue-205-reachability-update-config branch August 14, 2026 00:23
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.

refactor: decompose screen_reachability.go updateConfig() nested switch

1 participant