mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
## What changed - Introduce an async-question editor component with per-question drafts, navigation, replay deduplication, and submit or queue handling using the shared composer. - Add bounded `AnsweredQuestion` framing that truncates question text at a UTF-8 boundary and flattens line breaks before prepending it to an answer. - Add `prompt_stack_back` and `skip_question` keybinding actions and the `tui.question_esc_back` setting. Normalize `Ctrl+]` and `Ctrl+5` for key matching and conflict detection, and let default question shortcuts yield to explicit bindings. - Flush buffered typing in both the main composer and the covering view so background input cannot keep the draw loop waiting. The async-question component is not yet connected to the TUI event flow. ## Testing Add regression coverage for bounded Unicode question framing, question-shortcut conflicts, and paste-buffer flushing in background and covering editors. GitOrigin-RevId: 4098043cf588ddafc05c27505645495edd690cb9
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
//! Bounded question framing accompanying an explicitly submitted user answer.
|
|
|
|
use super::ContextualUserFragment;
|
|
use codex_protocol::models::ContentItemKind;
|
|
|
|
/// Identifies an answered question without repeating an unbounded model-authored prompt.
|
|
pub struct AnsweredQuestion {
|
|
question: String,
|
|
}
|
|
|
|
impl AnsweredQuestion {
|
|
pub fn new(question: &str) -> Self {
|
|
let end = question.floor_char_boundary(question.len().min(512));
|
|
Self {
|
|
question: question[..end].to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ContextualUserFragment for AnsweredQuestion {
|
|
fn content_kind(&self) -> ContentItemKind {
|
|
ContentItemKind("user.answered_question".into())
|
|
}
|
|
fn role(&self) -> &'static str {
|
|
"user"
|
|
}
|
|
fn markers(&self) -> (&'static str, &'static str) {
|
|
Self::type_markers()
|
|
}
|
|
fn type_markers() -> (&'static str, &'static str) {
|
|
("", "")
|
|
}
|
|
fn body(&self) -> String {
|
|
format!("> {}\n\n", self.question.replace(['\n', '\r'], " "))
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "answered_question_tests.rs"]
|
|
mod tests;
|