Skip to content

fix: clear modal input and error state on close - #3091

Merged
ghostdevv merged 2 commits into
npmx-dev:mainfrom
iiio2:fix/clear-modal-input-and-error-state
Jul 30, 2026
Merged

fix: clear modal input and error state on close#3091
ghostdevv merged 2 commits into
npmx-dev:mainfrom
iiio2:fix/clear-modal-input-and-error-state

Conversation

@iiio2

Copy link
Copy Markdown
Contributor

Both the Local Connector and Atmosphere modals kept their form state after being dismissed. If a connection attempt failed, closing the modal and reopening it showed the previously entered token/handle still populated, along with the stale error message from the last attempt. Now, both modals now reset their form state when the dialog closes.

Before:
when we write on input fieldn closes it and opens it again, we can still see the input and error message.

before

After:
Now we cannot see.

after

@vercel

vercelBot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
npmx.devReadyReadyPreview, CommentJul 28, 2026 5:03pm
2 Skipped Deployments
ProjectDeploymentActionsUpdated (UTC)
docs.npmx.devIgnoredIgnoredPreviewJul 28, 2026 5:03pm
npmx-lunariaIgnoredIgnoredJul 28, 2026 5:03pm

Request Review

@coderabbitai

coderabbitaiBot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Login forms now clear entered details and error messages when closed, preventing stale information when reopened.
    • Connection forms now reset token input, connection attempt state, and error messages when closed or disconnected.
    • Error messages are cleared more reliably during connection resets.
  • Tests
    • Updated Header Connector modal tests to support the new error-clearing behavior.

Walkthrough

Authentication and connector modals now clear transient form state when closed. Connector disconnection also resets token, connection-attempt, and error state through a new clearError action exposed by useConnector.

Changes

Modal Form State Reset

Layer / File(s)Summary
Connector form reset flow
app/composables/useConnector.ts, app/components/Header/ConnectorModal.vue, test/nuxt/components/HeaderConnectorModal.spec.ts
useConnector exposes clearError(). ConnectorModal resets token, attempt status, and errors when disconnected or closed while disconnected, with the test mock updated for the new action.
Authentication form reset
app/components/Header/AuthModal.client.vue
The authentication modal clears login input and displayed errors when its close event is emitted.

Suggested reviewers:alexdln

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check nameStatusExplanation
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly matches the main change: resetting modal input and error state when the modal closes.
Description check✅ PassedThe description is directly related to the change, explaining that both modals now reset stale form and error state on close.
✨ 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.

@codecov

codecovBot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
app/components/Header/AuthModal.client.vue0.00%2 Missing ⚠️
app/components/Header/ConnectorModal.vue85.71%1 Missing ⚠️
app/composables/useConnector.ts0.00%1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

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 `@app/components/Header/ConnectorModal.vue`:
- Around line 27-31: Update the isConnected watcher in ConnectorModal so
resetForm() does not clear an existing connector error from refreshState(), such
as “Connection lost”; only reset the form for intentional close/manual
disconnect or when no connector error is present.
🪄 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: CHILL

Plan: Pro Plus

Run ID: 9db44543-8a59-4662-8058-74fc412cd344

📥 Commits

Reviewing files that changed from the base of the PR and between 2c78c40 and 095a9b0.

📒 Files selected for processing (3)
  • app/components/Header/AuthModal.client.vue
  • app/components/Header/ConnectorModal.vue
  • app/composables/useConnector.ts

Comment on lines 27 to 31
watch(isConnected, connected => {
if (!connected) {
tokenInput.value = ''
hasAttemptedConnect.value = false
resetForm()
}
})

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bashset -euo pipefail
echo"Locate file and related symbols"
fd -p 'app/components/Header/ConnectorModal.vue'.||true
wc -l app/components/Header/ConnectorModal.vue
echoecho"Relevant file sections"
cat -n app/components/Header/ConnectorModal.vue | sed -n '1,260p'echoecho"Search for clearError and error propagation"
rg -n "clearError|error\.value|useConnector|resetForm|refreshState|connection lost|Connection lost" app -S

Repository: npmx-dev/npmx.dev

Length of output: 13586


🏁 Script executed:

#!/bin/bashset -euo pipefail
echo"Relevant useConnector sections"
cat -n app/composables/useConnector.ts | sed -n '1,220p'
cat -n app/composables/useConnector.ts | sed -n '410,450p'echoecho"Shared composable usage of clearError"
rg -n "function clearError|clearError\(|error\.(value|= null)|\.error\s*=\s*null" app/composables/useConnector.ts app -S | sed -n '1,120p'echoecho"Static read-only invariant probe: parse resetForm callers and clearError order"
python3 - <<'PY'from pathlib import Pathp = Path('app/components/Header/ConnectorModal.vue')s = p.read_text()checks = { "resetForm_has_clearError": "function resetForm() {\n tokenInput.value = ''\n hasAttemptedConnect.value = false\n clearError()\n}" in s, "watch_calls_resetForm_on_disconnect": "if (!connected) {\n resetForm()\n }" in s, "watch_has_error_guard": "!error.value" in s and "if (!connected && !error.value)" in s,}print(checks)for name, ok in checks.items(): print(f"{name}: {ok}")PY

Repository: npmx-dev/npmx.dev

Length of output: 11898


Preserve connection-loss errors in the watcher.

refreshState() sets state.value.error to 'Connection lost' when /state fails and also exposes this via error. The isConnected watcher then calls resetForm(), which sets state.value.error = null; this clears the shared connector error before the UI can report it. Only clear errors for intentional close/manual disconnect, or skip the form reset when a connector error is already present.

Suggested fix
 watch(isConnected, connected => {
- if (!connected) {+ if (!connected && !error.value) {
resetForm()
}
})
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
watch(isConnected, connected => {
if (!connected) {
tokenInput.value = ''
hasAttemptedConnect.value = false
resetForm()
}
})
watch(isConnected, connected => {
if (!connected && !error.value) {
resetForm()
}
})
🤖 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 `@app/components/Header/ConnectorModal.vue` around lines 27 - 31, Update the
isConnected watcher in ConnectorModal so resetForm() does not clear an existing
connector error from refreshState(), such as “Connection lost”; only reset the
form for intentional close/manual disconnect or when no connector error is
present.

@ghostdevvghostdevv changed the title fix: clear modal input + error state on closefix: clear modal input and error state on closeJul 30, 2026
@ghostdevv
ghostdevv added this pull request to the merge queueJul 30, 2026
@ghostdevv
ghostdevv removed this pull request from the merge queue due to a manual request Jul 30, 2026
@ghostdevv
ghostdevv added this pull request to the merge queueJul 30, 2026
Merged via the queue into npmx-dev:main with commit 5416b99Jul 30, 2026
25 checks passed
@github-actionsgithub-actionsBot mentioned this pull request Jul 30, 2026
@iiio2

Copy link
Copy Markdown
ContributorAuthor

Thanks @ghostdevv . 😊

@iiio2
iiio2 deleted the fix/clear-modal-input-and-error-state branch July 30, 2026 15:54
@ghostdevv

Copy link
Copy Markdown
Member

np!

ayo-run pushed a commit to ayo-run/npmx.dev that referenced this pull request Aug 5, 2026
Sign up for freeto 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

@iiio2@ghostdevv