|
| 1 | +# Per-turn completion time and duration in the TUI |
| 2 | + |
| 3 | +## Identity |
| 4 | + |
| 5 | +- Status: active |
| 6 | +- Integration branch: `dev-nowaker` |
| 7 | +- Development branch(es): `tui-turn-timing` (off upstream `dev` `907b3bc518`; also the upstream PR head) |
| 8 | +- First local commit: `17dca85fb5` |
| 9 | +- Current local commit(s): `17dca85fb5` |
| 10 | +- Upstream base when introduced: `907b3bc518` (upstream `dev`) |
| 11 | +- Last checked against upstream: `907b3bc518` (upstream `dev`) |
| 12 | +- Upstream: issue [#53192](https://github.com/anomalyco/opencode/issues/53192), PR [#53195](https://github.com/anomalyco/opencode/pull/53195) |
| 13 | + |
| 14 | +## Original request |
| 15 | + |
| 16 | +Relayed by coordinator `ses_ef8235798ffejGr4sa22eXmVNv` (effort item 3), |
| 17 | +quoting the user: |
| 18 | + |
| 19 | +> each ai turn should show time (if today), datetime (if not today) and how |
| 20 | +> long it took (e.g. 2h3m). additionally, final ai messages (after a series of |
| 21 | +> turns), should have both the time it took to generate final response AND the |
| 22 | +> entire interaction since the prompt that triggered this turn. configurable in |
| 23 | +> tui and in /tui commands. defaults: matching current defaults, whatever they |
| 24 | +> are. |
| 25 | +
|
| 26 | +## Goals |
| 27 | + |
| 28 | +- Every completed assistant turn can show when it finished |
| 29 | + (`Locale.todayTimeOrDateTime`: time of day if today, date and time |
| 30 | + otherwise) and how long it took (`completed - created`). |
| 31 | +- The final turn shows its own duration and keeps the existing total since |
| 32 | + the prompt, labelled `total`. |
| 33 | +- Configurable in `tui.json` and toggleable at runtime. |
| 34 | + |
| 35 | +## Non-goals |
| 36 | + |
| 37 | +- Defaults unchanged: both options off, so only the final message has a |
| 38 | + footer with the total, as upstream. |
| 39 | +- Duration format stays upstream `Locale.duration` (`8.3s`, `3m 12s`, |
| 40 | + `2h 3m`); not reformatted to `2h3m`. |
| 41 | +- No change to `/timestamps`, which still covers user messages only. |
| 42 | + |
| 43 | +## Rationale and constraints |
| 44 | + |
| 45 | +- Vanilla `907b3bc518` renders no footer on intermediate tool-call turns and |
| 46 | + only the prompt-to-completion total on the final one. |
| 47 | +- Two independent booleans, `turn_timing.time` and `turn_timing.duration`, |
| 48 | + instead of a mode enum: the two facts are wanted independently. |
| 49 | +- Runtime toggles `/turn-times` and `/turn-durations` (palette entries, |
| 50 | + keybinds `session_toggle_turn_time` / `session_toggle_turn_duration`, |
| 51 | + default `none`). A toggled value persists in `kv.json` and wins over |
| 52 | + `tui.json`, which only supplies the default; the value is read with |
| 53 | + `kv.get` rather than `kv.signal` so the default is never written to kv. |
| 54 | + |
| 55 | +## Changes |
| 56 | + |
| 57 | +| Commit | Workday | Change | Stable seam | |
| 58 | +|---|---|---|---| |
| 59 | +| `17dca85fb5` | 2026-10-04 | `turn_timing` schema; `showTurnTime` / `showTurnDuration` memos, palette/slash commands, context fields; `AssistantMessage` footer shown for every completed turn when either is on, with time, per-turn duration and `total` suffix; docs and config test | `TurnTiming` in `packages/tui/src/config/index.tsx`; `AssistantMessage` footer in `packages/tui/src/routes/session/index.tsx`; `packages/tui/src/config/keybind.ts` | |
| 60 | + |
| 61 | +## Verification |
| 62 | + |
| 63 | +- `bun typecheck` in `packages/tui` and `packages/opencode` - exit 0 on |
| 64 | + `tui-turn-timing` and on the landing branch. |
| 65 | +- `packages/opencode/test/config/tui.test.ts`: new `loads turn timing config` |
| 66 | + passes (30 pass); 4 plugin-merge tests fail identically on pristine |
| 67 | + `907b3bc518`. `packages/tui/test/config.test.tsx` 9/9. |
| 68 | +- Manual surface: `bun dev` in throwaway tmux socket `oc-tui-timing` |
| 69 | + (140x50), isolated `XDG_*` dirs, a fake OpenAI-compatible provider that |
| 70 | + answers each prompt with two `glob` tool-call steps and a final text step. |
| 71 | + Vanilla: only `▣ Build · Fake · 15.8s` on the final message. Patched with |
| 72 | + defaults: identical. Both toggles on: `· 1:07 PM · 8.3s`, `· 1:07 PM · |
| 73 | + 3.5s`, `· 1:07 PM · 3.7s · 15.6s total`. Time only: `· 1:07 PM` on each, |
| 74 | + final `· 1:07 PM · 15.6s`. `tui.json` `{"turn_timing":{"duration":true}}` |
| 75 | + with no kv override, after restart: durations shown from the start. |
| 76 | + |
| 77 | +## Timeline |
| 78 | + |
| 79 | +- 2026-10-04 |
| 80 | + [`ses_ef81c1485ffeC5Sb59U9mVI77g`](../sessions/2026-10-04-tui-turn-timing.md) |
| 81 | + - `17dca85fb5`: introduce (cherry-pick of `2fda6d8d7a`, conflicts with |
| 82 | + `keep_scroll_on_submit` resolved by keeping both); open upstream issue |
| 83 | + #53192 and PR #53195. |
| 84 | + |
| 85 | +## Current maintenance notes |
| 86 | + |
| 87 | +- Drop the fork commit once PR #53195 (or an equivalent) is in upstream `dev`. |
| 88 | +- Adjacent to `keep_scroll_on_submit` in the `Info` schema and the session |
| 89 | + command list; an upstream bump touching either may conflict textually. |
| 90 | + |
| 91 | +### Upstream integration checklist |
| 92 | + |
| 93 | +- Locate `TurnTiming` and `turn_timing` in `packages/tui/src/config/index.tsx`. |
| 94 | +- Locate `showTurnTime`, `showTurnDuration` and the `completed` memo in |
| 95 | + `packages/tui/src/routes/session/index.tsx`. |
| 96 | +- Run `bun typecheck` in `packages/tui`. |
| 97 | +- Run `/turn-times` and `/turn-durations` on a multi-step turn and check |
| 98 | + every assistant footer. |
| 99 | +- Link a new timeline row to the current session record. |
| 100 | + |
| 101 | +## Supersession or removal |
| 102 | + |
| 103 | +- Not applicable; status is active. |
0 commit comments