Skip to content

Traffic: running turns live in their sessions; running rows tick on core's clock - #208

Merged
fylorn merged 1 commit into
devfrom
ui/traffic-core-data
Sep 25, 2026
Merged

fylorn merged 1 commit into
devfrom
ui/traffic-core-data

Conversation

@fylorn

@fylorn fylorn commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Traffic page follow-up to core v0.48.0 (#202): running turns belong to their sessions from the start, and running requests show how long they have been running, measured on core's clock.

Sessions view

  • A running turn is grouped into its session from request_started.session, so it no longer sits as a loose row at the top.
  • The session header counts the turns its stored summary (SessionView) does not have yet: running turns (a row is stored at its ending) and turns that landed after the summary was read. The count never goes below the number of the session's rows in the table, so a turn that ends while a later one is already stored does not make the header drop by one until the summary is re-read. Models and the start/end span include those turns too; peak context and cost stay with the stored summary.
  • A live session gets the pulsing pending dot before its start time, with a tip saying how many turns are in progress. It is not in the status cell: that cell is the widest in the grouped table, and 10 more px push it past the default window (measured: 857 of 864 px in Chinese); the time cell has room.
  • A brand-new session (first turn still running) appears immediately as a live session; peak context and cost read "—" until core has a summary.

Session sheet

  • Turns missing from the stored detail (running, or landed before the detail is re-read) are appended to the cost waterfall from the table's rows; a running turn reads "In progress" where its amount will be (no column appears and disappears as turns start and end). Turns, failed turns and duration include them.
  • For a session whose first turn is still running, core answers control.session_not_found. The sheet then opens from the table's rows instead of showing an error, and switches to the stored detail once the turn lands.

Elapsed time on core's clock

  • Running rows show ttfb→m:ss in the latency column, counting up once a second (same format as the menu bar's "In Progress" list); the request drawer's total time does the same while the request runs. This replaces the old 1966→… placeholder.
  • Elapsed = core's now − the start's at_ms, both on core's clock (src/traffic/clock.ts). The offset is set from /in-flight's now_ms at the midpoint of the round trip on every snapshot (window open, core back to running, dropped events) and raised by every request_started.at_ms as it arrives (core's clock is at least there), so it keeps up between snapshots. It resets with the connection. Core's at_ms is never compared with Date.now() directly.
  • The tick writes the cell's text directly; rows and the table do not re-render. A React-state tick (tried first) is an update above the deferred full-table render's priority: it restarted that render every second, and in the dev build the table stayed on its first rows.
  • The page header's 30-minute sparkline aligns its minutes to core's clock as well.

Checks

  • pnpm typecheck && pnpm test && pnpm build (41 files, 397 tests). No Rust changes.
  • New tests: src/traffic/clock.test.ts (offset from snapshots and start events, reset, shared ticker, format) and header tallies in src/traffic/grouping.test.ts (running turn, landed-before-reread turn, brand-new session, the parallel-turn case, a running turn older than the summary's first turn).
  • Preview harness (1100×720, zh/en, light/dark): the running row ticks once a second with no DOM mutations outside the latency cells; the full 2,000-row table renders within about 1 s with the tick running; with ?live, header and sheet turn counts never step back as turns end; a synthetic brand-new session shows as live, its sheet opens from rows while running and after it ends.
  • Keyboard: cursor-probe.js passes in Chromium (flat and grouped) and in WKWebView (flat, plus the grouped JS sweeps): no off-screen selection, no jumps, no horizontal scroll. Row heights are unchanged (live and idle headers are both 32 px).
  • Grouped table widths are unchanged (min-content 857 px zh / 879 px en collapsed).

🤖 Generated with Claude Code

…ore's clock

- Sessions view: a running turn sits in its session from request_started. The
  session header counts the turns its stored summary does not have yet
  (running, or landed before the summary is re-read; never less than the rows
  in the table) and marks a live session with a pulsing dot before its start
  time. A brand-new session shows up as a live session right away, with "—"
  for peak context and cost until core has a summary.
- Session sheet: turns missing from the stored detail (running, just landed)
  are added from the table's rows. A session whose first turn is still running
  (core answers control.session_not_found) opens from those rows instead of
  showing an error.
- Running rows tick: latency reads "ttfb→m:ss" and counts up once a second;
  the drawer's total time does the same. Elapsed is core's now minus the
  start's at_ms, both on core's clock: the offset comes from /in-flight's
  now_ms (midpoint of the round trip) on every snapshot and is raised by each
  request_started's at_ms. The tick writes the text directly, so rows and the
  table do not re-render; a React-state tick interrupted the deferred
  full-table render every second and left the table on its first rows.
- The traffic sparkline aligns its minutes to core's clock.
- Waterfall amount and mark columns fit "In progress" and "Canceled" in
  English.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit c8f70ed into dev Sep 25, 2026
4 checks passed
@fylorn
fylorn deleted the ui/traffic-core-data branch September 25, 2026 06:48
fylorn added a commit that referenced this pull request Sep 25, 2026
…anges; fetch-core.sh says dev builds need it too

Overview, routing, dry-run, remote-switcher and traffic changed on dev
(#206, #207, #208). The comment at the top of fetch-core.sh still said a
dev build needs neither the network nor resources/twcore; the Tauri build
checks the resource at compile time, so a fresh checkout runs the script
once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 25, 2026
…hots (#201)

* docs: rewrite the READMEs for the current app and use the new screenshots

The READMEs showed screenshots of the old sidebar, including a Findings
page that no longer exists, and said nothing about connecting to a
remote core, the interface languages or the system tray. Both are
rewritten in the same structure, from what the code does today:

- An opening in the approved register, then the platforms, the
  interface languages and in-app updates.
- One section per page (Overview, Traffic, Clients, Keys, Upstreams,
  Routing, Security, MCP, Settings). Security is written from
  tw-config's guard defaults and built-in rules, MCP from tw-adopt's
  targets and tw-scan's sources, and the list of system notifications
  from src-tauri/src/notices/rules.rs.
- "Connecting to a remote core": Settings > Connection, the pages that
  always act on this machine (Clients, MCP), where the connection key
  is kept, what changes while connected; links to Core's server
  deployment guide.
- Layout: the control channel over a unix socket, a loopback port or a
  remote TCP port, each behind the Noise NNpsk0 handshake, replacing
  the per-launch credential the old text described.

Images now come from the committed pipeline: the zh README uses
docs/screenshots/zh/, the English one docs/screenshots/en/, both with
the light/dark <picture> switch, and the overview sits in the
introduction of both. A fresh `pnpm shots` run on this base produced
identical files, so no image changes. The 28 old root-level images are
deleted; nothing in this repository, the website or the organization
profile links to them (the latter two keep their own copies).

Build from source now fetches twcore first: Tauri checks declared
resources at compile time, so `pnpm tauri dev` fails in a fresh
checkout without it, while CONTRIBUTING said it needed nothing. Also
spell "Apple silicon", and give package.json and Cargo.toml a
description that names the platforms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: name the platforms before the gateway in the English opening

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say how a new version is announced, and give the mismatch command

The Updates section said a small window appears when there is a new
version. The automatic check sends a system notification instead
(updater.rs: update_loop -> notify_update), and only when notices are
set to system notifications. The update window opens from that
notification, from the Install Version item that replaces Check for
Updates in the menu bar or tray menu, and from Settings > About. The
notifications paragraph now mentions the new-version notification too.

For a Homebrew installation the check reads the tap's cask, so the
sentence that said when the window appears now says when a new version
is reported.

Connecting to a remote core: when the server's core version differs,
the app gives `sudo twcore upgrade --version <version> --restart`, which
installs the expected version whether it is newer or older than the
installed one (#204). Both languages say the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: re-shoot the screenshots on core v0.48.0

`pnpm shots` on dev 2fa65fd changes five scenes, because #202 and #203
changed what they show:

- remote-add: the connection test reports core 0.48.0, the version the
  app now pins (a 0.47.0 server would be a version mismatch). The alt
  text in both READMEs says 0.48.0.
- traffic: the request in progress shows its status code and token
  count, replayed from /in-flight.
- routing and dry-run: the map marks the upstream with a request in
  flight.
- security: the header counts the entries by outcome.

The other alt texts still describe their images. The website copies in
docs/screenshots/web/ are regenerated with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: re-shoot five scenes after the overview, routing and traffic changes; fetch-core.sh says dev builds need it too

Overview, routing, dry-run, remote-switcher and traffic changed on dev
(#206, #207, #208). The comment at the top of fetch-core.sh still said a
dev build needs neither the network nor resources/twcore; the Tauri build
checks the resource at compile time, so a fresh checkout runs the script
once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant