-
Notifications
You must be signed in to change notification settings - Fork 64
[codex] Improve Companion runtime console #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
35910b8
99dbc5e
459807e
1c38c83
85d04ab
8fa4153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace OpenClaw.Companion.Services; | ||
|
|
||
| public interface IConfirmationDialogService | ||
| { | ||
| Task<bool> ConfirmAsync(string title, string message, string confirmText, string cancelText, CancellationToken cancellationToken); | ||
| } | ||
|
|
||
| public sealed class DenyConfirmationDialogService : IConfirmationDialogService | ||
| { | ||
| public Task<bool> ConfirmAsync(string title, string message, string confirmText, string cancelText, CancellationToken cancellationToken) | ||
| => Task.FromResult(false); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| using Avalonia.Controls; | ||
| using Avalonia.Layout; | ||
| using Avalonia.Threading; | ||
|
|
||
| namespace OpenClaw.Companion.Services; | ||
|
|
||
| public sealed class WindowConfirmationDialogService(Window owner) : IConfirmationDialogService | ||
| { | ||
| public async Task<bool> ConfirmAsync( | ||
| string title, | ||
| string message, | ||
| string confirmText, | ||
| string cancelText, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| if (cancellationToken.IsCancellationRequested) | ||
| return false; | ||
|
|
||
| var dialog = new Window | ||
| { | ||
| Title = title, | ||
| Width = 420, | ||
| SizeToContent = SizeToContent.Height, | ||
| WindowStartupLocation = WindowStartupLocation.CenterOwner, | ||
| CanResize = false | ||
| }; | ||
|
|
||
| var result = false; | ||
| var confirmButton = new Button | ||
| { | ||
| Content = confirmText, | ||
| MinWidth = 96, | ||
| HorizontalContentAlignment = HorizontalAlignment.Center | ||
| }; | ||
| var cancelButton = new Button | ||
| { | ||
| Content = cancelText, | ||
| MinWidth = 96, | ||
| HorizontalContentAlignment = HorizontalAlignment.Center | ||
| }; | ||
|
|
||
| confirmButton.Click += (_, _) => | ||
| { | ||
| result = true; | ||
| dialog.Close(); | ||
| }; | ||
| cancelButton.Click += (_, _) => | ||
| { | ||
| result = false; | ||
| dialog.Close(); | ||
| }; | ||
|
|
||
| dialog.Content = new StackPanel | ||
| { | ||
| Margin = new Avalonia.Thickness(20), | ||
| Spacing = 16, | ||
| Children = | ||
| { | ||
| new TextBlock | ||
| { | ||
| Text = message, | ||
| TextWrapping = Avalonia.Media.TextWrapping.Wrap | ||
| }, | ||
| new StackPanel | ||
| { | ||
| Orientation = Orientation.Horizontal, | ||
| HorizontalAlignment = HorizontalAlignment.Right, | ||
| Spacing = 8, | ||
| Children = { cancelButton, confirmButton } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| using var cancellationRegistration = cancellationToken.Register(() => | ||
| Dispatcher.UIThread.Post(() => | ||
| { | ||
| result = false; | ||
| if (dialog.IsVisible) | ||
| dialog.Close(); | ||
| })); | ||
|
|
||
| await dialog.ShowDialog(owner); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Severity: low 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| return result && !cancellationToken.IsCancellationRequested; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| <Styles xmlns="https://github.com/avaloniaui"> | ||
| <Style Selector="TextBlock.page-title"> | ||
| <Setter Property="FontSize" Value="22" /> | ||
| <Setter Property="FontWeight" Value="SemiBold" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="TextBlock.section-title"> | ||
| <Setter Property="FontSize" Value="15" /> | ||
| <Setter Property="FontWeight" Value="SemiBold" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="TextBlock.muted"> | ||
| <Setter Property="Opacity" Value="0.68" /> | ||
| <Setter Property="FontSize" Value="12" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Border.section-card"> | ||
| <Setter Property="Padding" Value="14" /> | ||
| <Setter Property="CornerRadius" Value="8" /> | ||
| <Setter Property="BorderThickness" Value="1" /> | ||
| <Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseLowBrush}" /> | ||
| <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Border.metric-card"> | ||
| <Setter Property="Padding" Value="12" /> | ||
| <Setter Property="CornerRadius" Value="8" /> | ||
| <Setter Property="BorderThickness" Value="1" /> | ||
| <Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseLowBrush}" /> | ||
| <Setter Property="MinHeight" Value="84" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Border.badge"> | ||
| <Setter Property="CornerRadius" Value="10" /> | ||
| <Setter Property="Padding" Value="8,3" /> | ||
| <Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumBrush}" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="TextBox.monospace"> | ||
| <Setter Property="FontFamily" Value="Consolas, Menlo, monospace" /> | ||
| <Setter Property="FontSize" Value="12" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Button.primary"> | ||
| <Setter Property="FontWeight" Value="SemiBold" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Button.danger"> | ||
| <Setter Property="Background" Value="#a61f1f" /> | ||
| <Setter Property="Foreground" Value="White" /> | ||
| <Setter Property="BorderBrush" Value="#a61f1f" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Border.empty-state"> | ||
| <Setter Property="Padding" Value="24" /> | ||
| <Setter Property="CornerRadius" Value="8" /> | ||
| <Setter Property="BorderThickness" Value="1" /> | ||
| <Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseLowBrush}" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Border.error-banner"> | ||
| <Setter Property="Padding" Value="10" /> | ||
| <Setter Property="CornerRadius" Value="8" /> | ||
| <Setter Property="Background" Value="#3a1515" /> | ||
| <Setter Property="BorderBrush" Value="#ff453a" /> | ||
| <Setter Property="BorderThickness" Value="1" /> | ||
| </Style> | ||
|
|
||
|
|
||
| <Style Selector="Border.error-banner TextBlock"> | ||
| <Setter Property="Foreground" Value="White" /> | ||
| </Style> | ||
| </Styles> | ||
Uh oh!
There was an error while loading. Please reload this page.