Skip to content

Replace native window.alert/confirm with app-styled dialogs#263

Open
luojiyin1987 wants to merge 12 commits into
nashsu:mainfrom
luojiyin1987:fix/replace-native-dialogs
Open

Replace native window.alert/confirm with app-styled dialogs#263
luojiyin1987 wants to merge 12 commits into
nashsu:mainfrom
luojiyin1987:fix/replace-native-dialogs

Conversation

@luojiyin1987
Copy link
Copy Markdown

Fixes #262

Summary

Replaces all native window.alert() and window.confirm() calls with an app-styled dialog system built on the existing shadcn/ui Dialog primitive.

What's new

  • src/stores/app-dialog-store.ts — Zustand store that manages a FIFO queue of dialog requests. Exposes alert(options) and confirm(options) as Promise-based APIs.
  • src/components/ui/app-dialog-host.tsx — Global dialog renderer mounted in App.tsx. Consumes the queue and renders one dialog at a time.

Migrated call sites

File Before After
App.tsx window.alert ×2 await alert()
activity-panel.tsx window.confirm await confirm({ confirmVariant: "destructive" })
knowledge-tree.tsx window.alert await alert()
research-panel.tsx window.alert await alert()
lint-view.tsx window.confirm await confirm({ confirmVariant: "destructive" })
review-view.tsx window.alert await alert()
about-section.tsx bare alert() ×2 await alert()
sources-view.tsx window.alert ×2 await alert()

Design decisions

  • Queue-based: multiple dialogs won't clobber each other; they display serially
  • Promise API: minimal migration cost — window.alert(msg)await alert({ message: msg })
  • Destructive variant: delete/cancel confirmations use the red destructive button style
  • No close button: showCloseButton={false} on confirm dialogs so users must explicitly choose an action

Test plan

  • Verified npm run typecheck passes
  • Verified npm run test:mocks passes
  • Manually tested alert and confirm flows in dev build

Commits

Each file is committed separately for clean history:

  1. feat: add app-dialog store
  2. feat: add AppDialogHost component
  3. refactor(App)
  4. refactor(activity-panel)
  5. refactor(knowledge-tree)
  6. refactor(research-panel)
  7. refactor(lint-view)
  8. refactor(review-view)
  9. refactor(about-section)
  10. refactor(sources-view)

Introduces useAppDialog() hook backed by a Zustand queue.
Supports Promise-based alert() and confirm() with variant
styling (default/destructive) so callers can await user
interaction instead of blocking on window.alert/confirm.
Global dialog renderer that consumes the app-dialog store queue.
Mounts once in App.tsx and serially displays alert/confirm
dialogs using the existing shadcn/ui Dialog primitive.
Mounts AppDialogHost in all three render paths (loading,
welcome, project) and replaces the two window.alert calls
with await alert() for consistent dialog styling.
Converts handleCancelAll to async and replaces window.confirm
with await confirm() using destructive variant for cancel
operations.
Replaces delete-failure window.alert with alert() and adds
useAppDialog import.
Replaces web-search-not-configured window.alert with await
alert() in handleStartResearch.
Replaces orphan-page delete confirmation with await confirm()
and uses destructive variant for the delete action.
Replaces web-search-not-configured window.alert with await
alert() in the deep-research action handler.
Replaces the two bare alert() calls (browser-open fallback)
with await alert() for consistent dialog styling.
Replaces delete-failure and delete-folder-failure window.alert
calls with await alert().
# Conflicts:
#	src/components/layout/research-panel.tsx
#	src/components/lint/lint-view.tsx
#	src/components/review/review-view.tsx
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.

Replace native window.alert/confirm with app-styled dialogs

1 participant