Repository navigation
feat(rooms): relative-time + (stale) annotation on airc list (closes #82) - #89
Conversation
Memento's case (2026-04-25) showed `airc list` with 5 rooms and no signal which was active vs. abandoned, contributing to room-bouncing + gist-thrash. Add relative-time display + (stale) marker for rooms inactive > 24h (configurable via AIRC_STALE_HOURS). Side fix: cmd_rooms / Get-GhGistList were reading column 4 (visibility, "secret") into the "updated" field of the output. The actual timestamp is at column 5. So pre-#82 the rooms list literally showed "updated: secret" -- a display bug fixed here on the way to adding the activity annotation. New helpers (bash + ps1 lockstep): - _format_relative_time / _FormatRelativeTime: ISO 8601 -> "12m ago" / "3h ago" / "2d ago". Handles BSD date (macOS) and GNU date (Linux/ WSL); ps1 uses [datetime]::Parse. - _is_stale / _IsStale: true when older than AIRC_STALE_HOURS (24h default). Output now: # airc room: general id: dca151bf... mnemonic: moon-yankee-steak-grey updated: 1h ago (1:1) airc invite for old-thing (stale) ... updated: 1d ago 133/133 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds “last updated” relative-time output and a (stale) annotation to the rooms/invites listing so users can quickly identify inactive rooms, while also fixing an existing column-parsing bug where updated was incorrectly displaying the visibility field.
Changes:
- Fix
gh gist listcolumn parsing soupdateduses the actual timestamp field (notvisibility). - Add relative-time formatting for gist
updated_atin both bash (airc rooms) and PowerShell (airc list/rooms). - Add stale-room detection based on
AIRC_STALE_HOURS(default 24h) and display a(stale)marker.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airc |
Fixes updated-field parsing and adds relative-time + stale marker logic for cmd_rooms. |
airc.ps1 |
Fixes updated-field parsing and adds relative-time + stale marker logic for Invoke-Rooms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function _IsStale { | ||
| param([string]$Ts) | ||
| if (-not $Ts) { return $false } | ||
| $thresholdHours = if ($env:AIRC_STALE_HOURS) { [int]$env:AIRC_STALE_HOURS } else { 24 } |
There was a problem hiding this comment.
_IsStale casts $env:AIRC_STALE_HOURS with [int] directly; if the env var is set but not a valid integer (e.g. "24h"), PowerShell will throw and break airc rooms/list. Consider using [int]::TryParse (or -as [int] + fallback) and clamping to a sane minimum (e.g. >=1) before doing the threshold math.
| $thresholdHours = if ($env:AIRC_STALE_HOURS) { [int]$env:AIRC_STALE_HOURS } else { 24 } | |
| $thresholdHours = 24 | |
| if ($env:AIRC_STALE_HOURS) { | |
| $parsedThresholdHours = 0 | |
| if ([int]::TryParse($env:AIRC_STALE_HOURS, [ref]$parsedThresholdHours)) { | |
| $thresholdHours = $parsedThresholdHours | |
| } | |
| } | |
| if ($thresholdHours -lt 1) { $thresholdHours = 1 } |
| local ts="${1:-}" | ||
| local threshold_hours="${AIRC_STALE_HOURS:-24}" | ||
| [ -z "$ts" ] && return 1 | ||
| local epoch | ||
| if epoch=$(date -j -u -f "%Y-%m-%dT%H:%M:%SZ" "$ts" +%s 2>/dev/null); then | ||
| : | ||
| elif epoch=$(date -u -d "$ts" +%s 2>/dev/null); then | ||
| : | ||
| else | ||
| return 1 | ||
| fi | ||
| local now; now=$(date -u +%s) | ||
| local diff=$((now - epoch)) | ||
| [ "$diff" -gt $((threshold_hours * 3600)) ] |
There was a problem hiding this comment.
_is_stale uses threshold_hours="${AIRC_STALE_HOURS:-24}" in an arithmetic expansion without validating it's an integer. With set -euo pipefail, a non-numeric value (or negative) can cause airc rooms to exit with an error. Add input validation (e.g., numeric regex/case) and default to 24 (and/or enforce threshold_hours >= 1) before computing threshold_hours * 3600.
…lity (#1283) * feat(store): generic scoped_state key→JSON store (walls/coordination/plan/widget) The internal sibling of the bio identity card: one durable, dumb key→JSON table scoped to a user, a room, or a (user, room) pair. Editable walls (a room's instructions / recipe), room coordination state (the shared plan), per-person prefs, widget UI state (open tabs / rooms), and the adaptive tool-menu cursor all live here — differing only by (scope_key, key). Backs concise RAG: explicit, scoped, budgetable grounding layers instead of an undifferentiated dump. Mirrors account_registry exactly (String-PK durable table, upsert-on- conflict, store never parses value_json). Scope is encoded as a flat `scope_key` string (`user:<peer>` / `room:<room>` / `uir:<peer>:<room>`) so the PK stays a clean two-column (scope_key, key) — no nullable composite. The kanban board stays event-sourced and untouched; "plan generics" is a `plan` wall in this store that links WorkCardIds. Slice 1 (airc-store layer): StoredScopedState DTO, composite-PK entity, migration #18, EventStore::{get,set,list,delete}_scoped_state on both SqliteEventStore (OnConflict upsert) and InMemoryEventStore. Round-trip test covers upsert-wins, scope-isolated key-ascending list, idempotent delete. Next slices (separate commits): airc-core ScopeRef + ScopedStateChanged wire event (broadcast on room scope), airc-lib set/get, airc-cli `airc state`. Continuum consumes via a WallSource RagSource + the tool-menu cursor read. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * feat(core): ScopeRef — private/local scoped-state domain layer (complements the room wall) Slice 2 — the storage-neutral typed layer over the scoped_state store. ScopeRef { User(PeerId) | Room(RoomId) | UserInRoom(PeerId, RoomId) } owns the scope_key encoding (user:<peer> / room:<room> / uir:<peer>:<room>) that the store previously only documented — one logical decision, one owner (compression principle). scope_key() ↔ parse() are exact inverses; parse() fails loud (None) on an unknown prefix or bad UUID rather than guessing a scope. Scoped state is the PRIVATE/LOCAL sibling of airc's existing room wall. airc already has Airc::publish_wall_post / wall_posts — event-sourced, broadcast, supersede-chain, open consumer-defined categories — which is the right home for SHARED room documents (a room's plan, coding instructions, the recipe, rules/agenda/rag). This store deliberately does NOT duplicate that: it holds peer-private, high-churn, last-write- wins state the wall can't serve — prefs, "where was I last" / the tool-menu mode cursor, widget UI state (open tabs / rooms). A growing supersede log is the wrong shape for a cursor updated every turn; a durable LWW row is right. Scoped state therefore never broadcasts (no wire event) — a consumer (continuum's WallSource) presents ONE unified scoped grounding surface by reading the wall (shared) + scoped state (private) underneath. That is the concise-RAG payoff: explicit, scoped, budgetable layers, each on the right primitive. ScopedStateEntry mirrors the persisted DTO (StoredScopedState) as the storage-neutral domain view, with a typed scope() accessor. 3 unit tests cover round-trip, fail-loud parse, and scope() recovery. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * feat(lib): Airc::{get,set,list,delete}_scoped_state — private scoped-state facade Slice 3 — the airc-lib facade over the scoped_state store (slices 1–2). get/set/list/delete take a typed ScopeRef and bridge the persistence DTO (StoredScopedState) to the domain view (ScopedStateEntry). set() stamps the write time (crate::time::now_ms) and records THIS peer as updated_by — the caller can't spoof provenance and the lib owns the clock, matching how publish_wall_post stamps published_at_ms; the caller still owns the LWW version counter. delete is idempotent. Deliberately NO broadcast and NO wire event — unlike set_local_identity_card (which fans a card to every subscribed room) scoped state is peer-private. Shared room documents (a room's plan / coding instructions / recipe) reuse the existing event-sourced wall (publish_wall_post / wall_posts); this facade serves the private complement (prefs, the tool-menu cursor, widget UI state). A consumer reads scoped state on demand and composes it with the wall into one grounding surface — concise RAG, not a parallel broadcast. stored_to_entry degrades an unparseable updated_by string to None (provenance is advisory, never load-bearing) rather than failing the read. One integration test exercises the full round trip through the facade (set/get/list/delete + provenance + idempotent delete) on a tempdir Airc. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * feat(airc-cli): `airc state` — CLI over the scoped-state facade Slice 4 of the generic scoped-state store (task #89). Thin clap layer (state_cli.rs) + four async handlers (state_commands.rs) routing through `attached_airc(home)` → `Airc::{get,set,list,delete}_scoped_state`, so the CLI exercises the same daemon-attached path a persona consumer does. Provenance + write-time stamping stay single-sourced in airc-lib; this layer only resolves the scope and renders. Scope defaults to this peer (user scope); `--in-room` scopes to (this peer, the current room). Renamed off `--here` to avoid colliding with the global `--here` (cwd-local home) flag. Shared room documents — plan, instructions, recipe — belong on the broadcast wall (`airc publish --room …`), not here; scoped state never broadcasts. Verbs: get (prints value or nothing), set (--value --version, LWW), list (key\tvalue_json per row), delete (idempotent). cargo check + clippy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * fix(wall): daemon-attached publish + body-authoritative read A daemon-attached client (e.g. a Continuum persona) published wall posts that vanished — the wall-grounding A/B showed zero lift because the [room-board] block was always empty. Two airc-lib bugs, both fixed here in airc.rs (no wire-protocol change): WRITE split-brain: publish_wall_post routed through emit_lifecycle, which writes only the CLIENT-local store + live channel and never forwards to the daemon when attached. The post landed in the persona's own events.sqlite, invisible to the daemon-backed page_recent the same persona reads with. Fix: when is_daemon_attached(), route the post through daemon_publish (canonical persist + wire fan-out); emit locally only when this IS the owner-core. READ flattening: wall_posts() gated on event.kind == WallPostPublished, but the daemon read path (project/kind_to_transcript) flattens every non-Message bus kind to TranscriptKind::System — the fine kind rides the wire, not the coarse bus enum — so the gate dropped every post for attached clients. Fix: extract a pure wall_post_from_event discriminator that ignores kind and reads the self-describing body (only an actual WallPostPublished body deserializes to that variant; doctrine/identity/ chat bodies fall through). wall_posts() is now a filter_map over it. Regression tests (in the existing wall mod): a wall body on a System- kind event is still recovered; a sibling doctrine body is not misread as a wall post; non-JSON / body-less events fall through without panic. 297 lib tests green, clippy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * fix(identity): durable per-peer identity index — names survive busy rooms Peer display names decayed to None in busy rooms because name resolution scanned only the bounded recent transcript window for each peer's `IdentityPublished` card. A card is published once per join, so in any room with >window events since a peer joined, the card scrolled out of the scan and `peer_alias` / `room_roster` returned None — and consumers (continuum personas) confabulated names from raw uuids. Fix: maintain a durable per-peer identity index in `scoped_state` (`ScopeRef::User(peer)` → `identity.card`), LWW-keyed on the card's `emitted_at_ms`. Every observed `IdentityPublished` event is recorded into it: - inbound peer cards via both `append_received_frame` branches (daemon-sink + direct); - this peer's OWN card via `emit_lifecycle` — the only path that persists self-originated lifecycle events (it bypasses both the received and sent message-frame paths). `peer_alias` / `peer_identity_card` now read the index instead of scanning; `room_roster` resolves each live peer's name through `peer_alias`, and the now-redundant `peer_display_names` window scan is deleted. The index is room-independent — one identity per peer — which is strictly better than the old per-room scan. Also seed a NAMED citizen's published nick from its `agent_name` at identity-row creation (`generate_and_save_as`), so `attach_as("Claude")` / `init --as Claude` publishes a card carrying "Claude" from its first beat rather than an empty name. The default scope keeps an empty name (the user's identity, set later via `airc identity set`). Adds `AircError::Serde` to surface (never swallow) identity (de)serde into the index. Regression test `peer_name_survives_identity_card_scrolling_past_the_recent_window` buries the card under >window events and asserts both `peer_alias` and `room_roster` still resolve the name — it fails against any window-bounded scan. Incidental: `cargo fmt --all` normalized line-wrapping in three pre-existing `airc-store` scoped_state files (no logic change). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * fix(identity): daemon-aware peer-identity-card read so attached personas resolve foreign names An attached scope has two disjoint data planes: transcript/presence reads RPC to the daemon (foreign peers show present), but scoped_state reads hit the persona's LOCAL home sqlite — which only ever holds the persona's own identity card. The daemon's subscribe reader forwards events without running the identity-observe chokepoint, so foreign peers' cards are indexed only in the DAEMON's store, never the attached client's. Result: presence saw a peer but peer_alias returned None, so personas rendered raw UUIDs (7711fe60) and confabulated names. Fix, modeled exactly on card 8428ae8c (channel_latest_cursor → room_tip): peer identity is owner-core shared state like the transcript tip, so add a typed daemon IPC op PeerIdentityCard and branch peer_identity_card on is_daemon_attached() to read from the daemon's authoritative scoped_state index. peer_alias now delegates to peer_identity_card so there is ONE daemon-aware identity read path. All other scoped_state stays local — peer identity is the single shared exception (derived from broadcast IdentityPublished, globally meaningful), so the key constant lives in airc-core (PEER_IDENTITY_STATE_KEY) as the single source of truth shared by the writer and the daemon's handler. Also: airc identity set --name — the only post-creation path to set the display name on a long-lived identity created before the agent_name nick-seed (republishes the card, so the durable index updates). Wire contract pinned both sides for the new request/response (op tag + field names), mirroring the room_tip per-shape wire tests. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * fix(identity): route per-peer identity index to the coordinator store The per-peer identity index (scoped_state `user:<peer>` / `identity.card`) is owner-core shared state — like the transcript tip, it must live in the machine-account `coordinator_store`, not the scope-local `event_store`. `record_peer_identity_card` was writing the index to `event_store()` (the scope home) while every reader expects it in the machine-account store: the daemon's IPC index (`handle_peer_identity_card` reads `coordinator_store`) and the daemon-less self-resolution path. The write/read split left the daemon's `coordinator_store` with zero `identity.card` rows while cards were stranded in per-scope homes. The symptom downstream: a continuum persona (attached client) resolved peer display names as raw UUIDs ("7711fe60" instead of "Claude") and confabulated names, because the daemon's identity index it reads over IPC was empty. Fix: add `get_coordinator_scoped_state` / `set_coordinator_scoped_state` helpers and route both the write (`record_peer_identity_card`) and the daemon-less read branch (`peer_identity_card`) through them. Because `coordinator_store` is the one shared machine-account `events.sqlite`, any scope that records a card writes it to the single index every sibling scope and the daemon read. The general scope-home `set/get_scoped_state` (tool.mode / wall / coordination) are unchanged. Regression test: `peer_identity_index_converges_across_scopes_via_ coordinator_store` — one scope records a peer card, a different scope sharing the same wire_root resolves it. Pre-fix the reader read its own empty scope store and answered None. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * feat(identity): room_roster_cards + fix daemon coordinator-store fidelity Adds `Airc::room_roster_cards(within, window) -> Vec<RoomMemberCard>`: the richer sibling of `room_roster` that folds the per-peer identity join airc-side, so a continuum positron roster makes ONE call and each present peer carries its full `Identity` card (name/pronouns/role/bio/ integrations) instead of just a display name. `RoomMemberCard` has NO `display_name` field by design — the name lives at `identity.name`, the same durable-index source as `peer_alias`, so there is ONE name source and no drift (a test pins `identity.name == peer_alias`). Building the sibling test surfaced a pre-existing substrate blocker: the durable per-peer identity index was unreadable under a daemon-attached scope. `handle_peer_identity_card` reads the coordinator store at `User(peer)/PEER_IDENTITY_STATE_KEY`, and a scope WRITES that index to its coordinator store (`wire_root/events.sqlite`) via `record_peer_identity_card`. In production (`run_daemon`) the daemon's coordinator is a Sqlite over that SAME machine-account file, so the read sees the write. But `DaemonFixture` handed the daemon a disjoint `InMemoryEventStore` AND rooted it at a different TempDir than the scopes attach against — doubly unfaithful — so every daemon-side identity/alias lookup returned `None`. This is the pre-existing red in `peer_name_survives_identity_card_scrolling_past_the_recent_window`. Fix makes the fixture production-faithful: the daemon's coordinator is a `SqliteEventStore` over `home/events.sqlite` (same file the router uses, matching `run_daemon`), and `Machine` roots the daemon at the shared `root` every scope attaches against (`start_in`) — ONE machine-account `events.sqlite` for daemon + all scopes, exactly like production. Both the pre-existing name-join test and the new `room_roster_cards` test go green. Daemon payload-opacity is untouched (the daemon never parses `IdentityPublished`; it only reads the index scopes durably wrote). Pre-existing unrelated red left as-is: `gh::account_registry::gh_stub::*` fail deterministically (even single-threaded) on this environment — a GitHub gist-rendezvous stub dependency, a different subsystem; out of scope for this identity PR. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Closes #82. Adds relative-time display +
(stale)marker for rooms inactive >24h (configurable viaAIRC_STALE_HOURS).Side fix: the existing rooms list was reading column 4 (visibility = "secret") into the "updated" field — a display bug fixed here on the way to adding activity annotation. Pre-#82 the rooms list literally printed "updated: secret".
Output before / after
Before:
After:
Test plan
airc listnow shows actual timestamps + stale markers🤖 Generated with Claude Code