Skip to content

[CLI] Rebuild the TUI suggestion editor with Hex1b widgets - #1522

Open
Mitch Denny (mitchdenny) wants to merge 6 commits into
Azure:mainfrom
mitchdenny:mitchdenny-hex1b-suggestion-editor
Open

Mitch Denny (mitchdenny) wants to merge 6 commits into
Azure:mainfrom
mitchdenny:mitchdenny-hex1b-suggestion-editor

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Nov 26, 2026 •

Copy link
Copy Markdown

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 49ef80f40fb938b250f44da51ece24718248c433

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Debug solution build, Release Tui.Tests build and all 28 Tui.Tests pass (automator-driven, isolated temp history), including nine new anchor cases across sizes, panels, suggestion counts and input shapes.
↑ Real PTY at 60×18, 80×24 and 120×40 reproduced 1–4 blank rows below the input on the previous revision; at this revision input sits directly above the bottom separator with 0, few and many suggestions.
↑ Wrapped input stays flush with the separator while growing and shrinking; focus stays on input after the first submission replaces the welcome panel.
↓ Ctrl+Enter could not be injected via PTY, so multiline layout is verified only headlessly.
↓ Live Azure path completion and the full test suite were not run.

Related command

Azclips TUI command entry

Description

Builds on #1521 and includes its Hex1b 0.176.0 upgrade commit. This PR targets upstream Azure/azclips:main, not the dependency branch; the original branch remains unchanged.

Replace SuggestionRenderer.Render with Build, returning a VStack containing a native controlled List above a TextBox configured with Predict. Up/Down transfer focus and navigate suggestions; crossing the list boundary or pressing Escape returns focus to input. Right Arrow completes the selected or first available suggestion at the end of input, while retaining ordinary cursor movement elsewhere. Tab/Enter accept a selected suggestion; Enter otherwise submits the command. Typing while browsing resumes editing. History, wrapping and Ctrl+Enter multiline entry remain supported.

Clear stale suggestions/selection before asynchronous path lookup and discard results for changed input or mode. Remove the obsolete placement menu because suggestions now always appear above the input.

The input TextBox fills the row width, and the inline prediction is dropped for one frame after programmatic edits (submit, history recall, completion), because Hex1b 0.176.0 refreshes predictions only on typed input. Without that frame, stale ghost text would remain. Inline predictions are single-line only, so wrapped or multiline commands use list-based completion.

Keep the editor immediately above the bottom separator, with suggestions growing upward. Hex1b's content measurement reserves at least one row for an empty List and measures all items even when its arranged height is capped at eight. The enclosing stack now uses the displayed list rows plus actual wrapped/multiline input rows, and the input row uses its actual height, eliminating the unused space without padding or spacer widgets.

Add a dedicated tests/Tui.Tests project, which receives InternalsVisibleTo instead of Cli.Tests. The TUI tests move there and are rewritten to drive input with Hex1bTerminalAutomator through a TuiTestApp headless fixture. A single-widget SuggestionRenderer example is also added. HistoryService accepts an optional directory so tests never read or write the user's real history. A new tui-testing skill documents the approach.

Testing Guide

  • Passed: dotnet build azclips.slnx -v:q (0 errors).
  • Passed: dotnet test tests/Tui.Tests/Tui.Tests.csproj (28 tests).
  • Passed: dotnet build tests/Tui.Tests/Tui.Tests.csproj -c Release -v:q (0 errors; signed build used by CI).
  • Passed: real pseudo-terminal runs (pexpect + pyte) at 60×18, 80×24 and 120×40. The previous revision left 1 blank row below the input with no suggestions and 3–4 rows with many. At this revision, input sits directly above the bottom separator for empty, few, many and no-match suggestion states, after backspacing, and for wrapped input growing to 3 rows and shrinking back. Focus stays on input after the first submission swaps the welcome panel for history.
  • Headless only: multiline (Ctrl+Enter) layout and help-panel layout, covered by the new anchor theory; Ctrl+Enter could not be injected through the PTY.
  • Earlier pseudo-terminal runs verified inline prediction while typing; Up/Down list focus and selection; Esc focus return; Right Arrow completion and ordinary cursor movement; editing after completion; Enter submission matching the base branch; history recall without stale ghost text.
  • Not run: live Azure path completion; full test suite.

History Notes

[CLI] TUI: Navigate native suggestions above command input and accept completions with Right Arrow


  • The PR title starts with [Component Name] for customer-facing changes or {Component Name} for non-customer-facing changes, and does not end with trailing punctuation or spaces.
  • Customer-facing changes include a useful release note in the PR title or the History Notes section.
  • I added or updated tests for behavior changes.
  • I updated documentation when behavior, setup, support, or security guidance changed.

Migrate to the split WithHex1bApp(options, app => ...) overload; the
combined (app, options) callback was removed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 08:42
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
6 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Stale asynchronous path lookups can overwrite newer suggestions, and pressing Space after selecting a suggestion activates it instead of resuming editing.

2 open issues
What changed in this PR

Rebuilds Azclips’ TUI command editor with native Hex1b widgets, incorporating the Hex1b 0.176.0 upgrade from #1521.

Changes:

  • Places a native suggestion list above the editor, with keyboard focus navigation, completion, and prediction support.
  • Adds asynchronous suggestion filtering and preserves history, wrapping, and multiline entry.
  • Removes suggestion-placement controls, updates keyboard help, and adds editor interaction tests.
File Description
TUI/​Rendering/​SuggestionRenderer.cs Builds the native suggestion list and prediction-enabled text editor.
TUI/​Rendering/​MenuBarRenderer.cs Removes the obsolete suggestion-placement menu.
TUI/​Rendering/​HelpRenderer.cs Documents completion, focus navigation, and multiline shortcuts.
TUI/​Program.cs Integrates the editor, updates focus and key handling, and adjusts line counting.
TUI/​Core.Tui.csproj Upgrades Hex1b to 0.176.0.
TUI/​AppState.cs Adds prediction and completion helpers plus asynchronous result filtering.
tests/​Cli.Tests/​TuiSuggestionEditorTests.cs Adds headless tests for navigation, acceptance, editing, and history.

Review effort: Balanced

Comment thread TUI/AppState.cs
Comment on lines +204 to +205
if (InputText == input && Mode == mode)
OnAsyncSuggestions(suggestions);
Comment on lines +31 to +39
.InputBindings(bindings => bindings.AnyCharacter().Action((text, _) =>
{
state.EditorState.HandleInput(new Hex1bKeyEvent(
Hex1bKey.None, text, Hex1bModifiers.None));
state.UpdateSuggestions();
app.RequestFocus(n => n is TextBoxNode);
app.Invalidate();
return Task.CompletedTask;
}, "Resume editing"))
Make the suggestion TextBox fill the row so completed text is not
horizontally scrolled, and drop the predictor for one frame after
programmatic edits so stale inline predictions are cleared.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Completion lookups can publish stale results after repeated input or working-directory changes, overwriting suggestions and selections, while mode switches can leave stale inline predictions visible.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Clear cached inline predictions when mode or suggestions change

TUI/​Rendering/​SuggestionRenderer.cs:56

Pressing F2 after typing an Azure command prefix can leave its inline prediction visible in Local mode even when the new suggestion list is empty, because TypedInputText still equals InputText. The PR's stated Hex1b 0.176.0 behavior is consistent with upstream default-branch reconciliation, which clears cached predictions only when the handler is removed. Track mode and suggestion revision alongside the input text, and clear the cached prediction when that context changes without a typed edit.

Review effort: Balanced

Size the editor stack from its displayed suggestion rows and wrapped input rows, avoiding List's uncapped content measurement and empty-list row reservation. Cover list growth and multiline input across terminal sizes and output panels.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved bugs can flatten multiline pastes, accept stale completions, block editing from the suggestion list, and let outdated suggestion requests disrupt focus.

2 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Forward editing keys and paste from the suggestion list

TUI/​Rendering/​SuggestionRenderer.cs:37

After typing /p and pressing Down, Space accepts /pwd instead of resuming editing because the native List binds Space to activation (default-branch source, also confirmed in 0.176.0). Backspace, Delete, Left Arrow and paste also fail to reach the sibling TextBox. Override Space and forward editing keys with their modifiers and paste to the editor, restoring input focus and refreshing suggestions after edits.

Medium severity Preserve line breaks when pasting into a single-line editor

TUI/​Rendering/​SuggestionRenderer.cs:52

An empty or short editor is single-line, so pasting echo one\necho two changes it to echo one echo two. Hex1b normalizes the newlines before OnTextChanged (confirmed in 0.176.0; default-branch implementation). Add an explicit paste handler that preserves line breaks and replaces the selection, and cover this case with a regression test.

Medium severity Clear stale ghost text when suggestion context changes

TUI/​Rendering/​SuggestionRenderer.cs:58

Type g in Azure mode, wait for the group prediction, then press F2 with no matching local history: the suggestions clear but the ghost text remains. Right Arrow can then accept that stale completion because replacing a non-null predictor does not clear Hex1b's cache (confirmed in 0.176.0; default-branch source). Track mode and suggestion-context changes as well as text, and omit the predictor for a frame when that context changes.

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A superseded completion request can still overwrite newer suggestions and reset the active selection because matching text and mode does not uniquely identify the current request.

2 open issues

Review effort: Balanced

Moves TUI tests out of Cli.Tests into a dedicated project driven by
Hex1bTerminalAutomator, makes the HistoryService directory injectable so
tests use isolated history, and adds a tui-testing skill.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Completion requests lack generation-based invalidation, allowing stale callbacks to overwrite or clear current suggestions, while pending lookups can leave inline predictions blank.

3 open issues

Review effort: Balanced

widgets.Add(inner.Text($" {Ansi.AccentPurple}▸ {s.Text,-28}{Ansi.End} {Ansi.Foreground}{s.Description}{Ansi.End}"));
else
widgets.Add(inner.Text($" {Ansi.Comment} {s.Text,-28} {s.Description}{Ansi.End}"));
editor = editor.Predict((text, _) => Task.FromResult(state.GetPrediction(text)));
@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

/azp run azclips-alpha-build

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants