Skip to content

Commit ecf22bf

Browse files
committed
Add synchronized TUI mode
1 parent 9f2213d commit ecf22bf

19 files changed

Lines changed: 2484 additions & 18 deletions

README.md

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ AgentMeter is a local-first dashboard for understanding coding-agent session usa
1515
tokens, estimated cost, timing, session history, and tool-call behavior.
1616

1717
It reads local agent JSONL session files, indexes them into SQLite, and shows the data
18-
in a private local browser UI. No proxy, no cloud service, no telemetry.
18+
in private local Web and terminal interfaces. No proxy, no cloud service, no telemetry.
19+
20+
The Web UI is the default MVP interface. The TUI is available as a terminal MVP
21+
over the same local database, indexing pipeline, pricing rules, and query
22+
semantics.
1923

2024
## Why AgentMeter
2125

@@ -41,6 +45,8 @@ can actually use:
4145
- Incremental indexing based on path, size, modified time, and content hash.
4246
- Built-in pricing registry with unknown models clearly marked as `unpriced`.
4347
- Local Go HTTP server with a Vue 3 + Vite frontend.
48+
- TUI mode for terminal workflows, kept in sync with the Web UI through shared
49+
backend/query behavior.
4450

4551
## Privacy Model
4652

@@ -110,6 +116,43 @@ Open:
110116
http://127.0.0.1:34115
111117
```
112118

119+
### UI Modes
120+
121+
Web mode remains the default:
122+
123+
```powershell
124+
go run . -http 127.0.0.1:34115
125+
```
126+
127+
You can select a mode explicitly:
128+
129+
```powershell
130+
go run . -ui web -http 127.0.0.1:34115
131+
go run . -ui web -static frontend/dist
132+
go run . -ui tui
133+
```
134+
135+
Behavior:
136+
137+
- `-ui web` starts the local HTTP API and browser dashboard.
138+
- `-ui tui` starts the terminal UI without opening a browser or HTTP listener.
139+
- Web remains the default for compatibility with the MVP.
140+
- `-http` and `-static` apply to Web mode.
141+
- Both modes must use the same SQLite data, pricing rules, filters, and usage
142+
calculations.
143+
144+
TUI keys:
145+
146+
```text
147+
1-4 / tab switch screens
148+
up/down select or scroll
149+
enter open selected session detail
150+
b / esc back from detail
151+
r refresh current screen
152+
i / I index now / rebuild index
153+
q quit
154+
```
155+
113156
For frontend development with Vite hot module reload, run the backend and
114157
frontend dev server in separate terminals:
115158

@@ -152,21 +195,39 @@ already includes:
152195
- Normalized sessions, events, token usage, model calls, and tool calls.
153196
- Vue 3 + TypeScript frontend using Ant Design Vue and ECharts.
154197
- MVP screens for Overview, Sessions, Session Detail, Tools, and Settings.
198+
- TUI mode with Overview, Sessions, Session Detail, Tools, Settings, refresh,
199+
and index actions over the same application services.
155200

156201
## Development Checks
157202

203+
Run the shared backend checks:
204+
205+
```powershell
206+
go test ./...
207+
```
208+
209+
Run the Web build check:
210+
158211
```powershell
159212
cd frontend
160213
npm ci
161214
npm run build
162215
cd ..
163-
164-
go test ./...
165216
```
166217

218+
For TUI changes, run the backend tests and a terminal smoke check covering
219+
startup, keyboard navigation, resize behavior, indexing, and parity for Overview
220+
totals, Session Detail values, and Tools aggregates against Web mode for the
221+
same database.
222+
223+
When shared query behavior changes, update both UI expectations in the same
224+
change: Web views, TUI screens, README command examples, and
225+
`docs/ui-modes.md`.
226+
167227
## Roadmap
168228

169-
Planned directions include packaged builds, more coding-agent adapters, export formats, project grouping, custom pricing, and
229+
Planned directions include richer TUI filters, packaged builds, more
230+
coding-agent adapters, export formats, project grouping, custom pricing, and
170231
richer timeline views.
171232

172233
See [Roadmap](docs/roadmap.md) for details.
@@ -175,6 +236,7 @@ See [Roadmap](docs/roadmap.md) for details.
175236

176237
- [Project Brief](docs/project-brief.md)
177238
- [Architecture](docs/architecture.md)
239+
- [UI Modes](docs/ui-modes.md)
178240
- [Data Model](docs/data-model.md)
179241
- [Codex Session Format](docs/codex-session-format.md)
180242
- [Roadmap](docs/roadmap.md)

docs/architecture.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
## Decision
44

5-
Use a Go HTTP backend, SQLite storage, and a Vue 3 + Vite + TypeScript frontend.
5+
Use a Go application core with SQLite storage, shared query services, and two
6+
local interfaces:
7+
8+
- Web UI: the current Vue 3 + Vite + TypeScript browser dashboard served by the
9+
Go HTTP backend.
10+
- TUI: a terminal interface over the same app services, database, pricing rules,
11+
and query semantics.
612

713
## Why Go HTTP + Vite
814

@@ -17,10 +23,17 @@ During development, Vite serves the frontend and proxies `/api` to the Go
1723
backend. For local production use, the Go server can serve the built
1824
`frontend/dist` assets from disk.
1925

26+
The HTTP API remains the Web mode boundary. TUI mode should not require a
27+
separate ingestion path or a second persistence layer.
28+
2029
## High-level Components
2130

2231
```text
2332
AgentMeter
33+
interfaces
34+
web dashboard
35+
terminal UI
36+
2437
frontend
2538
Vue views
2639
charts
@@ -34,7 +47,7 @@ AgentMeter
3447
ingestion pipeline
3548
SQLite repository
3649
pricing service
37-
query service
50+
shared query service
3851
export service
3952
4053
storage
@@ -68,6 +81,8 @@ internal/
6881
model/
6982
pricing/
7083
query/
84+
tui/
85+
viewmodel/
7186
export/
7287
platform/
7388
```
@@ -81,12 +96,14 @@ Responsibilities:
8196
- `model`: normalized domain structs.
8297
- `pricing`: model aliases, pricing table, cost calculation.
8398
- `query`: read models for UI screens.
99+
- `viewmodel`: shared display formatting and presenter helpers for UI parity.
100+
- `tui`: terminal UI mode over `app.App`.
84101
- `export`: JSON and CSV export.
85102
- `platform`: OS-specific database and default source path discovery.
86103

87104
## UI Shape
88105

89-
MVP screens:
106+
The Web and TUI interfaces should cover the same product areas:
90107

91108
- Overview
92109
- Sessions
@@ -114,6 +131,48 @@ Session Detail should show:
114131
- tool calls;
115132
- raw source path.
116133

134+
The Web UI can use charts, wide layouts, and browser affordances. The TUI can
135+
use tables, panes, keyboard navigation, and compact summaries. Differences in
136+
presentation are acceptable; differences in totals, filters, status labels, or
137+
drill-down semantics are not.
138+
139+
## Interface Synchronization
140+
141+
Web and TUI modes should stay synchronized by design:
142+
143+
- Token totals, cost estimates, durations, model normalization, and status
144+
labels come from shared backend logic.
145+
- Overview, Sessions, Session Detail, Tools, Settings, and Pricing data use
146+
shared query semantics.
147+
- Filtering and sorting rules should not be reimplemented with different
148+
behavior in each UI.
149+
- New shared user-visible behavior should update both interface expectations in
150+
the same change.
151+
- Documentation for command examples and UI capabilities should be updated with
152+
the implementation state.
153+
154+
## Command Line
155+
156+
Default Web command:
157+
158+
```powershell
159+
go run . -http 127.0.0.1:34115
160+
```
161+
162+
Interface selector:
163+
164+
```powershell
165+
go run . -ui web -http 127.0.0.1:34115
166+
go run . -ui web -static frontend/dist
167+
go run . -ui tui
168+
```
169+
170+
Behavior:
171+
172+
- `web` is the default mode for MVP compatibility.
173+
- `-http` and `-static` apply to Web mode.
174+
- TUI mode runs in the terminal and does not start an HTTP listener.
175+
117176
## Runtime Rules
118177

119178
- AgentMeter must not modify source session files.

docs/project-brief.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,20 @@ The current version supports:
3333
- session duration from local JSONL timestamps;
3434
- tool-call statistics from local session events;
3535
- SQLite indexing;
36-
- local browser UI.
36+
- local browser UI;
37+
- synchronized terminal UI MVP.
38+
39+
## Interface Direction
40+
41+
AgentMeter should support two local interfaces over one shared application core:
42+
43+
- Web UI for the current dashboard-oriented experience.
44+
- TUI for terminal-first workflows, SSH sessions, and users who prefer staying
45+
inside a shell.
46+
47+
The two interfaces should share the same database, indexing pipeline, pricing
48+
rules, query semantics, and user-visible definitions for tokens, cost, duration,
49+
status, filters, and session identity.
3750

3851
## Non-goals For MVP
3952

@@ -44,6 +57,7 @@ The current version supports:
4457
- Remote database.
4558
- Automatic uploads or telemetry.
4659
- Complex eval workflows.
60+
- Divergent Web-only and TUI-only business logic for the same usage concepts.
4761

4862
## User
4963

@@ -68,7 +82,7 @@ The first user is a developer who uses local coding agents and wants to understa
6882

6983
## First Usable Version
7084

71-
The first useful build should let a user open AgentMeter, point it at one or
85+
The first useful Web build should let a user open AgentMeter, point it at one or
7286
more local agent data directories if needed, index sessions, and inspect:
7387

7488
- overview totals;
@@ -77,3 +91,7 @@ more local agent data directories if needed, index sessions, and inspect:
7791
- session detail timeline;
7892
- model usage;
7993
- tool-call counts and durations.
94+
95+
The first useful TUI build exposes the same core data in a terminal: Overview
96+
totals, session list, session detail, tool aggregates, settings, index trigger,
97+
and clear parse/pricing status labels.

docs/roadmap.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Deliverables:
6060
- session rows in SQLite;
6161
- parser test coverage.
6262

63-
## Phase 3: MVP UI
63+
## Phase 3: MVP Web UI
6464

65-
Goal: make the indexed data useful.
65+
Goal: make the indexed data useful in the browser.
6666

6767
Screens:
6868

@@ -83,9 +83,47 @@ Tasks:
8383

8484
Deliverables:
8585

86-
- usable local dashboard for local coding-agent sessions.
86+
- usable local Web dashboard for local coding-agent sessions.
8787

88-
## Phase 4: Packaging
88+
## Phase 4: TUI Mode
89+
90+
Goal: keep the terminal interface useful without splitting AgentMeter into two
91+
products.
92+
93+
Interface contract:
94+
95+
- Web mode remains the default MVP path.
96+
- TUI mode uses the same SQLite database, pricing rules, indexing pipeline, and
97+
query semantics as Web mode.
98+
- UI differences are presentational only: terminal tables and panes can replace
99+
charts, but totals, filters, statuses, and drill-down meaning must match Web.
100+
101+
Implemented command line:
102+
103+
```text
104+
go run . -ui web -http 127.0.0.1:34115
105+
go run . -ui web -static frontend/dist
106+
go run . -ui tui
107+
```
108+
109+
Delivered:
110+
111+
- Add `-ui web|tui` mode selection while keeping Web as the default.
112+
- Define shared display helpers for formatting, status classification, Overview
113+
derived metrics, and Tools summary.
114+
- Implement TUI navigation, table browsing, and session detail panes.
115+
- Support an index trigger and visible indexing/parse status in TUI mode.
116+
- Add terminal resize and narrow-width behavior.
117+
- Document TUI keyboard behavior and README examples.
118+
119+
Remaining:
120+
121+
- Add search/filter entry in TUI Sessions.
122+
- Add parity checks comparing Web and TUI values for the same database.
123+
- Improve compact visual treatment for pricing, parse status, and long paths.
124+
- Add terminal smoke checks to release validation.
125+
126+
## Phase 5: Packaging
89127

90128
Goal: make cross-platform usage easy.
91129

@@ -95,6 +133,7 @@ Tasks:
95133
- macOS portable build.
96134
- Linux portable build.
97135
- Installer or portable zip.
136+
- Package both Web and TUI modes from the same binary when TUI mode is ready.
98137
- Local database path decision.
99138
- Log file location.
100139
- Basic crash/error reporting to local logs only.
@@ -103,7 +142,7 @@ Deliverables:
103142

104143
- Windows release artifact.
105144

106-
## Phase 5: Beyond MVP
145+
## Phase 6: Beyond MVP
107146

108147
Possible additions:
109148

@@ -116,4 +155,5 @@ Possible additions:
116155
- richer model-call timeline.
117156
- project grouping.
118157
- custom pricing UI.
158+
- TUI command palette and saved filter shortcuts.
119159
- dark/light theme.

0 commit comments

Comments
 (0)