mirror of
https://github.com/openai/codex.git
synced 2026-05-01 03:42:05 +03:00
75 lines
2.1 KiB
Rust
75 lines
2.1 KiB
Rust
use codex_core::protocol::Event;
|
|
use codex_file_search::FileMatch;
|
|
use crossterm::event::KeyEvent;
|
|
use ratatui::text::Line;
|
|
use std::time::Duration;
|
|
|
|
use crate::app::ChatWidgetArgs;
|
|
use crate::slash_command::SlashCommand;
|
|
|
|
#[derive(Debug)]
|
|
#[allow(clippy::large_enum_variant)]
|
|
pub(crate) enum AppEvent {
|
|
CodexEvent(Event),
|
|
|
|
/// Request a redraw which will be debounced by the [`App`].
|
|
RequestRedraw,
|
|
|
|
/// Actually draw the next frame.
|
|
Redraw,
|
|
|
|
/// Schedule a one-shot animation frame roughly after the given duration.
|
|
/// Multiple requests are coalesced by the central frame scheduler.
|
|
ScheduleFrameIn(Duration),
|
|
|
|
KeyEvent(KeyEvent),
|
|
|
|
/// Text pasted from the terminal clipboard.
|
|
Paste(String),
|
|
|
|
/// Request to exit the application gracefully.
|
|
ExitRequest,
|
|
|
|
/// Forward an `Op` to the Agent. Using an `AppEvent` for this avoids
|
|
/// bubbling channels through layers of widgets.
|
|
CodexOp(codex_core::protocol::Op),
|
|
|
|
/// Dispatch a recognized slash command from the UI (composer) to the app
|
|
/// layer so it can be handled centrally.
|
|
DispatchCommand(SlashCommand),
|
|
|
|
/// Kick off an asynchronous file search for the given query (text after
|
|
/// the `@`). Previous searches may be cancelled by the app layer so there
|
|
/// is at most one in-flight search.
|
|
StartFileSearch(String),
|
|
|
|
/// Result of a completed asynchronous file search. The `query` echoes the
|
|
/// original search term so the UI can decide whether the results are
|
|
/// still relevant.
|
|
FileSearchResult {
|
|
query: String,
|
|
matches: Vec<FileMatch>,
|
|
},
|
|
|
|
/// Result of computing a `/diff` command.
|
|
DiffResult(String),
|
|
|
|
InsertHistory(Vec<Line<'static>>),
|
|
|
|
StartCommitAnimation,
|
|
StopCommitAnimation,
|
|
CommitTick,
|
|
|
|
/// Onboarding: result of login_with_chatgpt.
|
|
OnboardingAuthComplete(Result<(), String>),
|
|
OnboardingComplete(ChatWidgetArgs),
|
|
|
|
/// Image pasted via Cmd+V (clipboard image attachment).
|
|
AttachImage {
|
|
path: std::path::PathBuf,
|
|
width: u32,
|
|
height: u32,
|
|
format_label: &'static str,
|
|
},
|
|
}
|