Refine chat management: auto-titles, per-chat rename/delete, custom modal
- Auto-title a session from its first user message (chat_title) so chats are distinguishable in the sidebar instead of all 'Nuova chat'. - Per-chat rename (✏️) and delete (🗑️) buttons with aria-labels; stopPropagation so they don't switch the conversation. deleteSessionById selects a fallback or creates a fresh session. - Replace native prompt()/confirm() with a styled custom modal (showDialog): mobile-friendly and inspectable by automation (native dialogs hung the browser subagent). Verified via direct HTTP (auto-title/rename/delete) + 108 tests; browser subagent avoided after repeated hangs.
This commit is contained in:
1 parent
8979201139
commit
0123f41d99
5 files changed
+198
-10
No files matched your search
@@ -299,3 +299,39 @@ async fn agent_mode_streams_events_and_persists() {
|
||||
assert_eq!(msgs.last().unwrap().role, "assistant");
|
||||
assert_eq!(msgs.last().unwrap().content, "efghi");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn first_message_auto_titles_and_rename_delete_work() {
|
||||
let (app, store) = build_app().await;
|
||||
let id = create_session(&app).await;
|
||||
assert_eq!(store.get_session(&id).unwrap().unwrap().title, "Nuova chat");
|
||||
|
||||
// First user message auto-titles the session.
|
||||
req(
|
||||
&app,
|
||||
Method::POST,
|
||||
&format!("/api/sessions/{id}/chat"),
|
||||
Some(serde_json::json!({"content": "Qual è la capitale?"})),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
store.get_session(&id).unwrap().unwrap().title,
|
||||
"Qual è la capitale?"
|
||||
);
|
||||
|
||||
// Rename via PATCH.
|
||||
let (st, _) = req(
|
||||
&app,
|
||||
Method::PATCH,
|
||||
&format!("/api/sessions/{id}"),
|
||||
Some(serde_json::json!({"title": "Mio titolo"})),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(st, StatusCode::OK);
|
||||
assert_eq!(store.get_session(&id).unwrap().unwrap().title, "Mio titolo");
|
||||
|
||||
// Delete via DELETE.
|
||||
let (st, _) = req(&app, Method::DELETE, &format!("/api/sessions/{id}"), None).await;
|
||||
assert_eq!(st, StatusCode::NO_CONTENT);
|
||||
assert!(store.get_session(&id).unwrap().is_none());
|
||||
}
|
||||
Reference in new issue
Block a user