Skip to content

Refactor skip button logic in StageFooter#344

Open
wemvora wants to merge 3 commits into
nook-browser:devfrom
wemvora:patch-2
Open

Refactor skip button logic in StageFooter#344
wemvora wants to merge 3 commits into
nook-browser:devfrom
wemvora:patch-2

Conversation

@wemvora

@wemvora wemvora commented Jun 4, 2026

Copy link
Copy Markdown

This should make the skip button work. Previously the skip button would go back and not forward.

Summary by CodeRabbit

  • Bug Fixes
    • Onboarding footer button behavior corrected: the secondary button now performs the appropriate skip or back action based on the current onboarding step, fixing incorrect navigation for certain stages and ensuring consistent forward/backward flow.

This should make the skip button work. Previously the skip button would go back and not forward.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f6e1a57-6710-41e4-b5bf-71380542bc64

📥 Commits

Reviewing files that changed from the base of the PR and between 17247d1 and 05facfa.

📒 Files selected for processing (1)
  • Onboarding/Components/StageFooter.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • Onboarding/Components/StageFooter.swift

📝 Walkthrough

Walkthrough

StageFooter is now @MainActor; the secondary button's tap handler calls onContinue() when currentStage == 1 and calls onBack() for all other stage values.

Changes

StageFooter updates

Layer / File(s) Summary
Main actor isolation
Onboarding/Components/StageFooter.swift
StageFooter is annotated with @MainActor, restricting its execution to the main actor.
Secondary button stage-aware action
Onboarding/Components/StageFooter.swift
The secondary button's tap handler now conditionally calls onContinue() when currentStage == 1, and calls onBack() for all other stage values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I’m a rabbit on the footer rail,
A tap decides a different tale,
At stage one I leap and continue,
Else I hop backward, quick and true,
Hooray for tiny routing cues! 🐰✨

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring the skip button logic in StageFooter to make it work correctly by changing the stage-specific behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Enforce Pr Base ✅ Passed PR #344 correctly targets the dev branch (not main), satisfying the enforce pr base requirement. The user confirmed they previously targeted main by mistake but corrected it to dev.

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

✨ 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 and usage tips.

@wemvora

wemvora commented Jun 4, 2026

Copy link
Copy Markdown
Author

I previously accidentally made a pull to main. This is the same code and pull request but just in dev.

@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.

🧹 Nitpick comments (2)
Onboarding/Components/StageFooter.swift (2)

68-75: ⚡ Quick win

Consider removing the redundant outer condition check.

The condition at line 68 checking currentStage > 0 is redundant because line 66 already ensures the button only appears when currentStage != 0. This creates unnecessary nesting without functional benefit.

♻️ Proposed simplification
             if !(currentStage == 0) {
                 Button {
-                    if currentStage > 0 {
-                        if currentStage == 1 {
-                            // Skip at stage 1 should advance, not go back
-                            onContinue()
-                        } else {
-                            onBack()
-                        }
+                    if currentStage == 1 {
+                        // Skip at stage 1 should advance, not go back
+                        onContinue()
+                    } else {
+                        onBack()
                     }
                 } label: {
🤖 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 `@Onboarding/Components/StageFooter.swift` around lines 68 - 75, Remove the
redundant outer `if currentStage > 0` check and simplify the control flow inside
the StageFooter so the Skip handling directly checks `currentStage == 1` to call
`onContinue()` and otherwise calls `onBack()`; update the Skip button handler in
StageFooter.swift to call `onContinue()` when `currentStage == 1` and `onBack()`
for all other non-zero stages (using the existing `currentStage`,
`onContinue()`, and `onBack()` symbols).

10-10: Onboarding/Components/StageFooter.swift: remove redundant currentStage > 0 guard in secondary button

  • The secondary button is only shown when currentStage != 0 and OnboardingView constrains currentStage to 0...7 (advance guards < 7, goBack guards > 0), so the inner if currentStage > 0 { ... } (line 68) is redundant. You can simplify the action to if currentStage == 1 { onContinue() } else { onBack() }.
  • StageFooter has no explicit @MainActor; the repo also doesn’t annotate struct ...: View/ViewModifier types with @MainActor, so this matches the project’s convention for SwiftUI view isolation.
🤖 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 `@Onboarding/Components/StageFooter.swift` at line 10, The secondary button in
StageFooter contains a redundant `if currentStage > 0` check; since the button
is only rendered when `currentStage != 0` and the parent constrains stages,
replace the inner guarded branch in the secondary button's action with a simple
conditional: `if currentStage == 1 { onContinue() } else { onBack() }`, removing
the extra `if currentStage > 0 { ... }` wrapper; keep StageFooter as-is without
adding `@MainActor` annotations.
🤖 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.

Nitpick comments:
In `@Onboarding/Components/StageFooter.swift`:
- Around line 68-75: Remove the redundant outer `if currentStage > 0` check and
simplify the control flow inside the StageFooter so the Skip handling directly
checks `currentStage == 1` to call `onContinue()` and otherwise calls
`onBack()`; update the Skip button handler in StageFooter.swift to call
`onContinue()` when `currentStage == 1` and `onBack()` for all other non-zero
stages (using the existing `currentStage`, `onContinue()`, and `onBack()`
symbols).
- Line 10: The secondary button in StageFooter contains a redundant `if
currentStage > 0` check; since the button is only rendered when `currentStage !=
0` and the parent constrains stages, replace the inner guarded branch in the
secondary button's action with a simple conditional: `if currentStage == 1 {
onContinue() } else { onBack() }`, removing the extra `if currentStage > 0 { ...
}` wrapper; keep StageFooter as-is without adding `@MainActor` annotations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1d5a28f-1dfb-470c-b891-ccfcb32d49b4

📥 Commits

Reviewing files that changed from the base of the PR and between fe81d9e and cc61bd9.

📒 Files selected for processing (1)
  • Onboarding/Components/StageFooter.swift

@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.

Caution

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

⚠️ Outside diff range comments (1)
Onboarding/Components/StageFooter.swift (1)

10-10: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add @MainActor annotation for thread safety.

The struct is missing the @MainActor annotation required by the coding guidelines. As per coding guidelines, all Swift code must be confined to @MainActor for thread safety across the entire codebase.

🔒 Proposed fix to add `@MainActor`
+@MainActor
 struct StageFooter: View {
🤖 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 `@Onboarding/Components/StageFooter.swift` at line 10, Add the `@MainActor`
annotation to the StageFooter view struct to ensure UI/thread-safety; locate the
struct declaration "struct StageFooter: View" and prepend the `@MainActor`
attribute (i.e., change the declaration to annotate StageFooter with `@MainActor`)
so the view and its methods run on the main actor.
🤖 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.

Outside diff comments:
In `@Onboarding/Components/StageFooter.swift`:
- Line 10: Add the `@MainActor` annotation to the StageFooter view struct to
ensure UI/thread-safety; locate the struct declaration "struct StageFooter:
View" and prepend the `@MainActor` attribute (i.e., change the declaration to
annotate StageFooter with `@MainActor`) so the view and its methods run on the
main actor.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8ff79e36-8711-4d46-9115-3f7db00f835b

📥 Commits

Reviewing files that changed from the base of the PR and between cc61bd9 and 17247d1.

📒 Files selected for processing (1)
  • Onboarding/Components/StageFooter.swift

@wemvora

wemvora commented Jun 4, 2026

Copy link
Copy Markdown
Author

Note: last two commit messages were generated by AI. Second commit used AI by inputting the coderabbit AI prompt just to help me understand what coderabbit was saying a bit more. Actual changes were made by me.

@wemvora

wemvora commented Jun 4, 2026

Copy link
Copy Markdown
Author

@jonathancaudill I could make a discord server for Nook so that there is a more informal chat area and a way to easily contact contributers and other supporters. What is your discord btw?

@jonathancaudill

Copy link
Copy Markdown
Contributor

@wemvora there already is one!! should be in the gh description or on the website I think. TBH, I'm a full time tech employee now so contributing anything outside of small open source projects is nigh impossible these days. Will probably be looking for someone to take over maintenance.

@wemvora

wemvora commented Jun 5, 2026

Copy link
Copy Markdown
Author

@jonathancaudill yes I could help with maintenance and keep the dc up to date with events and stuff

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.

2 participants