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
28 changes: 28 additions & 0 deletions PolyPilot.Tests/ReflectionCycleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -862,4 +862,32 @@ public void EvaluatorFeedback_NullOnPass()
Assert.Null(cycle.EvaluatorFeedback);
Assert.True(cycle.GoalMet);
}

[Theory]
[InlineData("fix the bug --max 10", 10, "fix the bug")]
[InlineData("fix the bug \u2014max 10", 10, "fix the bug")] // em-dash (macOS auto-substitution)
[InlineData("fix the bug --max 50", 50, "fix the bug")]
[InlineData("--max 20 fix the bug", 20, "fix the bug")]
[InlineData("\u2014max 20 fix the bug", 20, "fix the bug")] // em-dash at start
[InlineData("fix the bug", 5, "fix the bug")] // no --max, default
[InlineData("fix the bug --max 200", 200, "fix the bug")] // no upper bound
[InlineData("fix the bug --max 9999", 9999, "fix the bug")] // unlimited
[InlineData("fix the bug --max 0", 5, "fix the bug")] // zero keeps default
[InlineData("fix the bug --max 1", 1, "fix the bug")] // minimum valid
[InlineData("fix --max 3 the bug", 3, "fix the bug")] // mid-goal placement
public void ParseMaxIterations_HandlesVariousFormats(string arg, int expectedMax, string expectedGoal)
{
int maxIterations = 5;
var goal = arg;
var maxMatch = System.Text.RegularExpressions.Regex.Match(arg, @"(?:--|—|\u2014)max\s+(\d+)");
if (maxMatch.Success)
{
if (int.TryParse(maxMatch.Groups[1].Value, out var parsed) && parsed > 0)
maxIterations = parsed;
goal = arg.Remove(maxMatch.Index, maxMatch.Length).Trim();
}

Assert.Equal(expectedMax, maxIterations);
Assert.Equal(expectedGoal, goal);
}
}
1 change: 1 addition & 0 deletions PolyPilot/Components/ExpandedSessionView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<input type="file" id="file-@Session.Name.Replace(" ", "-")" accept="image/*" multiple style="display:none" />
<textarea id="input-@Session.Name.Replace(" ", "-")"
data-fiesta-workers="@FiestaAutocompleteWorkers"
autocorrect="off" autocapitalize="off" spellcheck="false"
placeholder="@(Session.IsProcessing ? "Message will be queued…" : PlatformHelper.IsMobile ? "Message..." : "Message... (↵ send, ⇧↵ newline)")"
rows="1"></textarea>
<button class="attach-btn" @onclick="() => OnAttach.InvokeAsync(Session.Name)" title="Attach image">
Expand Down
8 changes: 4 additions & 4 deletions PolyPilot/Components/Pages/Dashboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@
"**Usage:**\n" +
"```\n" +
"/reflect <goal> Start a cycle (default 5 iterations)\n" +
"/reflect <goal> --max N Set max iterations (1-100)\n" +
"/reflect <goal> --max N Set max iterations (default 5)\n" +
"/reflect stop Cancel active cycle\n" +
"/reflect pause Pause without cancelling\n" +
"/reflect resume Resume paused cycle\n" +
Expand All @@ -1558,14 +1558,14 @@
return;
}

// Parse --max N from the goal text
// Parse --max N from the goal text (accept em-dash — which macOS auto-substitutes for --)
int maxIterations = 5;
var goal = arg;
var maxMatch = System.Text.RegularExpressions.Regex.Match(arg, @"--max\s+(\d+)");
var maxMatch = System.Text.RegularExpressions.Regex.Match(arg, @"(?:--|—|\u2014)max\s+(\d+)");
if (maxMatch.Success)
{
if (int.TryParse(maxMatch.Groups[1].Value, out var parsed) && parsed > 0)
maxIterations = Math.Min(parsed, 100);
maxIterations = parsed;
goal = arg.Remove(maxMatch.Index, maxMatch.Length).Trim();
}

Expand Down
1 change: 1 addition & 0 deletions PolyPilot/Components/SessionCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@

<div class="card-input">
<input type="text" id="input-@Session.Name.Replace(" ", "-")"
autocorrect="off" autocapitalize="off" spellcheck="false"
placeholder="@(Session.IsProcessing ? "Queue a message…" : $"Send to {Session.Name}...")"
@onkeyup="HandleInputKeyUp" />
@if (Session.IsProcessing)
Expand Down