-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Refactor history_cell for clarity, intent, and safety #7079
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
base: main
Are you sure you want to change the base?
Conversation
- Reorganized history cells into dedicated modules, moving factory constructors alongside implementations so mod.rs mostly re-exports shared helpers. - Documented every cell and method with clear intent: where it appears, what it shows, how it renders (styling, wrapping, padding), plus # Output examples to convey expected layout without reading code. - Added comprehensive characterization tests and aligned insta snapshots per cell, using realistic data and wrapped/unwrapped scenarios to protect rendering behavior during future changes. - Ran fmt and scoped clippy fixes; cargo test -p codex-tui passes with updated snapshots.
| /// `Vec<Line<'static>>` representation to make it easier to display in a | ||
| /// scrollable list. | ||
| pub(crate) trait HistoryCell: std::fmt::Debug + Send + Sync + Any { | ||
| /// Render this cell into a set of display lines for the on-screen history panel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid adding the term "panel"?
| mod web_search; | ||
|
|
||
| pub(crate) use agent::AgentMessageCell; | ||
| #[expect(unused_imports)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all the unused imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The factory methods return these (fn new_foo() -> XxxCell) so they need to be exported, but they're not actually used anywhere as the types. This seems like a weird edge case in the way that clippy detects used imports. I've marked these as expected rather than allow so that if this bug is fixed we can just remove the attribute.
| /// The width is the available area in the history list. Implementations should wrap or | ||
| /// truncate as needed so callers can drop the result directly into a `Paragraph`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
| .unwrap_or(0) | ||
| } | ||
|
|
||
| /// Render this cell into a set of lines suitable for transcript export. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"export" is a weird word to use here
| /// The default implementation matches `display_lines`, but cells can opt in to returning | ||
| /// additional context or omit styling-only padding when exporting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The default implementation matches `display_lines`, but cells can opt in to returning | |
| /// additional context or omit styling-only padding when exporting. | |
| /// The default implementation matches `display_lines`, but cells can opt in to returning | |
| /// a different rendering for transcript mode. |
This is a prepatory refactor, with added characterization tests and documentation of the history cells code.
It prepares the code so that we can start more easily and safely making changes to the way these cells are rendered, and catch any regressions in the snapshots, tests etc.