diff --git a/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml b/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml index 6e25b8c..3e85827 100644 --- a/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml +++ b/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml @@ -1,7 +1,6 @@ @@ -139,15 +138,28 @@ - - + + + + + + + + + + + + + diff --git a/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml.cs index e5edc5d..7efcc15 100644 --- a/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/Detail/WorkConsole.axaml.cs @@ -1,8 +1,40 @@ +using System; +using System.Collections.Specialized; using Avalonia.Controls; +using ClaudeDo.Ui.ViewModels.Islands; namespace ClaudeDo.Ui.Views.Islands.Detail; public partial class WorkConsole : UserControl { - public WorkConsole() => InitializeComponent(); + private INotifyCollectionChanged? _log; + + public WorkConsole() + { + InitializeComponent(); + DataContextChanged += OnDataContextChanged; + } + + private void OnDataContextChanged(object? sender, EventArgs e) + { + if (_log is not null) + _log.CollectionChanged -= OnLogChanged; + + _log = (DataContext as DetailsIslandViewModel)?.Log; + + if (_log is not null) + _log.CollectionChanged += OnLogChanged; + } + + private void OnLogChanged(object? sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action != NotifyCollectionChangedAction.Add) return; + EventHandler? handler = null; + handler = (_, _) => + { + LogScroll.LayoutUpdated -= handler; + LogScroll.ScrollToEnd(); + }; + LogScroll.LayoutUpdated += handler; + } }