docs: recommend dialogApi + use*Dialog hook as the default pattern#306
Conversation
CodeRabbit was flagging the dialogApi-based dialogs (the project's actual convention — 38 of them, 0 inline-useState dialogs in the codebase) as violating an outdated guideline that said the opposite. @CptnFizzbin confirmed on #274 (comment)... that the guidance is out of date and asked for it to be flipped. The premise of the old guideline — that dialogApi "renders outside the provider tree" — is no longer true: DialogApiProvider is mounted inside CharacterSheetProvider in the character routes and inside the builder root, so React context propagates normally through dialogs rendered by dialogApi.open. Updates: - AGENTS.md "Dialog patterns" first bullet: now recommends the useDialogApi + use*Dialog hook pattern as the default and points at useAddKarmaDialog / useActiveSkillDialog as examples. The other two bullets (useConfirmDialog, compound Dialog) are unchanged. - docs/ui/dialog.md - "Inline useState dialog (no DialogApi)" section intro: reframed from "prefer this" to "use only when no DialogApi available" — inline state is now positioned as a rare alternative, not the default. The code example below stays as-is. - "Guidelines" first bullet: flipped to recommend the useDialogApi + use*Dialog hook pattern. The other three bullets (onClosed vs onClose, maxWidth, no styling props) are unchanged. No code changes. CodeRabbit should stop flagging dialogApi-based dialogs as a convention violation on subsequent reviews.
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 30 minutes and 54 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR updates documentation guidance across two files to establish ChangesDialog Pattern Guidance
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
…attern-guidance # Conflicts: # AGENTS.md # docs/ui/dialog.md
Summary
Flips the outdated "prefer inline
useStatedialogs" guidance inAGENTS.mdanddocs/ui/dialog.mdto recommend the project's actual convention: ause*Dialoghook that wrapsdialogApi.open(...).CodeRabbit has been flagging
dialogApi-based dialogs as convention violations on PRs (most recently #274). @CptnFizzbin confirmed on that thread that the guidance is out of date and asked for the docs to be updated.Why the old guidance no longer applies
The old text claimed
dialogApi"renders outside the provider tree" so dialogs lost access toCharacterSheetProvider. That's no longer true:DialogApiProvideris mounted insideCharacterSheetProviderin the character routes ($characterId.tsx) and inside the builder root.DialogErrorBoundaryalready catchesOutOfContextErrorand gracefully shows an alert if a future tree ever did drop a provider.A quick audit of the codebase: 38 dialogs use the
use*Dialog+dialogApipattern (e.g.useAddKarmaDialog,useActiveSkillDialog,useSpellFormDialog,useConfirmDialog, every dialog undersrc/components/items/dialogs/). Zero use the inlineuseStatepattern the guideline currently recommends.What changed
AGENTS.md→ Dialog patterns — first bullet flipped; the other two (compoundDialog,useConfirmDialog) stay verbatim.docs/ui/dialog.md:useStatedialog (no DialogApi)" section intro reframed from "prefer this pattern" to "use only when noDialogApiis available." The example code below stays — it's still valid when applicable.useDialogApi+use*Dialoghook pattern; the other three bullets unchanged.Test plan
grep "Prefer inline" AGENTS.md docs/returns no matches.grep "renders outside the provider tree"returns no matches.dialogApishould no longer flag the pattern. (No way to verify short of opening another PR — flagging for the next review cycle.)Docs-only change — no code, no tests, no CI surface affected.