UrlElicitationScreen
Base classes
| Name |
Children |
Inherits |
ModalScreen textual.screen A screen with bindings that take precedence over the App's key bindings. |
|
|
β Inheritance diagram
graph TD
107846721239312["elicitation.UrlElicitationScreen"]
107846717906624["screen.ModalScreen"]
107846717858048["screen.Screen"]
107846685555472["typing.Generic"]
137699722799616["builtins.object"]
107846718477920["widget.Widget"]
107846718489888["dom.DOMNode"]
107846718374032["message_pump.MessagePump"]
107846717906624 --> 107846721239312
107846717858048 --> 107846717906624
107846685555472 --> 107846717858048
137699722799616 --> 107846685555472
107846718477920 --> 107846717858048
107846718489888 --> 107846718477920
107846718374032 --> 107846718489888
137699722799616 --> 107846718374032
π DocStrings
Bases: ModalScreen['CreateElicitationResponse']
Asks the user to visit a URL (e.g. to sign in); closes when the agent reports completion.
Source code in src/acptui/ui/screens/elicitation.py
| class UrlElicitationScreen(ModalScreen["CreateElicitationResponse"]):
"""Asks the user to visit a URL (e.g. to sign in); closes when the agent reports completion."""
DEFAULT_CSS = "UrlElicitationScreen {" + DIALOG_CSS + " #url { color: $text-accent; } }"
BINDINGS: ClassVar = [Binding("escape", "cancel", "Cancel"), Binding("o", "open", "Open URL")]
def __init__(self, request: UrlElicitationRequest) -> None:
super().__init__()
self.request = request
self.elicitation_id = request.elicitation_id
def compose(self) -> ComposeResult:
with Vertical(id="dialog"):
yield Static("The agent asks you to open a URL", id="message")
yield Static(Content(self.request.message))
yield Static(Content(self.request.url), id="url")
yield Static("Waiting for the agent to confirm⦠(o: open in browser)", classes="help")
with Horizontal(id="buttons"):
yield Button("Open", variant="primary", id="open", compact=True)
yield Button("Done", variant="success", id="done", compact=True)
yield Button("Decline", variant="error", id="decline", compact=True)
yield Button("Cancel", id="cancel", compact=True)
async def action_open(self) -> None:
"""Open the URL in a browser (in a thread: it may block)."""
await asyncio.to_thread(webbrowser.open, self.request.url)
def action_cancel(self) -> None:
"""Cancel the elicitation."""
self.dismiss(CancelElicitationResponse())
async def on_button_pressed(self, event: Button.Pressed) -> None:
match event.button.id:
case "open":
await self.action_open()
case "done":
self.dismiss(AcceptElicitationResponse())
case "decline":
self.dismiss(DeclineElicitationResponse())
case _:
self.action_cancel()
def complete(self) -> None:
"""The agent reported the elicitation complete."""
if self.is_attached:
self.dismiss(AcceptElicitationResponse())
def cancel(self) -> None:
"""Close because the agent cancelled the request."""
if self.is_attached:
self.dismiss(CancelElicitationResponse())
|
action_cancel
Cancel the elicitation.
Source code in src/acptui/ui/screens/elicitation.py
| def action_cancel(self) -> None:
"""Cancel the elicitation."""
self.dismiss(CancelElicitationResponse())
|
action_open
async
Open the URL in a browser (in a thread: it may block).
Source code in src/acptui/ui/screens/elicitation.py
| async def action_open(self) -> None:
"""Open the URL in a browser (in a thread: it may block)."""
await asyncio.to_thread(webbrowser.open, self.request.url)
|
cancel
Close because the agent cancelled the request.
Source code in src/acptui/ui/screens/elicitation.py
| def cancel(self) -> None:
"""Close because the agent cancelled the request."""
if self.is_attached:
self.dismiss(CancelElicitationResponse())
|
complete
The agent reported the elicitation complete.
Source code in src/acptui/ui/screens/elicitation.py
| def complete(self) -> None:
"""The agent reported the elicitation complete."""
if self.is_attached:
self.dismiss(AcceptElicitationResponse())
|
:fa-brands-github: Show source on GitHub