Skip to content

refactor(ui): unify terminal rendering and component primitives#159

Open
fcoury-oai wants to merge 4 commits into
masterfrom
fcoury/ui-unification
Open

refactor(ui): unify terminal rendering and component primitives#159
fcoury-oai wants to merge 4 commits into
masterfrom
fcoury/ui-unification

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Why

Red's dialogs, floating and docked composers, pickers, completions, panels, overlays, and plugin workspaces independently implemented prompt editing, action hints, scrolling, geometry, icons, Unicode clipping, and frame rendering. That duplication made narrow terminals, theme changes, streamed content, and document-aware highlighting inconsistent and difficult to maintain.

What changed

  • Introduce concrete shared UI primitives: a real rope-backed PromptBuffer, responsive UiAction/ActionBar, selection and follow-tail viewports, half-open ScreenRect geometry, Markdown rich-text painting, and a centralized icon catalog.
  • Migrate floating composers, docked panel composers, single-line input, picker selection, LSP completions, plugin workspaces, and file icons onto the appropriate shared primitive without introducing a general-purpose widget framework.
  • Keep the floating composer deliberately right-aligned so code remains visible on the left; preserve multiline editing, Vim modes, grapheme-aware cursor movement, undo/redo, prompt history, and Ctrl+Enter submission.
  • Recompose visible overlays on every frame and route incremental edits through the existing document-aware window renderer so overlays and multiline syntax highlighting remain correct.
  • Unify themed dialog and popup frames, responsive action hints, rounded completion borders, grapheme-safe truncation, and splash-screen display-width calculations.
  • Verify the plugin host API against runtime dispatch in both directions and document component ownership and intentionally separate follow-up work in docs/UI_ARCHITECTURE.md.

This is a standalone UI refactor based directly on master. It contains no parallel-agent foundation commits, agent-workspace backend, worktree or checkpoint changes, or plugin host-contract expansion.

How to Test

  1. Exercise the shared components and the sensitive agent-composer regression:

    cargo test --lib ui::
    cargo test -p red --lib agent_composer_never_uses_picker_history_or_records_prompt_input
    cargo test --lib runtime_dispatch_is_covered_by_the_machine_readable_schema

    Expected: prompt history, Unicode editing, responsive actions, picker/completion behavior, right-aligned composer geometry, Ctrl+Enter submission, and bidirectional plugin-schema parity all pass.

  2. Run the complete workspace and repository quality gates:

    cargo fmt --check
    cargo test --workspace --all-targets --all-features
    cargo clippy --all-targets --all-features -- -D warnings

    Expected: all workspace tests pass and formatting and Clippy report no warnings or errors.

  3. Open the floating agent composer, enter a multiline Unicode draft, resize the terminal, and submit using Ctrl+Enter.

    Expected: Enter inserts a newline, the composer remains right-aligned, the editor remains visible on the left, and the exact draft is submitted without leaking into picker history.

  4. Scroll upward in a streaming text panel and resize the editor while an overlay is visible.

    Expected: new transcript content does not interrupt manual scroll position, complete Unicode graphemes remain visible, and the overlay persists across subsequent rendered frames.

@fcoury
fcoury force-pushed the fcoury/ui-unification branch from 1755609 to 43a70c8 Compare July 26, 2026 22:33
@fcoury-oai fcoury-oai changed the title feat(agent): unify parallel workspaces and terminal ui primitives refactor(ui): unify terminal rendering and component primitives Jul 26, 2026
@fcoury

fcoury commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43a70c8b92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugin/panel.rs Outdated
@fcoury

fcoury commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2fe8e6e79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor/rendering.rs
Comment thread src/editor/rendering.rs Outdated
Comment thread src/ui/prompt_buffer.rs Outdated
@fcoury

fcoury commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5df142d8a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ui/agent_composer.rs Outdated
@fcoury

fcoury commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23b9485082

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor/rendering.rs
Comment on lines +457 to +459
let rows = (0..self.window_content_height(&window))
.map(|row| self.window_to_terminal_y(&window, row))
.collect::<Vec<_>>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid repainting the full viewport before the final frame

For ordinary edit events in EventRenderMode::Immediate, this now renders every visible row of the active window, but render_edited_window_rows neither flushes a frame nor advances render_generation. Consequently, process_editor_event still calls self.render(buffer) at src/editor.rs:7549-7552, repainting the viewport again after every inserted or deleted character. This changes the prior one-row prepaint into an extra full syntax-highlighted viewport pass and can noticeably increase input latency in large panes or expensive documents; either limit this prepaint to affected rows or make it satisfy the event's final render.

Useful? React with 👍 / 👎.

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.

2 participants