Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d9e9a38
Message composers attach files: one owner from picker to send
trissim Nov 18, 2026
5219fa2
Qt message composers attach files: Attach beside Send, chips over the…
trissim Nov 18, 2026
a217c85
Chip members named apart from both toolkits' own: caption, take_off
trissim Nov 18, 2026
13e58d7
Terminal message prompts attach files: a file browser, the path searc…
trissim Nov 18, 2026
ff4d9a9
History rows draw a message's files as chips; a chip fetches the file…
trissim Nov 18, 2026
1c7e923
Read an accepted dialog's choice: Qt's own dialog emits no urlSelected
trissim Nov 18, 2026
ea3e7ea
Merge the TUI's file pickers
trissim Nov 18, 2026
1b308b2
Qt's path search attaches through the shared local-file reader
trissim Nov 18, 2026
60e49a7
Merge origin/main
trissim Nov 18, 2026
8d82e4c
Merge history chips for message files
trissim Nov 18, 2026
ab2acf4
Keep the file picker family through the merge
trissim Nov 18, 2026
82ba50a
Keep the file picker family's imports through the merge
trissim Nov 18, 2026
51f2d69
The terminal draws a sent file as a chip under its message
trissim Nov 18, 2026
d953d4e
qt_drive opens a thread once its sidebar row is listed, as it does a …
trissim Nov 18, 2026
a0a992b
Qt reads a picked file by its local path, or by its content:// URL on…
trissim Nov 18, 2026
78bfa26
The attach drive picks as a person does: the path typed into the dial…
trissim Nov 18, 2026
002fb35
A history's file chips are their own module: the readers never import…
trissim Nov 18, 2026
62f417c
The shipped run closes a dialog a pressed key opened before the next key
trissim Nov 18, 2026
854365a
The shipped run activates the window again after closing a key's dialog
trissim Nov 18, 2026
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
49 changes: 32 additions & 17 deletions src/toad/client/bus_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
RouteChangedError,
)
from agent_comms.messaging.delivery_failure import delivery_failure
from agent_comms.messaging.message_files import FileUpload
from agent_comms.messaging.message_reference import MessageReference

from toad.client.application import ClientApplication
from toad.client.connection import Observing
from toad.client.input_decision import InputAccepted, InputDecision, InputRefused
from toad.client.line_blocks import MutedRole, Span
from toad.client.notification_status import DetailLines
from toad.client.prompt_composer import PromptComposer
from toad.client.submission import (
BusDestination,
MessageDestination,
Expand Down Expand Up @@ -57,13 +59,24 @@ def refusal_notice(description: str) -> str:
def unknown_notice(description: str) -> str:
return f"Send outcome unknown: {description}. Check this conversation before resending."

@property
@abstractmethod
def delivery_refused(self, description: str, body: str) -> None:
"""Nothing left this machine, or Core refused it: the draft comes back with why."""
def submission_composer(self) -> PromptComposer:
"""The composer a returned draft goes back into."""

@abstractmethod
def delivery_unknown(self, description: str, body: str) -> None:
def show_send_failure(self, text: str) -> None:
"""Say why a send came back, where this view says what went wrong."""

def delivery_refused(self, description: str, draft: SubmittedText) -> None:
"""Nothing left this machine, or Core refused it: the draft comes back with why."""
self.submission_composer.restore(draft)
self.show_send_failure(self.refusal_notice(description))

def delivery_unknown(self, description: str, draft: SubmittedText) -> None:
"""The request may have reached Core; the draft comes back with a warning."""
self.submission_composer.restore(draft)
self.show_send_failure(self.unknown_notice(description))

@abstractmethod
async def refresh_composer(self, read_only: bool) -> None:
Expand All @@ -88,9 +101,10 @@ def submissions_changed(self) -> None:

@dataclass(frozen=True)
class TypedText(SubmittedText):
"""Text typed into a message composer, exactly as typed."""
"""Text typed into a message composer, exactly as typed, and the files attached to it."""

source_text: str
files: tuple[FileUpload, ...]


@dataclass(frozen=True)
Expand All @@ -115,7 +129,7 @@ def __init__(self, owner: BusSubmissions, submission: SubmittedText, refusal: In
self.owner, self.submission, self.refusal = owner, submission, refusal

async def prepare(self):
self.owner.view.delivery_refused(self.refusal.message, self.submission.source_text)
self.owner.view.delivery_refused(self.refusal.message, self.submission)


class SubmissionExecution(SubmissionStart):
Expand Down Expand Up @@ -250,7 +264,7 @@ def delivering(self) -> tuple[str, ...]:

def retire_unsent(self) -> None:
"""A message to a view that changed before it left comes back as the draft."""
self.owner.view.delivery_refused("Message route changed; reopen this view", self.submission.source_text)
self.owner.view.delivery_refused("Message route changed; reopen this view", self.submission)
self.owner.finish(self)

def settle(self) -> None:
Expand All @@ -269,43 +283,44 @@ async def send(self):

async def deliver(self) -> DeliveryOutcome:
"""Send after the earlier messages; a refusal is answered here."""
view, body, destination = self.owner.view, self.submission.source_text, self.destination
view, draft, destination = self.owner.view, self.submission, self.destination
access, preparation = view.app.coordination_access, view.app.preparation
try:
await self.after.wait()
observed = await preparation.run_thread(access.observing, destination.root)
read_only = await preparation.run_thread(destination.conversation.read_only, observed.core)
await view.refresh_composer(read_only)
if read_only:
view.delivery_refused(MessageDestination.read_only_reason, body)
view.delivery_refused(MessageDestination.read_only_reason, draft)
return RefusedMessage()
route_current = await preparation.run_thread(lambda: access.current(destination.root))
if not route_current or not self.current:
raise HumanSendRefusedError(RelationViolationError("Message route changed; reopen this view"))
except asyncio.CancelledError:
view.delivery_refused("Cancelled before sending", body)
view.delivery_refused("Cancelled before sending", draft)
raise
except (HumanSendError, RouteChangedError) as error:
delivery_failure(error).present(view, body)
view.delivery_refused(delivery_failure(error).description, draft)
return RefusedMessage()
except Exception:
# Nothing left this machine: the draft comes back, and the failure stays loud.
view.delivery_refused("the send failed before it left this machine", body)
view.delivery_refused("the send failed before it left this machine", draft)
raise
try:
return await self.commit(observed, body)
return await self.commit(observed, draft)
except (HumanSendError, RouteChangedError) as error:
delivery_failure(error).present(view, body)
view.delivery_refused(delivery_failure(error).description, draft)
return RefusedMessage()

async def commit(self, observed: Observing, body: str) -> DeliveryOutcome:
async def commit(self, observed: Observing, draft: SubmittedText) -> DeliveryOutcome:
view = self.owner.view
task = asyncio.create_task(asyncio.to_thread(
observed.send_user_message, self.destination.conversation.send_target(), body))
observed.send_user_message, self.destination.conversation.send_target(), draft.source_text,
draft.files))
try:
return SentMessage(await asyncio.shield(task))
except asyncio.CancelledError:
view.delivery_unknown("the send was cancelled while it may still be writing", body)
view.delivery_unknown("the send was cancelled while it may still be writing", draft)
def _surface_late_exc(done: asyncio.Future) -> None:
if done.cancelled():
return
Expand All @@ -326,7 +341,7 @@ def _surface_late_exc(done: asyncio.Future) -> None:
raise
except Exception:
# The request left: Core may have published it. Raise for the log, never hold compose.
view.delivery_unknown("its reply could not be read", body)
view.delivery_unknown("its reply could not be read", draft)
raise


Expand Down
11 changes: 7 additions & 4 deletions src/toad/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from typing import ClassVar, TypeVar
from weakref import WeakKeyDictionary, WeakSet

from agent_comms.messaging.message_files import FileUpload
from agent_comms.errors import RouteChangedError
from agent_comms.execution.child_process import (
HelperStart,
Expand Down Expand Up @@ -702,10 +703,12 @@ def session_thread(self, project: Path, preferred: str) -> ProjectThreadSelectio
"""The thread an unbound session at ``project`` names; Core's host resolves the path."""
return self.core.call(CommsSessionThreadTool(project=str(project), preferred=preferred))

def send_user_message(self, target: NamedTarget, body: str) -> MessageReference:
"""The owner's input, published by Core under the owner's identity, in process or
across the connector; the reference is what the view waits to draw."""
return self.core.call(CommsUserSendTool(target=target.name, body=body)).message.source
def send_user_message(self, target: NamedTarget, body: str,
files: tuple[FileUpload, ...]) -> MessageReference:
"""The owner's input and the files attached to it, published by Core under the
owner's identity, in process or across the connector; the reference is what the view
waits to draw."""
return self.core.call(CommsUserSendTool(target=target.name, body=body, files=files)).message.source

def mark_thread_read(self, identity, project: Path, through: TranscriptCursor) -> None:
"""Acknowledge, as the owner, what this UI displayed of one thread: Core applies it,
Expand Down
58 changes: 38 additions & 20 deletions src/toad/client/fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ShownFragment,
UncheckedNotifications,
)
from toad.client.message_file_links import MessageFileLink, file_chips
from toad.commit_claims import CommitClaim
from toad.core.projection import MroProjection
from toad.message_rows import MarkdownMessageStyle, MessageRow, WireMessageStyle
Expand Down Expand Up @@ -104,6 +105,10 @@ def status_blocks(self, shown: MessageShown, link: LineLink) -> tuple[LineBlock,
@abstractmethod
def outgoing_sources(self, publication: PublishedSentMessage): ...

@abstractmethod
def file_blocks(self, links: tuple[MessageFileLink, ...]) -> tuple[LineBlock, ...]:
"""The chips of the message's files; only the part carrying its status draws them."""

def draw_divider(self, consumer, divider: Divider) -> None:
"""A message's first part draws its header; later parts draw none."""
consumer.blocks.append(divider)
Expand Down Expand Up @@ -155,6 +160,9 @@ def status_blocks(self, shown: MessageShown, link: LineLink):
def outgoing_sources(self, publication: PublishedSentMessage):
return (publication.reference,)

def file_blocks(self, links: tuple[MessageFileLink, ...]) -> tuple[LineBlock, ...]:
return file_chips(links)


class InnerPart(PartPosition):
__slots__ = ()
Expand All @@ -169,6 +177,9 @@ def status_blocks(self, shown: MessageShown, link: LineLink):
def outgoing_sources(self, publication: PublishedSentMessage):
return ()

def file_blocks(self, links: tuple[MessageFileLink, ...]) -> tuple[LineBlock, ...]:
return ()


class OnlyPart(LastPart):
"""A message in one part: it draws the header and carries the status."""
Expand Down Expand Up @@ -374,7 +385,32 @@ def blocks(self, shown: Shown) -> tuple[LineBlock, ...]:


@dataclass(kw_only=True)
class BusMessageHistoryFragment(HistoryFragment):
class MessageLines(HistoryFragment):
"""A bus message drawn as lines: what leads it, its text, the chips of the files it
carries, then what trails it. `files` is what its page's read answered for it."""

files: tuple[MessageFileLink, ...] = ()

@property
def leading(self) -> tuple[LineBlock, ...]:
"""Blocks above the message's own text."""
return ()

@abstractmethod
def text(self, shown) -> tuple[LineBlock, ...]:
"""The message's own text."""

def trailing(self, shown) -> tuple[LineBlock, ...]:
"""Blocks below the message's own text and files."""
return ()

def blocks(self, shown):
return (*self.leading, *self.text(shown), *self.part_position.file_blocks(self.files),
*self.trailing(shown))


@dataclass(kw_only=True)
class BusMessageHistoryFragment(MessageLines):
"""One bus-message builder: header, styled body and Core notification feedback."""

shown: MessageShown = field(default_factory=MessageShown)
Expand Down Expand Up @@ -427,12 +463,9 @@ def text(self, shown):
def trailing(self, shown):
return self.part_position.status_blocks(shown, self.details_link)

def blocks(self, shown):
return (*self.leading, *self.text(shown), *self.trailing(shown))


@dataclass(kw_only=True)
class EvidencedFragment(DeclaredViews, HistoryFragment, ABC):
class EvidencedFragment(DeclaredViews, MessageLines, ABC):
"""One wire message drawn as lines.

`evidence` is Core's page whose display evidence can mark this message
Expand Down Expand Up @@ -465,21 +498,6 @@ def timestamp(self) -> float:
def clipboard_text(self) -> str:
return self.message.body

@property
def leading(self) -> tuple[LineBlock, ...]:
"""Blocks above the message's own text."""
return ()

def trailing(self, shown: MessageShown) -> tuple[LineBlock, ...]:
"""Blocks below the message's own text."""
return ()

@abstractmethod
def text(self, shown: MessageShown) -> tuple[LineBlock, ...]:
"""The message's own text."""

def blocks(self, shown):
return (*self.leading, *self.text(shown), *self.trailing(shown))


class MembershipText(EvidencedFragment):
Expand Down
7 changes: 5 additions & 2 deletions src/toad/client/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from toad.client.fragments import EvidencedFragment, FragmentKey, MessageShown
from toad.client.history_preparation import HistorySourceSnapshot, PageRequest
from toad.client.history_reads import NothingToRead, PaintedRead, ReadMarking, ReadWork
from toad.client.message_file_links import PageFiles
from toad.client.history_state import (
LatestReplacementViewportRequest,
ReplacementViewportRequest,
Expand All @@ -62,7 +63,7 @@
SubmissionStart,
SubmittedText,
)
from toad.message_rows import WireMessageStyle
from toad.message_rows import MessageRow, WireMessageStyle
from toad.submission_queue import BusQueueSource
from toad.target_commands import TargetContext

Expand Down Expand Up @@ -429,11 +430,13 @@ def read(self, request: PageRequest[WireCut], through: AfterSequence) -> Prepare
# "Checking": the answer that follows then changes nothing it has to redraw.
scope = ReadNotifications(str(self.root), LiveNotificationRead(()),
display=page.selection.notification_identity)
files = PageFiles.read(str(self.root), self.core, (
(message.reference, MessageRow(message, self.me).file_reader) for message in page.messages))
fragments = tuple(
self.fragments.of(message, shown=MessageShown(
style=self.style,
status=self.access.notification_status(scope, message.role.notification_references(message))),
evidence=evidence, reader=self.me, page=page)
evidence=evidence, reader=self.me, page=page, files=files.of(message.reference))
for message, evidence in page.message_evidence()
)
wire = WirePage(
Expand Down
Loading