Skip to content

Move web chat onto the event queues' interactive lane #8151

Open

Description

@senamakel

Parent: #8147

Summary

Move web chat onto the queues' interactive lane, with the gate bypassed, so web chat gets the same durability, dedupe and per-conversation ordering without added latency.

Problem

Web chat is the one inbound path a user is actively waiting on, and it is still outside the pipeline: a crash mid-turn loses the message, and double-submits are deduped only ad hoc.

Solution

  • Ingest web chat as instant cadence in the interactive lane, gate and salience bypassed (the user is always addressing the agent).
  • Deliver calls the existing web chat start/steer path.
  • Do this last, after the channel migrations have proven the delivery path.

Acceptance criteria

  • Latency — added time-to-turn-start from the queue hop is measured and stays within a small fixed bound (state the number in the PR).
  • Durable — a message sent just before a core restart is delivered after it, once.
  • Double-submit deduped — the same client message id twice produces one turn.
  • Ordering — messages within one thread are delivered in order, one turn in flight.
  • Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/ci-fast.yml).

Related

Part of #8147. Builds on #8136 (inbound domain, tinyeventqueues v0.1.2) and tinyhumansai/tinyeventqueues#6.

Audit findings (2026-10-20)

  • Entry path: RPC channel.web_chat → handle_chat (web_chat/schemas.rs:158) → channel_web_chat (ops/channel_ops.rs:248-306) → start_chat (ops/start_chat.rs:141).
  • Request id: request_id is a fresh Uuid (start_chat.rs:225).
  • No client message id reaches the core.
    • The app sends client_id (socket), thread_id, message, model, locale, queue_mode and reasoning_effort (app/src/services/chatService.ts:1681-1692).
    • The frontend persists the user message itself (ChatRuntimeProvider.tsx:634-651), and its ThreadMessage.id is the natural dedupe key. The app has to start sending it.
  • Queue modes (start_chat.rs:356-361):
    • steer/followup/collect push into the running turn's RunQueue (L389-419);
    • parallel uses its own lane;
    • the default is interrupt.
    • RunQueue, IN_FLIGHT and the parallel state (ops/state.rs) are in memory only.
  • Module support: the fast path (gate bypass, zero debounce, immediate wake) comes from [inbound-queues] sources: per-source gate bypass and debounce override for web chat senamakel/tinyeventqueues#3. Without it, web chat would wait about 1.5 s per message.

Agent brief

Depends on: senamakel#514, senamakel/tinyeventqueues#3 · Blocks: senamakel#515 · Parallel with: #8148, #8149, #8150

Research first

  • How steer/collect/interrupt semantics map onto queued delivery. The queue serializes one turn per conversation, but interrupt must still cancel an in-flight turn immediately. That control action probably stays direct, with only the message itself queued.
  • The latency budget. Measure time-to-turn-start before and after with pnpm debug web and record both in the PR.

Files to consider

  • Read: crates/openhuman-core/src/web_chat/ops/channel_ops.rs:248-306, web_chat/ops/start_chat.rs:141-481, web_chat/ops/state.rs, app/src/services/chatService.ts:1670-1700, app/src/providers/ChatRuntimeProvider.tsx:620-660
  • Change: web_chat/ops/channel_ops.rs (ingest via inbound::route), the web: handler in inbound/deliver/, app/src/services/chatService.ts (send the client message id), its Vitest test
  • Tests: web_chat/ops/*_tests.rs, app/src/services/chatService.test.ts, a tests/json_rpc_e2e.rs case

Workflow: implementing-an-epic step.

Subagents: tdd-implementer (Sonnet), then code-reviewer.

Gates: cargo check --manifest-path Cargo.toml · pnpm rust:clippy · cargo test -p openhuman web_chat inbound · pnpm test -- chatService · pnpm typecheck · pnpm rust:layout

Activity

  1. added
    subtask
    feature
    rust-core
    on Oct 20, 2026
  2. M3gA-Mind commented on Nov 16, 2026

    @M3gA-Mind
    Collaborator

    Re-checked on current main: not done yet. Web chat doesn't go through inbound, and each message gets a fresh id, so dedupe and durability are still the ad-hoc ones. As the issue says, this one comes last, after the channel migrations (#8148, #8149). Keeping it open.

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

    featurerust-coresubtask

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions