hex/src/developer_control.rs
Kit Langton d6d83598e3 refactor(app_window): own OpenCode unavailable copy and reuse developer enums for previews and the dev CLI
OpenCodeUnavailableCopy stores its bounded error as a String so
render_mode_detail keeps the struct instead of flattening it into a
six-tuple, and both surfaces build their retry/setup buttons through one
opencode_unavailable_actions helper.

DeveloperHudState and DeveloperPane derive clap::ValueEnum, replacing
the 1:1 DevHudState, DevPane, and PreviewPane copies plus their mapping
matches. AppWindowPreview now carries a DeveloperPane directly. As a
side effect, 'hex dev show history' is accepted; Pane::from_developer
already handled it.
2026-09-22 14:37:41 -07:00

64 lines
1.4 KiB
Rust

use std::sync::mpsc::SyncSender;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, clap::ValueEnum)]
#[serde(rename_all = "kebab-case")]
pub enum DeveloperHudState {
Reset,
Recording,
Transcribing,
Processing,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, clap::ValueEnum)]
#[serde(rename_all = "kebab-case")]
pub enum DeveloperPane {
Settings,
Modes,
VoiceAction,
Replacements,
History,
HudLab,
Commands,
Meetings,
Activity,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "command", rename_all = "kebab-case")]
pub enum DeveloperCommand {
Status,
Hud { state: DeveloperHudState },
ShowPane { pane: DeveloperPane },
SetCommandsEnabled { enabled: bool },
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "status", rename_all = "kebab-case")]
pub enum DeveloperReply {
Ok,
State {
window_open: bool,
pane: Option<DeveloperPane>,
commands_enabled: bool,
},
Error {
code: String,
message: String,
},
}
pub struct DeveloperCall {
pub command: DeveloperCommand,
pub reply: SyncSender<DeveloperReply>,
}
impl DeveloperReply {
pub fn error(code: impl Into<String>, message: impl Into<String>) -> Self {
Self::Error {
code: code.into(),
message: message.into(),
}
}
}