story-kit: merge 174_story_constrain_thinking_traces_in_chat_panel
This commit is contained in:
@@ -103,6 +103,12 @@ enum WsResponse {
|
||||
/// Heartbeat response to a client `Ping`. Lets the client confirm the
|
||||
/// connection is alive and cancel any stale-connection timeout.
|
||||
Pong,
|
||||
/// Streaming thinking token from an extended-thinking block.
|
||||
/// Sent separately from `Token` so the frontend can render them in
|
||||
/// a constrained, scrollable ThinkingBlock rather than inline.
|
||||
ThinkingToken {
|
||||
content: String,
|
||||
},
|
||||
/// Sent on connect when the project's spec files still contain scaffold
|
||||
/// placeholder content and the user needs to go through onboarding.
|
||||
OnboardingStatus {
|
||||
@@ -257,6 +263,7 @@ pub async fn ws_handler(ws: WebSocket, ctx: Data<&Arc<AppContext>>) -> impl poem
|
||||
Ok(WsRequest::Chat { messages, config }) => {
|
||||
let tx_updates = tx.clone();
|
||||
let tx_tokens = tx.clone();
|
||||
let tx_thinking = tx.clone();
|
||||
let tx_activity = tx.clone();
|
||||
let ctx_clone = ctx.clone();
|
||||
|
||||
@@ -277,6 +284,11 @@ pub async fn ws_handler(ws: WebSocket, ctx: Data<&Arc<AppContext>>) -> impl poem
|
||||
content: token.to_string(),
|
||||
});
|
||||
},
|
||||
move |thinking: &str| {
|
||||
let _ = tx_thinking.send(WsResponse::ThinkingToken {
|
||||
content: thinking.to_string(),
|
||||
});
|
||||
},
|
||||
move |tool_name: &str| {
|
||||
let _ = tx_activity.send(WsResponse::ToolActivity {
|
||||
tool_name: tool_name.to_string(),
|
||||
@@ -595,6 +607,16 @@ mod tests {
|
||||
assert_eq!(json["type"], "pong");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thinking_token_response() {
|
||||
let resp = WsResponse::ThinkingToken {
|
||||
content: "I need to think about this...".to_string(),
|
||||
};
|
||||
let json = serde_json::to_value(&resp).unwrap();
|
||||
assert_eq!(json["type"], "thinking_token");
|
||||
assert_eq!(json["content"], "I need to think about this...");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_onboarding_status_true() {
|
||||
let resp = WsResponse::OnboardingStatus {
|
||||
|
||||
Reference in New Issue
Block a user