fix(tui): la bascule TUI native <-> CLI custom ne déclenche plus de faux conflit de visibilité (#189)
This commit is contained in:
@ -1344,6 +1344,68 @@ async fn chat_intent_replaces_existing_pty_instead_of_returning_pty_session() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn chat_intent_reattaches_existing_structured_session_after_stale_pty_transition() {
|
||||
let profile = profile(
|
||||
pid(9),
|
||||
ContextInjection::convention_file("CLAUDE.md").unwrap(),
|
||||
)
|
||||
.with_structured_adapter(StructuredAdapter::Claude);
|
||||
let (launch, agent, _fs, pty, _bus, sessions, tr, _session) = launch_fixture_with_profile(
|
||||
profile,
|
||||
Some(ContextInjectionPlan::File {
|
||||
target: "CLAUDE.md".to_owned(),
|
||||
}),
|
||||
);
|
||||
let structured = Arc::new(StructuredSessions::new());
|
||||
let factory = FakeStructuredFactory::new(Arc::clone(&tr), sid(888));
|
||||
let launch = launch
|
||||
.with_structured_routing_mode(StructuredRoutingMode::HumanPtyFallback)
|
||||
.with_structured(Arc::new(factory.clone()), Arc::clone(&structured));
|
||||
|
||||
let stale_custom_node = nid(7);
|
||||
structured.insert_in_project(
|
||||
project().id,
|
||||
Arc::new(FakeSession {
|
||||
id: sid(555),
|
||||
conversation_id: Some("engine-session-stale".to_owned()),
|
||||
}),
|
||||
agent.id,
|
||||
stale_custom_node,
|
||||
);
|
||||
seed_live_agent_session(&sessions, agent.id, nid(8), sid(42));
|
||||
|
||||
let target = nid(9);
|
||||
let mut input = launch_input(agent.id);
|
||||
input.node_id = Some(target);
|
||||
input.require_structured = true;
|
||||
let out = launch.execute(input).await.unwrap();
|
||||
|
||||
assert_eq!(pty.kills(), vec![sid(42)], "old native TUI PTY is closed");
|
||||
assert!(
|
||||
sessions
|
||||
.session_for_agent_in_project(project().id, &agent.id)
|
||||
.is_none(),
|
||||
"old PTY registration is removed before the custom transition returns"
|
||||
);
|
||||
assert_eq!(
|
||||
factory.starts(),
|
||||
Vec::<ProfileId>::new(),
|
||||
"existing custom session is resumed, not restarted"
|
||||
);
|
||||
assert_eq!(out.session.id, sid(555));
|
||||
assert_eq!(out.session.node_id, target);
|
||||
assert_eq!(
|
||||
structured.node_for_agent_in_project(project().id, &agent.id),
|
||||
Some(target),
|
||||
"stale custom host node is rebound to the requested surface"
|
||||
);
|
||||
assert!(
|
||||
out.structured.is_some(),
|
||||
"backend still returns a chat session descriptor"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn launch_agent_structured_forwards_resolved_effort_ahead_of_profile_default() {
|
||||
let profile = profile(
|
||||
|
||||
Reference in New Issue
Block a user