Buttons are chips, status marks are ✓/✗, confirms are dialogs

Three button/status stragglers join the house style. The tracing
dialog's "❯ [ Abort ]" — the one control drawn with a pointer and
brackets — becomes the centered reverse-video chip every other popup
button already is (ButtonDialog, the reconnect dialog's Abort). Chat's
✅/❌ delivery emoji become the app-wide ✓/✗ status marks in their
ok/err styles: the emoji belong to the packet-class icon lane, and the
single-width marks keep transcript rows evenly spaced. And the channel
manager's Clear — the last bare Yes/No confirm in the app — becomes a
standard destructive dialog (Cancel left, Clear right and default,
danger theming) like every other consequence gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 4.8 committed 2026-07-12 04:04:35 -04:00
1 parent 84a2c45f12
commit 826ab5b4ee
5 files changed
+53 -32

No files matched your search

+13 -5
View File
@@ -665,11 +665,19 @@ async def _edit(ctx: "AppContext", device: Device, slot: ChannelSlot) -> bool:
async def _clear(ctx: "AppContext", device: Device, slot: ChannelSlot) -> bool:
"""Clear a channel slot after confirmation; return whether it was cleared."""
if not await ctx.ui.confirm(
f"Clear [brand]{slot.name}[/brand]? This removes the channel from this device.",
default=False,
):
"""Clear a channel slot after confirmation; return whether it was cleared.
A standard destructive dialog (Cancel left, the verb right and default, danger
theming) rather than a bare yes/no, so it reads like every other confirm.
"""
choice = await ctx.ui.dialog(
f"Clear {slot.name}? This removes the channel from this device.",
[("Cancel", None), ("Clear", "clear")],
title="Clear channel",
default=1,
danger=True,
)
if choice != "clear":
return False
await device.set_channel(slot.idx, "", None) # empty name => the slot reads as unused
ctx.ui.note(f"[warn]cleared channel {slot.name}[/warn]")
+14 -10
View File
@@ -47,11 +47,13 @@ _SENDER_PREFIX = re.compile(r"^([^\s:][^:]{0,19}):[ \t]+(.*)$", re.DOTALL)
_MENTION = re.compile(r"@\[([^\]]{1,20})\]")
#: Delivery-state indicators for a *resolved* outbound direct message, shown at the end of
#: its line: acknowledged, or transmitted-but-unacknowledged (retryable via Ctrl-R). While
#: the ack is still pending the line shows an animated spinner instead (see
#: :meth:`ChatScreen._delivery_glyph`).
_DELIVERED, _FAILED = "✅", "❌"
#: Delivery-state marks for a *resolved* outbound direct message, shown at the end of its
#: line: acknowledged, or transmitted-but-unacknowledged (retryable via ^R). The app-wide
#: ``✓``/``✗`` status marks in their ok/err styles — not the ✅/❌ emoji, which belong to
#: the packet-class icon lane. While the ack is still pending the line shows an animated
#: spinner instead (see :meth:`ChatScreen._delivery_glyph`).
_DELIVERED = ("✓", "ok")
_FAILED = ("✗", "err")
#: Seconds between spinner frames on a message that is still awaiting its ack.
_SPINNER_INTERVAL = 0.12
@@ -409,15 +411,16 @@ class ChatScreen(Screen):
return text
def _delivery_glyph(self, acked: Optional[bool]) -> Text:
"""Map an outbound direct message's ``acked`` state to its trailing glyph.
"""Map an outbound direct message's ``acked`` state to its trailing mark.
A message still awaiting its ack (``acked is None``) shows the current spinner frame,
animated by :meth:`_spin_while` for as long as the send is in flight; a resolved one
shows the delivered ✅ or the unacknowledged ❌.
shows the delivered ``✓`` (ok) or the unacknowledged ``✗`` (err).
"""
if acked is None:
return self._spinner.text()
return Text(_DELIVERED if acked else _FAILED)
glyph, style = _DELIVERED if acked else _FAILED
return Text(glyph, style=style)
def _reply_banner(self) -> Text:
"""One-line cue shown above the input when a message is picked to reply to."""
@@ -635,8 +638,9 @@ class ChatScreen(Screen):
self._session.invalidate()
asyncio.ensure_future(self._send_channel(text))
else:
# Direct chats show an optimistic bubble whose trailing glyph tracks delivery:
# ⏳ now, then ✅/❌ once the ack resolves (or times out). acked=None ⇒ ⏳.
# Direct chats show an optimistic bubble whose trailing mark tracks delivery:
# a spinner now, then ✓/✗ once the ack resolves (or times out). acked=None
# ⇒ still spinning.
pending = ChatMessage(text=text, outbound=True, created_at=utcnow())
self._messages.append(pending)
self._status = ""
+11 -3
View File
@@ -171,7 +171,7 @@ class TracingDialog(Screen):
"""Natural outer width hugging the widest line (compositor still caps it)."""
widths = [cell_len(self.title), cell_len(self.footer_hint),
cell_len(self.status) + 4, len("last ✗ no reply — will retry"),
len("[ Abort ]")]
len(" Abort ")]
return max(widths) + 8
def _last_line(self) -> Text:
@@ -192,14 +192,22 @@ class TracingDialog(Screen):
return line
def render_body(self, width: int) -> list[str]:
"""Render the spinner chip, the last reply, and the Abort button."""
"""Render the spinner chip, the last reply, and the Abort button.
The button is the app's one button look — a centered reverse-video chip in the
shared ``selected`` fill, exactly as the ButtonDialog and reconnect dialog draw
theirs — so every popup's committing control reads the same.
"""
from .tui.prompt import _center
chip = self._spinner.text()
chip.append(f" {self.status}", style="")
lines = render_lines(chip, width)
if self.show_last:
lines.extend(render_lines(self._last_line(), width))
lines.append("")
lines.append(render_to_ansi(Text("❯ [ Abort ]", style="selected"), width))
button = Text(" Abort ", style="selected")
lines.append(render_to_ansi(_center(button, width), width))
return lines
def handle(self, action: str, data: str = "") -> None:
+6 -6
View File
@@ -294,15 +294,15 @@ def test_channel_identity_is_stable_across_slot_moves() -> None:
class _ScriptedUi:
"""A UI surface that replays queued answers, for driving the channel manager headless.
``select``/``text``/``confirm`` each pop their next scripted answer; the display methods
``select``/``text``/``dialog`` each pop their next scripted answer; the display methods
are no-ops. Enough of the :class:`~meshterm.ui.surface.Ui` contract for the channel
manager's create/clear flows.
"""
def __init__(self, selects: list, texts: list, confirms: list) -> None:
def __init__(self, selects: list, texts: list, dialogs: list) -> None:
self._selects = list(selects)
self._texts = list(texts)
self._confirms = list(confirms)
self._dialogs = list(dialogs)
def show(self, *renderables) -> None: # noqa: ANN002
pass
@@ -319,8 +319,8 @@ class _ScriptedUi:
async def text(self, title: str, *, default: str = "", validate=None, help_text: str = "", password: bool = False): # noqa: ANN001, ANN201
return self._texts.pop(0)
async def confirm(self, title: str, *, default: bool = True): # noqa: ANN201
return self._confirms.pop(0)
async def dialog(self, prompt, buttons, *, title: str = "", default: int = 0, keys=None, danger: bool = False): # noqa: ANN001, ANN201
return self._dialogs.pop(0)
async def test_recreating_a_slot_refiles_messages_to_the_new_channel(ctx: AppContext) -> None:
@@ -356,7 +356,7 @@ async def test_recreating_a_slot_refiles_messages_to_the_new_channel(ctx: AppCon
ctx.ui = _ScriptedUi(
selects=[0, _CLEAR, _CREATE, _BACK],
texts=["Ops"], # the new channel's name
confirms=[True], # confirm the clear
dialogs=["clear"], # confirm the clear on its Cancel/Clear dialog
)
await manage_channels(ctx)
+9 -8
View File
@@ -516,7 +516,7 @@ async def test_chat_screen_enter_sends_and_appends() -> None:
async def test_direct_send_spins_until_the_ack_resolves(monkeypatch) -> None:
"""A pending direct message spins while the send is in flight, then settles on ✅."""
"""A pending direct message spins while the send is in flight, then settles on ✓."""
from meshterm.ui.tui.spinner import Spinner
monkeypatch.setattr("meshterm.ui.chat._SPINNER_INTERVAL", 0.005)
@@ -547,7 +547,7 @@ async def test_direct_send_spins_until_the_ack_resolves(monkeypatch) -> None:
if screen._messages[-1].acked is not None:
break
assert screen._messages[-1].acked is True
assert "✅" in "\n".join(screen.render_body(60))
assert "✓" in "\n".join(screen.render_body(60))
def test_byte_counter_shows_used_over_limit_and_colors_only_used() -> None:
@@ -653,7 +653,7 @@ async def test_over_limit_message_is_not_sent_and_buffer_is_kept() -> None:
def test_chat_screen_shows_delivery_glyphs() -> None:
"""Outbound direct messages end with delivery glyphs: a spinner, then ✅ / ❌."""
"""Outbound direct messages end with delivery marks: a spinner, then ✓ / ✗."""
from meshterm.ui.tui.spinner import Spinner
messages = [
@@ -664,9 +664,10 @@ def test_chat_screen_shows_delivery_glyphs() -> None:
screen = _screen(_StubSession(), send=None, messages=messages)
joined = "\n".join(screen.render_body(60))
# A message still awaiting its ack spins (a Braille frame) rather than showing the old
# static hourglass; resolved ones show ✅ / ❌.
assert "✅" in joined and "❌" in joined
# A message still awaiting its ack spins (a Braille frame); resolved ones show the
# app-wide ✓/✗ status marks (never the ✅/❌ emoji, which are packet-class icons).
assert "✓" in joined and "✗" in joined
assert "✅" not in joined and "❌" not in joined
assert Spinner.BRAILLE[0] in joined and "⏳" not in joined
# A failed message advertises the retry shortcut in the footer hint (the app-wide
# compact ^-notation for Ctrl chords).
@@ -740,7 +741,7 @@ def test_direct_transcript_groups_under_sender_headers() -> None:
assert "d4e5f6a7" not in rendered # the key is never shown when a name is known
assert "you" in rendered # our own reply gets its own header
assert "hi" in rendered and "you there?" in rendered and "yes!" in rendered
assert "✅" in rendered # the outbound message keeps its delivery glyph
assert "✓" in rendered # the outbound message keeps its delivery mark
async def test_chat_screen_retry_resends_failed_message() -> None:
@@ -765,7 +766,7 @@ async def test_chat_screen_retry_resends_failed_message() -> None:
await asyncio.sleep(0) # let the scheduled resend task run
assert screen._messages[-1].acked is True # same object, now acknowledged
assert "✅" in "\n".join(screen.render_body(60))
assert "✓" in "\n".join(screen.render_body(60))
def test_chat_screen_scroll_detaches_and_end_reattaches() -> None: