feat(editor-core): wire CodegenState onto EditorState

Add pending_generate + pending_regenerate flags to CodegenState
(mirror of chat.pending_send). Wire codegen: CodegenState as a
field on EditorState immediately after chat, with TDD coverage in
codegen_state_defaults_to_idle_react.
This commit is contained in:
Kayshen-X 2026-06-07 15:16:40 +08:00
parent 59776bf232
commit 041cfc4de6
2 changed files with 15 additions and 0 deletions

View file

@ -123,6 +123,11 @@ pub struct CodegenState {
pub error: Option<String>,
/// Frame at which "Copied" was shown, to time the transient label.
pub copied_at: Option<u64>,
/// Set by the Code panel's Generate action; drained by the host codegen
/// session (P3). Mirror of `chat.pending_send`.
pub pending_generate: bool,
/// Set by Regenerate; drained by the host codegen session (P3).
pub pending_regenerate: bool,
}
impl Default for CodegenState {
@ -137,6 +142,8 @@ impl Default for CodegenState {
selection_snapshot: Vec::new(),
error: None,
copied_at: None,
pending_generate: false,
pending_regenerate: false,
}
}
}
@ -166,5 +173,7 @@ mod tests {
assert!(s.code.is_empty());
assert!(!s.degraded);
assert!(s.error.is_none());
assert!(!s.pending_generate);
assert!(!s.pending_regenerate);
}
}

View file

@ -40,6 +40,7 @@
//! constructor is provided so the type is usable + testable.
use crate::chat::ChatState;
use crate::codegen::CodegenState;
use crate::components::ComponentLibrary;
use crate::editor_ui_state::EditorUiState;
use crate::history::History;
@ -81,6 +82,10 @@ pub struct EditorState {
/// AI chat sub-state — message transcript, input draft, panel
/// anchor, model catalog. Mirrors shell-core's `Document.chat`.
pub chat: ChatState,
/// Code-generation sub-state — framework selection, phase,
/// progress, generated code, and pending-action flags. Read by
/// the Code panel painter; drained by the host codegen session.
pub codegen: CodegenState,
/// Component library — reusable design-system subtrees. Mirrors
/// shell-core's `Document.components`.
pub components: ComponentLibrary,
@ -108,6 +113,7 @@ impl EditorState {
ui: UiDraftState::new(),
editor_ui: EditorUiState::new(),
chat: ChatState::default(),
codegen: CodegenState::default(),
components,
ui_kits: crate::uikit::builtin_kits(),
}