Skip to content

Commit 2b8410a

Browse files
committed
feat: Add approval preset as a session mode
1 parent a36adc9 commit 2b8410a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/conversation.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,13 +1729,19 @@ impl<A: Auth> ConversationActor<A> {
17291729
}
17301730

17311731
fn modes(&self) -> Option<SessionModeState> {
1732-
let current_mode_id = APPROVAL_PRESETS
1732+
let current_preset = APPROVAL_PRESETS
17331733
.iter()
17341734
.find(|preset| {
17351735
preset.approval == self.config.approval_policy
17361736
&& preset.sandbox == self.config.sandbox_policy
17371737
})
1738-
.map(|preset| SessionModeId(preset.id.into()))?;
1738+
.unwrap_or(
1739+
APPROVAL_PRESETS
1740+
.first()
1741+
.expect("approval presets are empty!"),
1742+
);
1743+
1744+
let current_mode_id = SessionModeId(current_preset.id.into());
17391745

17401746
Some(SessionModeState {
17411747
current_mode_id,
@@ -1745,10 +1751,16 @@ impl<A: Auth> ConversationActor<A> {
17451751
id: SessionModeId(preset.id.into()),
17461752
name: preset.label.to_owned(),
17471753
description: Some(preset.description.to_owned()),
1748-
meta: None,
1754+
meta: Some(json!({
1755+
"approval_policy": current_preset.approval,
1756+
"sandbox_policy": current_preset.sandbox,
1757+
})),
17491758
})
17501759
.collect(),
1751-
meta: None,
1760+
meta: Some(json!({
1761+
"approval_policy": current_preset.approval,
1762+
"sandbox_policy": current_preset.sandbox,
1763+
})),
17521764
})
17531765
}
17541766

0 commit comments

Comments
 (0)