mirror of
https://github.com/GH05TCREW/pentestagent.git
synced 2026-03-07 22:33:38 +00:00
fix(tui): clear target and agent state when deactivating workspace
This commit is contained in:
@@ -2156,6 +2156,35 @@ Be concise. Use the actual data from notes."""
|
||||
try:
|
||||
if marker.exists():
|
||||
marker.unlink()
|
||||
# Clear TUI and agent target when workspace is deactivated
|
||||
self.target = ""
|
||||
try:
|
||||
self._apply_target_display("")
|
||||
except Exception:
|
||||
pass
|
||||
if self.agent:
|
||||
try:
|
||||
# Clear agent's target and any manual override
|
||||
self.agent.target = ""
|
||||
try:
|
||||
if hasattr(self.agent, "_manual_target"):
|
||||
delattr(self.agent, "_manual_target")
|
||||
except Exception:
|
||||
pass
|
||||
from pentestagent.agents.base_agent import AgentMessage
|
||||
|
||||
self.agent.conversation_history.append(
|
||||
AgentMessage(
|
||||
role="system",
|
||||
content=(
|
||||
f"Workspace '{active}' deactivated; cleared target"
|
||||
),
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception(
|
||||
"Failed to clear agent target on workspace clear"
|
||||
)
|
||||
self._add_system(f"Workspace '{active}' deactivated.")
|
||||
except Exception as e:
|
||||
self._add_system(f"Error deactivating workspace: {e}")
|
||||
|
||||
Reference in New Issue
Block a user