From 279f2c7598dc7642e4d0cd5ad89d4679bfdd562d Mon Sep 17 00:00:00 2001 From: mika kuns Date: Mon, 20 Apr 2026 11:00:45 +0200 Subject: [PATCH] fix(ui): wire modal delegates from DetailsIslandView owner Moved ShowDiffModal/ShowWorktreeModal delegate wiring from AgentStripView (child, possibly detached) to DetailsIslandView (the VM's DataContext owner). TopLevel is resolved at invocation time, not at wiring time, so attachment order no longer matters. AgentStripView reduced to InitializeComponent() only. Co-Authored-By: Claude Sonnet 4.6 --- .../Views/Islands/AgentStripView.axaml.cs | 31 +------------------ .../Views/Islands/DetailsIslandView.axaml.cs | 30 +++++++++++++++++- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs index 37bfc05..84ef7b3 100644 --- a/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs @@ -1,37 +1,8 @@ using Avalonia.Controls; -using ClaudeDo.Ui.ViewModels.Islands; -using ClaudeDo.Ui.ViewModels.Modals; -using ClaudeDo.Ui.Views.Modals; namespace ClaudeDo.Ui.Views.Islands; public partial class AgentStripView : UserControl { - public AgentStripView() - { - InitializeComponent(); - DataContextChanged += OnDataContextChanged; - } - - private void OnDataContextChanged(object? sender, EventArgs e) - { - if (DataContext is DetailsIslandViewModel vm) - { - vm.ShowDiffModal = async (diffVm) => - { - var owner = TopLevel.GetTopLevel(this) as Window; - if (owner == null) return; - var modal = new DiffModalView { DataContext = diffVm }; - await modal.ShowDialog(owner); - }; - - vm.ShowWorktreeModal = async (worktreeVm) => - { - var owner = TopLevel.GetTopLevel(this) as Window; - if (owner == null) return; - var modal = new WorktreeModalView { DataContext = worktreeVm }; - await modal.ShowDialog(owner); - }; - } - } + public AgentStripView() { InitializeComponent(); } } diff --git a/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs index 5585bed..422362e 100644 --- a/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs @@ -1,8 +1,36 @@ using Avalonia.Controls; +using ClaudeDo.Ui.ViewModels.Islands; +using ClaudeDo.Ui.Views.Modals; namespace ClaudeDo.Ui.Views.Islands; public partial class DetailsIslandView : UserControl { - public DetailsIslandView() { InitializeComponent(); } + public DetailsIslandView() + { + InitializeComponent(); + DataContextChanged += OnDataContextChanged; + } + + private void OnDataContextChanged(object? sender, EventArgs e) + { + if (DataContext is DetailsIslandViewModel vm) + { + vm.ShowDiffModal = async (diffVm) => + { + var owner = TopLevel.GetTopLevel(this) as Window; + if (owner == null) return; + var modal = new DiffModalView { DataContext = diffVm }; + await modal.ShowDialog(owner); + }; + + vm.ShowWorktreeModal = async (worktreeVm) => + { + var owner = TopLevel.GetTopLevel(this) as Window; + if (owner == null) return; + var modal = new WorktreeModalView { DataContext = worktreeVm }; + await modal.ShowDialog(owner); + }; + } + } }