-
Notifications
You must be signed in to change notification settings - Fork 1
chore: sync public mirror from internal #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Shared Dex Code presentation | ||
|
|
||
| The native TUI and lightweight workbench use these same renderers. Inputs are | ||
| borrowed presentation values; the application keeps execution, approvals, queue | ||
| semantics, preferences, and persistence. | ||
|
|
||
| ## Composer | ||
|
|
||
| `components::composer::Composer` borrows the existing `maestro_ui::textarea::TextArea`, | ||
| preformatted queue rows, completion text, runtime footer, and a `UiTheme`. | ||
| Use `cursor_pos(area)` to place the terminal cursor. Rendering uses that same | ||
| viewport and keeps the cursor's wrapped row visible when the terminal shrinks. | ||
| Queue previews reserve an editor row and disclose clipping. | ||
|
|
||
| The existing TUI textarea path re-exports this editor for compatibility. Its | ||
| paste folding preserves original submitted bytes. Callers using `TextAreaWidget` | ||
| directly can supply a wrapped-row offset with `scroll(rows)`. | ||
|
|
||
| ## Tool result | ||
|
|
||
| `components::tool_result::ToolResult` receives a typed `ToolPhase`, summary, | ||
| arguments, bounded output, optional truncation notice, and explicit expansion. | ||
| The native adapter remains responsible for tool summaries and output limits. | ||
| Execution identities appear in expanded details. Compact results show five | ||
| content rows and a remaining-line count; expanded results preserve blank rows | ||
| and show up to fifty output rows. Upstream truncation remains visible. | ||
|
|
||
| Use `lines(width)` for transcript composition or `height(width)` and `Widget` | ||
| for direct rendering. Measurement and rendering share the same layout. | ||
| Never derive success or permission from output text or a visual style. | ||
|
|
||
| ## Adding a state | ||
|
|
||
| 1. Reuse a production widget and pass values from the existing application owner. | ||
| 2. Add a named example to `ui-preview-rs/src/conversation.rs` for each relevant state. | ||
| 3. Test observable boundaries: cursor visibility, clipping, output disclosure, and status. | ||
| 4. Run the focused preview command, then the full catalog and native capture cases. | ||
|
|
||
| `cargo test -p maestro-presentation -p maestro-ui -p maestro-ui-preview --locked` | ||
| runs the lightweight component tests. The workbench README has gallery commands. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| //! Shared composer. Editing and queue effects remain with the caller. | ||
| use maestro_ui::{ | ||
| UiTheme, | ||
| textarea::{TextArea, TextAreaWidget}, | ||
| }; | ||
| use ratatui::{ | ||
| buffer::Buffer, | ||
| layout::{Alignment, Rect}, | ||
| style::Style, | ||
| text::Line, | ||
| widgets::{Block, Borders, Paragraph, Widget}, | ||
| }; | ||
|
|
||
| pub const PROMPT_WIDTH: u16 = 2; | ||
|
|
||
| /// Borrow the real editor and preformatted queue rows, rather than copying state. | ||
| pub struct Composer<'a> { | ||
| pub editor: &'a TextArea, | ||
| pub queued: &'a [Line<'static>], | ||
| pub busy: bool, | ||
| pub footer: Option<&'a str>, | ||
| pub completion: Option<&'a str>, | ||
| pub theme: UiTheme, | ||
| } | ||
|
|
||
| impl Composer<'_> { | ||
| fn inner(area: Rect) -> Rect { | ||
| Rect::new( | ||
| area.x.saturating_add(1), | ||
| area.y.saturating_add(1), | ||
| area.width.saturating_sub(2), | ||
| area.height.saturating_sub(2), | ||
| ) | ||
| } | ||
|
|
||
| fn queue_height(&self, area: Rect) -> u16 { | ||
| (self.queued.len().min(u16::MAX as usize) as u16) | ||
| .min(Self::inner(area).height.saturating_sub(1)) | ||
| } | ||
|
|
||
| /// The exact viewport used by rendering and terminal cursor placement. | ||
| pub fn editor_area(&self, area: Rect) -> Rect { | ||
| let inner = Self::inner(area); | ||
| let queued = self.queue_height(area); | ||
| Rect::new( | ||
| inner.x.saturating_add(PROMPT_WIDTH), | ||
| inner.y.saturating_add(queued), | ||
| inner.width.saturating_sub(PROMPT_WIDTH), | ||
| inner.height.saturating_sub(queued), | ||
| ) | ||
| } | ||
|
|
||
| pub fn cursor_pos(&self, area: Rect) -> Option<(u16, u16)> { | ||
| if area.width < 3 || area.height < 3 { | ||
| return None; | ||
| } | ||
| let editor = self.editor_area(area); | ||
| if self.editor.is_empty() { | ||
| let inner = Self::inner(area); | ||
| return Some(( | ||
| inner | ||
| .x | ||
| .saturating_add(PROMPT_WIDTH - 1) | ||
| .min(area.right() - 1), | ||
| editor.y, | ||
| )); | ||
| } | ||
| if editor.is_empty() { | ||
| return None; | ||
| } | ||
| let (row, col) = self.editor.cursor_line_col(editor.width)?; | ||
| let scroll = row | ||
| .saturating_add(1) | ||
| .saturating_sub(usize::from(editor.height)); | ||
| Some(( | ||
| editor.x + col.min(editor.width - 1), | ||
| editor.y + (row - scroll) as u16, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| impl Widget for Composer<'_> { | ||
| fn render(self, area: Rect, buf: &mut Buffer) { | ||
| let area = area.intersection(buf.area); | ||
| if area.is_empty() { | ||
| return; | ||
| } | ||
| let theme = self.theme.on_panel(); | ||
| Block::default() | ||
| .borders(Borders::TOP) | ||
| .border_style(Style::default().fg(if self.busy { theme.muted } else { theme.border })) | ||
| .style(Style::default().bg(theme.surface)) | ||
| .render(area, buf); | ||
| if area.height < 3 || area.width < 3 { | ||
| return; | ||
| } | ||
| let inner = Self::inner(area); | ||
| let queued = self.queue_height(area); | ||
| if queued > 0 { | ||
| let mut lines = self.queued[..usize::from(queued)].to_vec(); | ||
| if self.queued.len() > usize::from(queued) { | ||
| lines[usize::from(queued) - 1] = | ||
| Line::styled("… more queued input", Style::default().fg(theme.muted)); | ||
| } | ||
| Paragraph::new(lines).render( | ||
| Rect { | ||
| height: queued, | ||
| ..inner | ||
| }, | ||
| buf, | ||
| ); | ||
| } | ||
| let editor = self.editor_area(area); | ||
| buf.set_stringn( | ||
| inner.x, | ||
| editor.y, | ||
| "> ", | ||
| usize::from(inner.width), | ||
| Style::default().fg(theme.focus), | ||
| ); | ||
| if !editor.is_empty() { | ||
| let scroll = self | ||
| .editor | ||
| .cursor_line_col(editor.width) | ||
| .map_or(0, |(row, _)| { | ||
| row.saturating_add(1) | ||
| .saturating_sub(usize::from(editor.height)) | ||
| }); | ||
| TextAreaWidget::new(self.editor) | ||
| .scroll(scroll) | ||
| .style(Style::default().fg(theme.text)) | ||
| .render(editor, buf); | ||
| if let (Some(completion), Some((x, y))) = (self.completion, self.cursor_pos(area)) { | ||
| let x = x.max(editor.x); | ||
| buf.set_stringn( | ||
| x, | ||
| y, | ||
| completion, | ||
| usize::from(editor.right().saturating_sub(x)), | ||
| Style::default().fg(theme.muted), | ||
| ); | ||
| } | ||
| } | ||
| if let Some(footer) = self.footer { | ||
| Paragraph::new(footer) | ||
| .style(Style::default().fg(theme.muted)) | ||
| .alignment(Alignment::Right) | ||
| .render(Rect::new(inner.x, area.bottom() - 1, inner.width, 1), buf); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.