Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ session_ttl_hours = 24 # idle session TTL

[reactions]
enabled = true # enable emoji status reactions
tool_display = "compact" # full | compact | none
remove_after_reply = false # remove reactions after reply
```

<details>
<summary>Full reactions config</summary>

```toml
[reactions]
enabled = true
tool_display = "compact"
remove_after_reply = false

[reactions.emojis]
queued = "👀"
thinking = "🤔"
Expand Down
1 change: 1 addition & 0 deletions charts/openab/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ data:

[reactions]
enabled = {{ ($cfg.reactions).enabled | default true }}
tool_display = "{{ ($cfg.reactions).toolDisplay | default "compact" }}"
remove_after_reply = {{ ($cfg.reactions).removeAfterReply | default false }}
{{- if ($cfg.stt).enabled }}
{{- if not ($cfg.stt).apiKey }}
Expand Down
2 changes: 2 additions & 0 deletions charts/openab/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ agents:
# sessionTtlHours: 24
# reactions:
# enabled: true
# toolDisplay: compact # full | compact | none
# removeAfterReply: false
# persistence:
# enabled: true
Expand Down Expand Up @@ -78,6 +79,7 @@ agents:
sessionTtlHours: 24
reactions:
enabled: true
toolDisplay: compact # full | compact | none
removeAfterReply: false
stt:
enabled: false
Expand Down
1 change: 1 addition & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ session_ttl_hours = 24

[reactions]
enabled = true
tool_display = "compact" # full | compact | none
remove_after_reply = false

[reactions.emojis]
Expand Down
138 changes: 112 additions & 26 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ impl<'de> Deserialize<'de> for AllowBots {
"off" | "none" | "false" => Ok(Self::Off),
"mentions" => Ok(Self::Mentions),
"all" | "true" => Ok(Self::All),
other => Err(serde::de::Error::unknown_variant(other, &["off", "mentions", "all"])),
other => Err(serde::de::Error::unknown_variant(
other,
&["off", "mentions", "all"],
)),
}
}
}
Expand Down Expand Up @@ -66,8 +69,12 @@ impl Default for SttConfig {
}
}

fn default_stt_model() -> String { "whisper-large-v3-turbo".into() }
fn default_stt_base_url() -> String { "https://api.groq.com/openai/v1".into() }
fn default_stt_model() -> String {
"whisper-large-v3-turbo".into()
}
fn default_stt_base_url() -> String {
"https://api.groq.com/openai/v1".into()
}

#[derive(Debug, Deserialize)]
pub struct DiscordConfig {
Expand Down Expand Up @@ -110,6 +117,8 @@ pub struct PoolConfig {
pub struct ReactionsConfig {
#[serde(default = "default_true")]
pub enabled: bool,
#[serde(default = "default_tool_display")]
pub tool_display: ToolDisplayMode,
#[serde(default)]
pub remove_after_reply: bool,
#[serde(default)]
Expand All @@ -118,6 +127,14 @@ pub struct ReactionsConfig {
pub timing: ReactionTiming,
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum ToolDisplayMode {
Full,
Compact,
None,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ReactionEmojis {
#[serde(default = "emoji_queued")]
Expand Down Expand Up @@ -152,56 +169,108 @@ pub struct ReactionTiming {

// --- defaults ---

fn default_working_dir() -> String { "/tmp".into() }
fn default_max_sessions() -> usize { 10 }
fn default_ttl_hours() -> u64 { 4 }
fn default_true() -> bool { true }

fn emoji_queued() -> String { "👀".into() }
fn emoji_thinking() -> String { "🤔".into() }
fn emoji_tool() -> String { "🔥".into() }
fn emoji_coding() -> String { "👨‍💻".into() }
fn emoji_web() -> String { "⚡".into() }
fn emoji_done() -> String { "🆗".into() }
fn emoji_error() -> String { "😱".into() }

fn default_debounce_ms() -> u64 { 700 }
fn default_stall_soft_ms() -> u64 { 10_000 }
fn default_stall_hard_ms() -> u64 { 30_000 }
fn default_done_hold_ms() -> u64 { 1_500 }
fn default_error_hold_ms() -> u64 { 2_500 }
fn default_working_dir() -> String {
"/tmp".into()
}
fn default_max_sessions() -> usize {
10
}
fn default_ttl_hours() -> u64 {
4
}
fn default_true() -> bool {
true
}
fn default_tool_display() -> ToolDisplayMode {
ToolDisplayMode::Compact
}

fn emoji_queued() -> String {
"👀".into()
}
fn emoji_thinking() -> String {
"🤔".into()
}
fn emoji_tool() -> String {
"🔥".into()
}
fn emoji_coding() -> String {
"👨‍💻".into()
}
fn emoji_web() -> String {
"⚡".into()
}
fn emoji_done() -> String {
"🆗".into()
}
fn emoji_error() -> String {
"😱".into()
}

fn default_debounce_ms() -> u64 {
700
}
fn default_stall_soft_ms() -> u64 {
10_000
}
fn default_stall_hard_ms() -> u64 {
30_000
}
fn default_done_hold_ms() -> u64 {
1_500
}
fn default_error_hold_ms() -> u64 {
2_500
}

impl Default for PoolConfig {
fn default() -> Self {
Self { max_sessions: default_max_sessions(), session_ttl_hours: default_ttl_hours() }
Self {
max_sessions: default_max_sessions(),
session_ttl_hours: default_ttl_hours(),
}
}
}

impl Default for ReactionsConfig {
fn default() -> Self {
Self {
enabled: true,
tool_display: ToolDisplayMode::default(),
remove_after_reply: false,
emojis: ReactionEmojis::default(),
timing: ReactionTiming::default(),
}
}
}

impl Default for ToolDisplayMode {
fn default() -> Self {
default_tool_display()
}
}

impl Default for ReactionEmojis {
fn default() -> Self {
Self {
queued: emoji_queued(), thinking: emoji_thinking(), tool: emoji_tool(),
coding: emoji_coding(), web: emoji_web(), done: emoji_done(), error: emoji_error(),
queued: emoji_queued(),
thinking: emoji_thinking(),
tool: emoji_tool(),
coding: emoji_coding(),
web: emoji_web(),
done: emoji_done(),
error: emoji_error(),
}
}
}

impl Default for ReactionTiming {
fn default() -> Self {
Self {
debounce_ms: default_debounce_ms(), stall_soft_ms: default_stall_soft_ms(),
stall_hard_ms: default_stall_hard_ms(), done_hold_ms: default_done_hold_ms(),
debounce_ms: default_debounce_ms(),
stall_soft_ms: default_stall_soft_ms(),
stall_hard_ms: default_stall_hard_ms(),
done_hold_ms: default_done_hold_ms(),
error_hold_ms: default_error_hold_ms(),
}
}
Expand All @@ -225,3 +294,20 @@ pub fn load_config(path: &Path) -> anyhow::Result<Config> {
.map_err(|e| anyhow::anyhow!("failed to parse {}: {e}", path.display()))?;
Ok(config)
}

#[cfg(test)]
mod tests {
use super::{ReactionsConfig, ToolDisplayMode};

#[test]
fn reactions_tool_display_defaults_to_compact() {
let config: ReactionsConfig = toml::from_str("").unwrap();
assert_eq!(config.tool_display, ToolDisplayMode::Compact);
}

#[test]
fn reactions_tool_display_parses_none() {
let config: ReactionsConfig = toml::from_str("tool_display = \"none\"").unwrap();
assert_eq!(config.tool_display, ToolDisplayMode::None);
}
}
Loading
Loading