Manage global shortcuts (#635)
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-01-24 20:05:34 +01:00
1 parent c9f037bb2c
commit 127778df42
34 files changed
+1654 -35

No files matched your search

@@ -0,0 +1,3 @@
namespace AIStudio.Tools.Rust;
public sealed record RegisterShortcutRequest(Shortcut Id, string Shortcut);
@@ -0,0 +1,17 @@
namespace AIStudio.Tools.Rust;
/// <summary>
/// Identifies a global keyboard shortcut.
/// </summary>
public enum Shortcut
{
/// <summary>
/// Null pattern - no shortcut assigned or unknown shortcut.
/// </summary>
NONE = 0,
/// <summary>
/// Toggles voice recording on/off.
/// </summary>
VOICE_RECORDING_TOGGLE,
}
@@ -0,0 +1,3 @@
namespace AIStudio.Tools.Rust;
public sealed record ShortcutResponse(bool Success, string ErrorMessage);
@@ -0,0 +1,3 @@
namespace AIStudio.Tools.Rust;
public sealed record ShortcutValidationResponse(bool IsValid, string ErrorMessage, bool HasConflict, string ConflictDescription);
@@ -0,0 +1,10 @@
namespace AIStudio.Tools.Rust;
/// <summary>
/// Result of validating a keyboard shortcut.
/// </summary>
/// <param name="IsValid">Whether the shortcut syntax is valid.</param>
/// <param name="ErrorMessage">Error message if not valid.</param>
/// <param name="HasConflict">Whether the shortcut conflicts with another registered shortcut.</param>
/// <param name="ConflictDescription">Description of the conflict, if any.</param>
public sealed record ShortcutValidationResult(bool IsValid, string ErrorMessage, bool HasConflict, string ConflictDescription);
@@ -5,4 +5,41 @@ namespace AIStudio.Tools.Rust;
/// </summary>
/// <param name="EventType">The type of the Tauri event.</param>
/// <param name="Payload">The payload of the Tauri event.</param>
public readonly record struct TauriEvent(TauriEventType EventType, List<string> Payload);
public readonly record struct TauriEvent(TauriEventType EventType, List<string> Payload)
{
/// <summary>
/// Attempts to parse the first payload element as a shortcut.
/// </summary>
/// <param name="shortcut">The parsed shortcut name if successful.</param>
/// <returns>True if parsing was successful, false otherwise.</returns>
public bool TryGetShortcut(out Shortcut shortcut)
{
shortcut = default;
if(this.EventType != TauriEventType.GLOBAL_SHORTCUT_PRESSED)
return false;
if (this.Payload.Count == 0)
return false;
// Try standard enum parsing (handles PascalCase and numeric values):
if (Enum.TryParse(this.Payload[0], ignoreCase: true, out shortcut))
return true;
// Try parsing snake_case format (e.g., "voice_recording_toggle"):
return TryParseSnakeCase(this.Payload[0], out shortcut);
}
/// <summary>
/// Tries to parse a snake_case string into a ShortcutName enum value.
/// </summary>
private static bool TryParseSnakeCase(string value, out Shortcut shortcut)
{
shortcut = default;
// Convert snake_case to UPPER_SNAKE_CASE for enum matching:
var upperSnakeCase = value.ToUpperInvariant();
// Try to match against enum names (which are in UPPER_SNAKE_CASE):
return Enum.TryParse(upperSnakeCase, ignoreCase: false, out shortcut);
}
};
@@ -8,11 +8,13 @@ public enum TauriEventType
NONE,
PING,
UNKNOWN,
WINDOW_FOCUSED,
WINDOW_NOT_FOCUSED,
FILE_DROP_HOVERED,
FILE_DROP_DROPPED,
FILE_DROP_CANCELED,
GLOBAL_SHORTCUT_PRESSED,
}
@@ -0,0 +1,3 @@
namespace AIStudio.Tools.Rust;
public sealed record ValidateShortcutRequest(string Shortcut);