LogScreen
Base classes
| Name |
Children |
Inherits |
Screen textual.screen The base class for screens. |
|
|
โ Inheritance diagram
graph TD
107846719583568["log.LogScreen"]
107846717858048["screen.Screen"]
107846685555472["typing.Generic"]
137699722799616["builtins.object"]
107846718477920["widget.Widget"]
107846718489888["dom.DOMNode"]
107846718374032["message_pump.MessagePump"]
107846717858048 --> 107846719583568
107846685555472 --> 107846717858048
137699722799616 --> 107846685555472
107846718477920 --> 107846717858048
107846718489888 --> 107846718477920
107846718374032 --> 107846718489888
137699722799616 --> 107846718374032
๐ DocStrings
Bases: Screen[None]
Live view of the :class:AgentLog.
Source code in src/acptui/ui/screens/log.py
| class LogScreen(Screen[None]):
"""Live view of the :class:`AgentLog`."""
DEFAULT_CSS = """
LogScreen {
#log-title { height: 1; background: $panel; padding: 0 1; }
RichLog { height: 1fr; }
}
"""
BINDINGS: ClassVar = [
Binding("escape,ctrl+l", "close", "Back"),
Binding("t", "toggle_traffic", "Protocol traffic"),
]
def __init__(self, log: AgentLog) -> None:
super().__init__()
self.agent_log = log
self.show_traffic = False
def compose(self) -> ComposeResult:
yield Static("", id="log-title")
yield RichLog(wrap=True, highlight=False, markup=False, max_lines=5000)
yield Footer()
def on_mount(self) -> None:
self._reload()
self.agent_log.subscribe(self._append)
def on_unmount(self) -> None:
self.agent_log.unsubscribe(self._append)
def _reload(self) -> None:
traffic = "shown" if self.show_traffic else "hidden (t)"
self.query_one("#log-title", Static).update(
f"Agent log ยท stderr ยท protocol traffic {traffic}"
)
view = self.query_one(RichLog)
view.clear()
for line in self.agent_log.lines:
self._append(line)
def _append(self, line: LogLine) -> None:
if line.kind in {"incoming", "outgoing"} and not self.show_traffic:
return
text = Text.assemble(
(line.time.strftime("%H:%M:%S "), "dim"),
(PREFIX[line.kind] + " ", STYLES[line.kind]),
(line.text, STYLES[line.kind] if line.kind != "stderr" else ""),
)
self.query_one(RichLog).write(text)
def action_toggle_traffic(self) -> None:
"""Show or hide the JSON-RPC messages."""
self.show_traffic = not self.show_traffic
self._reload()
def action_close(self) -> None:
"""Back to the session."""
self.dismiss(None)
|
action_close
Back to the session.
Source code in src/acptui/ui/screens/log.py
| def action_close(self) -> None:
"""Back to the session."""
self.dismiss(None)
|
action_toggle_traffic
action_toggle_traffic() -> None
Show or hide the JSON-RPC messages.
Source code in src/acptui/ui/screens/log.py
| def action_toggle_traffic(self) -> None:
"""Show or hide the JSON-RPC messages."""
self.show_traffic = not self.show_traffic
self._reload()
|
:fa-brands-github: Show source on GitHub