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
12 changes: 11 additions & 1 deletion cecli/helpers/conversation/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,19 @@ def add_randomized_cta(self) -> None:
]
)

user_fidelity = random.choice(
[
"Be mindful of any instructions given, prioritizing the latest.",
"Respect all established constraints.",
"Please stay on task and stick closely to my guidance.",
"Keep my explicit intent in mind.",
"Stay focused on our goals and the scope of our concerns.",
]
)

msg = dict(
role="user",
content="System Message:\n\n" + message,
content=f"System Message:\n\n{message}\n{user_fidelity}",
)

ConversationService.get_manager(coder).add_message(
Expand Down
6 changes: 3 additions & 3 deletions cecli/prompts/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ main_system: |
2. **Explore**: Use discovery tools (`ExploreCode`, `Grep`, `Ls`) to research and gather understanding for you task. Modify search terms when errors are encountered.
3. **Execute**: Mark files as editable with `ContextManager` before attempting edits. Proactively use skills if they are available. Review diff outputs after edit to ensure the proper changes were made.
4. **Verify & Recover**: If an edit fails or introduces linting errors, use `UndoChange` immediately.
5. **Yield**: Use the `Yield` tool only after verifying the solution. Briefly summarize the changes for the user.
5. **Yield**: Use the `Yield` tool after accomplishing the goal and verifying any changes made. Provide helpful summaries of any changes.

## Todo List Management
- Break complex goals into meaningful sub-tasks so the problem remains tractable
Expand All @@ -57,12 +57,12 @@ main_system: |
</context>

Use the `.cecli/temp` directory for all temporary, test, or scratch files.
Always reply to the user in {language}.
Always reply in {language}.

system_reminder: |
<context name="critical_reminders">
## Operational Rules
- **Scope**: No unrequested refactors. Avoid full-file rewrites.
- **Scope**: No unrequested refactors. Avoid full-file rewrites. Only modify what you are asked to.
- **Hygiene**: Use `ContextManager`/`RemoveSkill` to evict unneeded files/skills immediately after use.
- **Outputs**: Tool calls trigger turns. Never include tool syntax in final user summaries.
- **Sandbox**: Perform all verification and temp logic in `.cecli/temp`.
Expand Down
6 changes: 3 additions & 3 deletions cecli/prompts/subagent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ main_system: |
2. **Explore**: Use discovery tools (`ExploreCode`, `Grep`, `Ls`) to research and gather understanding for you task. Modify search terms when errors are encountered.
3. **Execute**: Mark files as editable with `ContextManager` before attempting edits. Proactively use skills if they are available. Review diff outputs after edit to ensure the proper changes were made.
4. **Verify & Recover**: If an edit fails or introduces linting errors, use `UndoChange` immediately.
5. **Yield**: Use the `Yield` tool only after verifying the solution. Briefly summarize the changes for the user.
5. **Yield**: Use the `Yield` tool after accomplishing the goal and verifying any changes made. Provide helpful summaries of any changes.

## Todo List Management
- Break complex goals into meaningful sub-tasks so the problem remains tractable
Expand All @@ -42,12 +42,12 @@ main_system: |
</context>

Use the `.cecli/temp` directory for all temporary, test, or scratch files.
Always reply to the user in {language}.
Always reply in {language}.

system_reminder: |
<context name="critical_reminders">
## Operational Rules
- **Scope**: No unrequested refactors. Avoid full-file rewrites.
- **Scope**: No unrequested refactors. Avoid full-file rewrites. Only modify what you are asked to.
- **Hygiene**: Use `ContextManager`/`RemoveSkill` to evict unneeded files/skills immediately after use.
- **Outputs**: Tool calls trigger turns. Never include tool syntax in final user summaries.
- **Sandbox**: Perform all verification and temp logic in `.cecli/temp`.
Expand Down
6 changes: 3 additions & 3 deletions cecli/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,9 @@ def update_spinner(self, msg, agent_name: str | None = None):

def show_error(self, message, agent_name: str | None = None):
"""Show an error message in the status bar."""
self.status_bar.show_notification(
message, severity="error", timeout=5, agent_name=agent_name
)
status_bar = self.query_one("#status-bar", StatusBar)

status_bar.show_notification(message, severity="error", timeout=5, agent_name=agent_name)

def on_resize(self) -> None:
file_list = self.query_one("#file-list", FileList)
Expand Down
47 changes: 42 additions & 5 deletions tests/tui/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ def mock_query_one(selector, *args):
if isinstance(selector, type):
name = selector.__name__
else:
if "," in selector or "#" in selector:
if selector == "#input" or selector == "#input, InputArea":
return mock_input_area
return mock_footer
elif selector == "#status-bar" or selector == "#status-bar, StatusBar":
return mock_status_bar
name = "MainFooter" # Default fallback

mapping = {
"MainFooter": mock_footer,
"StatusBar": mock_status_bar,
Expand All @@ -217,9 +220,6 @@ def mock_query_one(selector, *args):
tui_instance.worker = MagicMock()
tui_instance.worker.coder = mock_coder

# Stub status_bar reference
tui_instance.status_bar = mock_status_bar

# Mock AgentService - unknown UUID should return None (no prefix)
monkeypatch.setattr(
"cecli.helpers.agents.service.AgentService.get_instance",
Expand All @@ -239,3 +239,40 @@ def mock_query_one(selector, *args):
timeout=5,
agent_name=None,
)


def test_show_error_uses_query_one(tui_instance):
"""
Test that show_error uses query_one to get the status bar and show a notification.
"""
mock_status_bar = MagicMock()
tui_instance.query_one = MagicMock(return_value=mock_status_bar)

# Import StatusBar for the assertion
from cecli.tui.widgets import StatusBar

tui_instance.show_error("A test error", agent_name="test_agent")

# Assert query_one was called correctly
tui_instance.query_one.assert_called_once_with("#status-bar", StatusBar)

# Assert show_notification was called on the result of query_one
mock_status_bar.show_notification.assert_called_once_with(
"A test error",
severity="error",
timeout=5,
agent_name="test_agent",
)
# Test: error message for unknown agent should have agent_name=None
msg = {
"type": "error",
"message": "Something went wrong!",
"coder_uuid": "unknown_uuid",
}
tui_instance.handle_output_message(msg)
mock_status_bar.show_notification.assert_called_once_with(
"Something went wrong!",
severity="error",
timeout=5,
agent_name=None,
)
Loading