mirror of
https://github.com/GH05TCREW/pentestagent.git
synced 2026-03-07 14:23:20 +00:00
refactor(tui): use persistent header for target display; remove in-chat target duplicates
This commit is contained in:
@@ -1789,28 +1789,13 @@ class PentestAgentTUI(App):
|
||||
updated = True
|
||||
break
|
||||
if not updated:
|
||||
# Fallback: add system line near top by inserting at beginning
|
||||
# If we couldn't find an existing banner SystemMessage to
|
||||
# update, update the persistent header instead of inserting
|
||||
# additional in-chat system messages to avoid duplicates.
|
||||
try:
|
||||
first = scroll.children[0] if scroll.children else None
|
||||
msg = SystemMessage(f" Target: {target}")
|
||||
if first:
|
||||
# Textual's ScrollableContainer may not implement
|
||||
# mount_before across versions; fall back to mount.
|
||||
try:
|
||||
scroll.mount_before(msg, first)
|
||||
except Exception:
|
||||
scroll.mount(msg)
|
||||
else:
|
||||
scroll.mount(msg)
|
||||
except Exception as e:
|
||||
logging.getLogger(__name__).exception("Failed to mount target system message: %s", e)
|
||||
try:
|
||||
from pentestagent.interface.notifier import notify
|
||||
|
||||
notify("warning", f"TUI: failed to display target: {e}")
|
||||
except Exception as ne:
|
||||
logging.getLogger(__name__).exception("Failed to notify operator about target display failure: %s", ne)
|
||||
self._add_system(f" Target: {target}")
|
||||
self._update_header(target=target)
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception("Failed to update persistent header with target")
|
||||
except Exception as e:
|
||||
logging.getLogger(__name__).exception("Failed while applying target display: %s", e)
|
||||
try:
|
||||
@@ -2419,22 +2404,14 @@ Be concise. Use the actual data from notes."""
|
||||
)
|
||||
updated = True
|
||||
break
|
||||
if not updated:
|
||||
try:
|
||||
first = scroll.children[0] if scroll.children else None
|
||||
msg = SystemMessage(f" Target: {target}")
|
||||
if first:
|
||||
try:
|
||||
scroll.mount_before(msg, first)
|
||||
except Exception:
|
||||
scroll.mount(msg)
|
||||
else:
|
||||
scroll.mount(msg)
|
||||
except Exception:
|
||||
self._add_system(f" Target: {target}")
|
||||
if not updated:
|
||||
try:
|
||||
self._update_header(target=target)
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception("Failed to update persistent header with target")
|
||||
except Exception as e:
|
||||
logging.getLogger(__name__).exception("Failed updating in-scroll target display: %s", e)
|
||||
# Also update the persistent header so the target is always visible
|
||||
# Also update the persistent header so the target is always visible
|
||||
try:
|
||||
self._update_header(target=target)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user