Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ public interface ICommandHandler
/// <param name="input">The raw user input string.</param>
/// <param name="session">The current agent session.</param>
/// <returns><see langword="true"/> if this handler handled the input; <see langword="false"/> otherwise.</returns>
bool TryHandle(string input, AgentSession session);
ValueTask<bool> TryHandleAsync(string input, AgentSession session);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ public ModeCommandHandler(AgentModeProvider? modeProvider, IReadOnlyDictionary<s
public string? GetHelpText() => this._modeProvider is not null ? "/mode [plan|execute] (show or switch mode)" : null;

/// <inheritdoc/>
public bool TryHandle(string input, AgentSession session)
public ValueTask<bool> TryHandleAsync(string input, AgentSession session)
{
if (!input.StartsWith("/mode ", StringComparison.OrdinalIgnoreCase) && !input.Equals("/mode", StringComparison.OrdinalIgnoreCase))
{
return false;
return ValueTask.FromResult(false);
}

if (this._modeProvider is null)
{
System.Console.WriteLine("AgentModeProvider is not available.");
return true;
return ValueTask.FromResult(true);
}

string[] parts = input.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (parts.Length < 2)
{
string current = this._modeProvider.GetMode(session);
System.Console.WriteLine($"\n Current mode: {current}\n");
return true;
return ValueTask.FromResult(true);
}

string newMode = parts[1];
Expand All @@ -64,6 +64,6 @@ public bool TryHandle(string input, AgentSession session)
System.Console.ResetColor();
}

return true;
return ValueTask.FromResult(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public TodoCommandHandler(TodoProvider? todoProvider)
public string? GetHelpText() => this._todoProvider is not null ? "/todos (show todo list)" : null;

/// <inheritdoc/>
public bool TryHandle(string input, AgentSession session)
public async ValueTask<bool> TryHandleAsync(string input, AgentSession session)
{
if (!input.Equals("/todos", StringComparison.OrdinalIgnoreCase))
{
Expand All @@ -37,7 +37,7 @@ public bool TryHandle(string input, AgentSession session)
return true;
}

var todos = this._todoProvider.GetAllTodos(session);
var todos = await this._todoProvider.GetAllTodosAsync(session).ConfigureAwait(false);
if (todos.Count == 0)
{
System.Console.WriteLine("\n No todos yet.\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static async Task RunAgentAsync(AIAgent agent, string title, string userP
bool handled = false;
foreach (var handler in commandHandlers)
{
if (handler.TryHandle(userInput, session))
if (await handler.TryHandleAsync(userInput, session).ConfigureAwait(false))
{
handled = true;
break;
Expand Down
Loading
Loading