Skip to content

ui-react: no client clock exists for send, first painted content and idle #4282

Open

Description

@schlessera

Context

Part of #4278.

Every latency figure in #4278 is a host clock. Nothing records what a person experienced:

The complaint that started the investigation was about how the chat feels. The only way to check that a change helped is a clock at the client.

Scope

  • The client records, per turn, elapsed pairs on its own monotonic clock:
  • It reports them to the host once, after idle, keyed by the turn id. Elapsed pairs only: no cross-process clock subtraction.
  • The host stores them beside the turn's lifecycle record.
  • A lost report loses the measurement and nothing else.

Out of scope

Acceptance criteria

  • After a completed turn in the browser test harness, the turn's stored record carries the client pairs, each a non-negative number.
  • With a fixture backend that delays its first content by a known time, the delay appears in "send to first painted content" within one animation frame's tolerance.
  • A turn started on one client and finished while that client is disconnected records no client pairs and is otherwise unaffected.
  • The report cannot be used to write any other field of the turn's record, and a report for a turn the principal does not own is refused, by tests.
  • docs/integration-contract/wire.md describes the client-to-host message and the stored fields.
  • A test covering this fails on the tree before the change and passes after.

Verification

bun run test packages/ui-react packages/ui-server/tests
bun run typecheck
bun run lint

Plus the real browser test for the turn path, run with command-scoped sandbox escalation where the sandbox blocks it.

Contract impact

  • This touches the integration contract, so it needs the contract label, a CONTRACT: commit prefix, and the doc updated in the same commit. Additive: one client-to-host message and optional stored fields.
  • This changes a published package's behaviour, so it needs a changeset.

Decisions needed

The existing host record is persisted by createTurnLifecycle (packages/ui-server/src/activity/turn-lifecycle.ts:14-27). Its turn milestones stop accepting updates at finish (finish, same file:59-62). Decide whether the after-idle browser report is a separate owner-bound receipt joined on read, or whether it extends the same lifecycle through a narrow write procedure. A separate receipt preserves the completed host clock and independent report lifetime at the cost of a join. Updating the lifecycle reuses its record but needs an explicit rule for post-finish replay, duplicates, retention and authorization. Prefer the separate receipt unless an existing append path can provide the same guarantees.

Decide whether the first-content metric means an observed presentation after content commits or client receipt of the content frame. The first follows the reported interaction but needs a browser-supported observation boundary and a defined background/unsupported outcome. The second is easier to validate but reports transport arrival. Prefer the presentation metric with absent values when evidence is unavailable. Browser animation-frame callbacks by themselves do not prove a displayed frame. If choosing arrival, rename the metric and update its acceptance criterion.

#4311 supplies the phase-status field later. The independent send, content and idle measurements can omit that value until the UI supplies it. Record the selected measurement, persistence and ownership semantics here before implementation. Then use the existing wire lifecycle section for the additive contract.

2026-11-20 triage — Updated source and the status reference on 63bb400b3. The remaining choices concern protocol and evidence semantics.

Activity

  1. added
    type: feat
    area: ui-server
    area: ui-react
    on Nov 20, 2026
  2. added
    priority: p2
    needs: decision
    contract
    area: ui-sdk
    on Nov 20, 2026
  3. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-20):

    1. Persistence: a separate, owner-bound client receipt keyed by turn id and joined to the lifecycle record on read. The completed host lifecycle record stays as it is. The receipt has its own authorization (a report for a turn the principal does not own is refused), duplicate handling (the first accepted report wins; later ones are refused without changing it) and retention (it follows the turn's lifecycle record).
    2. First content: client receipt of the first content frame, not an observed presentation. The metric is renamed from "send to first painted content" to "send to first content frame received", and the acceptance criterion reads: with a fixture backend that delays its first content by a known time, the delay appears in "send to first content frame received" within a small stated tolerance. The same applies to the phase pair ("send to first phase status frame received", once ui-react: one "thinking" status covers the ten seconds from accept to first content #4311 supplies it) and to "last content frame received to the idle status received".

    Everything else in the scope stands. needs: decision is removed.

  4. added
    agent-ready
    and removed
    needs: decision
    on Nov 20, 2026
  5. self-assigned this
    on Nov 20, 2026
  6. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-01af4fcb. Branch: feat/4282-client-turn-receipt.

    Worked as part of the #4278 epic integration branch epic/4278-host-overhead (one main landing for the epic). Collisions: none recorded at claim.

  7. added this to the 0.45.0 milestone on Nov 21, 2026
  8. removed their assignment
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-reactarea: ui-sdkarea: ui-servercontractpriority: p2type: feat

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions