Ages: the chat picker re-derived the column grammar

tools/chat._ago carried its own copy of the now/5m/3h/2d/4w ladder plus
an inline _age_seconds; _format_age is THE column age widget, so change
the ladder once and every surface follows. The picker keeps its one real
difference — a naive timestamp reads as a blank lane, not "never" —
and now says so (housekeeping H-002).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Fable 5 committed 2026-07-29 23:06:40 -04:00
1 parent 1efe3cae67
commit 5f8ffc1788
1 file changed
+6 -15
+6 -15
View File
@@ -34,14 +34,13 @@ from ..core.models import (
Contact,
Conversation,
is_direct_messageable,
utcnow,
)
from ..services.trace_runner import NameKeyResolver, make_name_key_resolver
from ..ui.chat import _MENTION, _split_channel_sender
from ..ui.menus import Lane, back_rows, column_header, fit_cells, section_heading
from ..ui.theme import name_style
from ..ui.tui import Choice, DeleteRequest, Separator
from ..ui.widgets import _NODE_GLYPHS, channel_glyph
from ..ui.widgets import _NODE_GLYPHS, _age_seconds, _format_age, channel_glyph
from .base import Tool, ToolResult, register
if TYPE_CHECKING:
@@ -796,23 +795,15 @@ def _append_body(text: Text, body: str, key_of: NameKeyResolver) -> None:
def _ago(when: Any) -> str:
"""A compact relative age for a message time — ``now``, ``5m``, ``3h``, ``2d``, ``4w``.
"""The column age for a message time, through THE grammar (``_format_age``).
Tolerates a naive timestamp (assumed UTC) so a stray one from the wire can't crash the
picker on the aware/naive subtraction.
One deliberate difference from the widget: a missing or naive timestamp (a stray one
from the wire) reads as a *blank* lane rather than ``never`` — the picker wants an
empty cell there, not a word.
"""
if getattr(when, "tzinfo", None) is None:
return ""
secs = max(0.0, (utcnow() - when).total_seconds())
if secs < 60:
return "now"
if secs < 3600:
return f"{int(secs // 60)}m"
if secs < 86400:
return f"{int(secs // 3600)}h"
if secs < 604800:
return f"{int(secs // 86400)}d"
return f"{int(secs // 604800)}w"
return _format_age(_age_seconds(when))
def _history_table(label: str, messages: list[ChatMessage]) -> Table: