Session-title subsystem, lifted out of the loop namespace: the three listener
registries (per-session value, global, and the pending/spinner channel), the
single set-title-with-broadcast! mutation point, and the async auto-title
side-channel (an off-surface ask! that names a session on its first
real turn). A LEAF — depends only on persistance + svar + runtime-settings,
never back on the loop.
Session-title subsystem, lifted out of the loop namespace: the three listener registries (per-session value, global, and the pending/spinner channel), the single `set-title-with-broadcast!` mutation point, and the async auto-title side-channel (an off-surface `ask!` that names a session on its first real turn). A LEAF — depends only on persistance + svar + runtime-settings, never back on the loop.
(add-global-title-listener! listener-fn)Register listener-fn to observe title changes across ALL sessions.
The fn is invoked with the session id (a UUID) and the new title
every time ANY session's title changes - host rename and auto-title
generation alike, since they all funnel through set-title-with-broadcast!.
Returns the listener fn so callers can pass it to
remove-global-title-listener! later.
Register `listener-fn` to observe title changes across ALL sessions. The fn is invoked with the session id (a UUID) and the new title every time ANY session's title changes - host rename and auto-title generation alike, since they all funnel through `set-title-with-broadcast!`. Returns the listener fn so callers can pass it to `remove-global-title-listener!` later.
(add-title-listener! session-id listener-fn)Register listener-fn for session-id. The fn is invoked with
the new title (a string) every time the title changes. Multiple
listeners are supported; they fire in unspecified order.
Returns the listener fn so callers can pass it to
remove-title-listener! later.
Register `listener-fn` for `session-id`. The fn is invoked with the new title (a string) every time the title changes. Multiple listeners are supported; they fire in unspecified order. Returns the listener fn so callers can pass it to `remove-title-listener!` later.
(add-title-pending-listener! session-id listener-fn)Register listener-fn for session-id; invoked with a boolean
(true when title generation starts, false when it ends). Returns the
listener fn for later remove-title-pending-listener!.
Register `listener-fn` for `session-id`; invoked with a boolean (true when title generation starts, false when it ends). Returns the listener fn for later `remove-title-pending-listener!`.
(maybe-auto-title! {:keys [db-info session-id session-title-atom] :as env}
user-request)Title the session asynchronously on a normal LLM turn. Two-phase so a slow or hung provider can never leave the tab untitled:
ask! (model-auto-title!) that
OVERWRITES the fallback with a real title and freezes it. On failure the
provisional fallback stays and a LATER turn retries the upgrade.A real (non-provisional) LLM title is generated once and never regenerated. Titles are host-owned; there is no model-facing override. Returns a future or nil; callers intentionally do not wait.
Title the session asynchronously on a normal LLM turn. Two-phase so a slow or hung provider can never leave the tab untitled: 1. FALLBACK-FIRST — write a deterministic first-words title up front (it cannot hang), marked PROVISIONAL, so the tab is titled instantly. 2. LLM UPGRADE — a hard-deadline-bounded `ask!` (`model-auto-title!`) that OVERWRITES the fallback with a real title and freezes it. On failure the provisional fallback stays and a LATER turn retries the upgrade. A real (non-provisional) LLM title is generated once and never regenerated. Titles are host-owned; there is no model-facing override. Returns a future or nil; callers intentionally do not wait.
(remove-global-title-listener! listener-fn)Deregister a previously added global title listener. Idempotent.
Deregister a previously added global title listener. Idempotent.
(remove-title-listener! session-id listener-fn)Deregister a previously added listener. Idempotent.
Deregister a previously added listener. Idempotent.
(remove-title-pending-listener! session-id listener-fn)Deregister a previously added pending listener. Idempotent.
Deregister a previously added pending listener. Idempotent.
(set-title-with-broadcast! db-info session-id session-title-atom title)Single mutation point for session titles.
session_state row.:session-title-atom so the next iteration's
:session-title-atom mirror sees the new value AND so a
read from the Python sandbox returns the fresh string immediately,
without a DB round-trip.session-title-atom may be nil (host-driven path with no live env).
Single mutation point for session titles. 1. Writes the title to the persisted `session_state` row. 2. Updates the env's in-memory `:session-title-atom` so the next iteration's `:session-title-atom` mirror sees the new value AND so a read from the Python sandbox returns the fresh string immediately, without a DB round-trip. 3. Broadcasts to every registered listener. `session-title-atom` may be nil (host-driven path with no live env).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |