Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5745,6 +5745,10 @@ def _chat_turn(user_input: str, clear_tasks: bool = False, profile: str | None =
"Execute the accepted plan below in Agent mode. Complete each durable task with evidence.\n\n"
+ json.dumps(accepted_plan, ensure_ascii=False)
)
_emit_stream_event({
"event": "interaction",
"interaction": _interaction_controller.envelope(user_input),
})
clear_tasks = False
elif mode_override is None and pending_plan:
user_input = (
Expand Down
9 changes: 9 additions & 0 deletions tests/test_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def turn_end(self, **_kwargs): return None
'TaskDone: 0\nMarker created and verified.',
]
try:
stream_events = []
stream_token = main._stream_event_callback.set(stream_events.append)
with patch.object(main, "_plugin_runtime_for_surface", return_value=RuntimeStub()), \
patch.object(main, "_touch_detached_learning_heartbeat"), \
patch.object(main, "dispatch_learning_cycle"), \
Expand All @@ -233,6 +235,11 @@ def turn_end(self, **_kwargs): return None
suspended = main._chat_turn("accept plan")
self.assertIn("Which accepted check", suspended)
self.assertIsNotNone(main._interaction_controller.state()["executing_plan"])
self.assertTrue(any(
event.get("event") == "interaction"
and event.get("interaction", {}).get("effective_mode") == "agent"
for event in stream_events
))
executed = main._chat_turn("Read contents")
self.assertIn("Marker created", executed)
self.assertEqual((root / "marker.txt").read_text(encoding="utf-8"), "ready")
Expand All @@ -246,6 +253,8 @@ def turn_end(self, **_kwargs): return None
self.assertEqual(state["preference_mode"], "auto")
self.assertEqual(state["effective_mode"], "ask")
finally:
if 'stream_token' in locals():
main._stream_event_callback.reset(stream_token)
(main.tasks, main._interaction_controller, main.learning_engine,
previous_root, main._execution_capability_token) = original
main._set_workspace_root(previous_root)
Expand Down
6 changes: 4 additions & 2 deletions tui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ func (m model) chatView() string {
header := lipgloss.NewStyle().Width(contentWidth).Render(
brandStyle.Render("OPENKYROZEN") + " " + softStyle.Render(firstNonEmpty(m.provider, "provider pending")) +
" · " + mutedStyle.Render(firstNonEmpty(m.modelName, "startup")) +
" · " + brandStyle.Render(strings.ToUpper(firstNonEmpty(m.interactionMode, "auto"))),
" · " + brandStyle.Render(strings.ToUpper(firstNonEmpty(m.effectiveMode, m.interactionMode, "ask"))),
)
if m.workspace != "" {
header += "\n" + mutedStyle.Render("workspace "+compactText(m.workspace, contentWidth-11))
Expand Down Expand Up @@ -1308,7 +1308,9 @@ func (m model) activityRail() string {
if m.workspace != "" {
lines = append(lines, "", mutedStyle.Render("WORKSPACE"), softStyle.Render(compactText(m.workspace, width)))
}
lines = append(lines, "", mutedStyle.Render("MODE"), softStyle.Render(firstNonEmpty(m.interactionMode, "auto")+" → "+firstNonEmpty(m.effectiveMode, "ask")))
lines = append(lines, "", mutedStyle.Render("MODE"), softStyle.Render(
"preference "+firstNonEmpty(m.interactionMode, "auto")+" · active "+firstNonEmpty(m.effectiveMode, "ask"),
))
lines = append(lines, "", titleStyle.Render(fmt.Sprintf("TASKS %d", len(m.tasks))))
if len(m.tasks) == 0 {
lines = append(lines, mutedStyle.Render("No active tasks"))
Expand Down
18 changes: 18 additions & 0 deletions tui/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,24 @@ func TestLongPlanModalScrollsAndKeepsActionsVisible(t *testing.T) {
}
}

func TestEffectiveAgentModeIsProminentDuringPlanExecution(t *testing.T) {
m := initialModel("", true)
m.width, m.height = 125, 39
m.screen = screenChat
m.applyInteraction(map[string]any{
"preference_mode": "plan",
"effective_mode": "agent",
})
m.resize()
view := m.View().Content
if !strings.Contains(view, "AGENT") {
t.Fatalf("header did not show effective Agent mode: %s", view)
}
if !strings.Contains(view, "preference plan") || !strings.Contains(view, "agent") {
t.Fatalf("activity rail did not distinguish preference and active mode: %s", view)
}
}

func TestProviderKeyIsMaskedAndApprovalArgsAreRedacted(t *testing.T) {
m := initialModel("", false)
m.width, m.height = 60, 16
Expand Down
Loading