refactor: Toast をグローバル1本化(ToastProvider + 単一Portalホスト) (#1400)#1402
Merged
Conversation
各コンポーネントがローカルに useToast() + <ToastContainer> を生成していたのを、 アプリ全体で共有する ToastProvider (React Context) へ集約。 - Toast.tsx: 状態機械を useToastState() に抽出し、ToastProvider が showToast/removeToast/clearToasts を Context 提供、単一の <ToastContainer>(#1399 の document.body への createPortal を踏襲)を1箇所だけ描画。 useToast() は Provider 配下で共有インスタンス、非配下ではローカルへフォールバック。 - AppProviders: NextIntlClientProvider 直下に ToastProvider を配置(AppShell の transform 外)。 - Sidebar / CommandPalette / MarkdownEditor / LogViewer / NotificationsSettings / WorktreeDetailRefactored / WorktreeDetailDesktop / useWorktreeDetailController: ローカルの <ToastContainer> と toasts/removeToast の受け渡しを撤去し showToast のみ共有 Context 経由に。 - 種類・自動消滅・スタッキング・アニメーション等の既存挙動は不変。 grep -rn "ToastContainer" src/ の描画箇所は Provider 内の単一ホストのみ。 lint / tsc / test:unit (10169) すべてグリーン。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtG2MtTqXXgKz28HAVx9K7
This was referenced Jul 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
アプリ内に散在していた
ToastContainer/useToastを、単一のグローバルToastProvider+ 単一の Portal ホストに統合するリファクタ。Closes #1400依存 #1399(
ToastContainerのdocument.bodyへのcreatePortal化)は既に develop にマージ済みで、その portal 描画を単一ホストで踏襲している。変更内容
src/components/common/Toast.tsx:ToastContext/ToastProviderを新設。useToast()はuseContext(ToastContext)を返す共有フックに変更(Provider外でもクラッシュしないようctx ?? localフォールバック)。<ToastContainer>の実描画は Provider 内の1箇所のみに集約(fix(ui): サイドバー同期トーストが見切れる(fixed要素がtransform祖先に閉じ込められる) #1399 の portal 描画を維持)。src/components/providers/AppProviders.tsx:ToastProviderをアプリ全体にマウント。useToast()+<ToastContainer>を撤去し、共有 Context 経由に置き換え:layout/Sidebar.tsx(SyncButton),common/CommandPalette.tsx,notifications/NotificationsSettings.tsxworktree/LogViewer.tsx,worktree/MarkdownEditor.tsx,worktree/WorktreeDetailDesktop.tsx,worktree/WorktreeDetailRefactored.tsx,hooks/useWorktreeDetailController.tsToast.test.tsx,CommandPalette.test.tsx,Sidebar.test.tsx,MarkdownEditor.test.tsx。完遂確認
grep -rn '<ToastContainer' src/→ 実描画はToast.tsxの Provider 内 1 箇所のみ(他はコメント)。useToast()(Context)を使用。孤立したローカルキューなし。テスト
npm run lint: PASSnpx tsc --noEmit: PASSnpm run test:unit(CI=true): PASS(596 files / 10169 tests)効果