From 0d40f270982b6b6a75d423fc96ba4c364f3787a2 Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Thu, 9 Apr 2026 01:03:16 -0400 Subject: [PATCH] Fix F3 context pane for unconscious agents read_sections and draw_context now use selected_agent() which maps the selected index to either a subconscious forked_agent or an unconscious agent Arc. Context title uses selected_agent_name for both types. Co-Authored-By: Proof of Concept --- src/user/subconscious.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/user/subconscious.rs b/src/user/subconscious.rs index 59ac237..ecd181f 100644 --- a/src/user/subconscious.rs +++ b/src/user/subconscious.rs @@ -149,6 +149,17 @@ impl SubconsciousScreen { self.history_scroll = 0; } + /// Get the agent Arc for the selected item, whether subconscious or unconscious. + fn selected_agent(&self, app: &App) -> Option> { + let idx = self.selected(); + let sub_count = app.agent_state.len(); + if idx < sub_count { + return app.agent_state[idx].forked_agent.clone(); + } + let unc_idx = idx.checked_sub(sub_count + 1)?; // +1 for separator + app.unconscious_state.get(unc_idx)?.agent.clone() + } + fn output_sections(&self, app: &App) -> Vec { let snap = match app.agent_state.get(self.selected()) { Some(s) => s, @@ -166,16 +177,18 @@ impl SubconsciousScreen { } fn read_sections(&self, app: &App) -> Vec { - let snap = match app.agent_state.get(self.selected()) { - Some(s) => s, + let agent = match self.selected_agent(app) { + Some(a) => a, None => return Vec::new(), }; - snap.forked_agent.as_ref() - .and_then(|agent| agent.context.try_lock().ok()) + let fork_point = app.agent_state.get(self.selected()) + .map(|s| s.fork_point).unwrap_or(0); + + agent.context.try_lock().ok() .map(|ctx| { let conv = ctx.conversation(); let mut view = section_to_view("Conversation", conv); - let fork = snap.fork_point.min(view.children.len()); + let fork = fork_point.min(view.children.len()); view.children = view.children.split_off(fork); vec![view] }) @@ -350,8 +363,8 @@ impl SubconsciousScreen { self.context_tree.render_sections(sections, &mut lines); } - let title = app.agent_state.get(self.selected()) - .map(|s| s.name.as_str()) + let name = self.selected_agent_name(app); + let title = name.as_deref() .unwrap_or("—"); let mut block = pane_block_focused(title, self.focus == Pane::Context);