Skip to content

Fold Projects into a Clients master-detail tab (ALI-2617) - #16

Merged
michaelaguiar merged 2 commits into
mainfrom
ali-2617-tui-clients
Dec 4, 2026
Merged

michaelaguiar merged 2 commits into
mainfrom
ali-2617-tui-clients

Conversation

@michaelaguiar

Copy link
Copy Markdown
Member

Fixes ALI-2617

What changed

The TUI goes from four tabs to three (Timers, Clients, Reports). Projects are now the detail side of Clients, drawn from the "Redesign · TUI · Clients" and "Edit client, with error" boards on the Notch design canvas.

  • Client list: rate, this month's hours and earned, unbilled (every month, as in clients -json), and a project count under each client. A client with no rate shows — for rate, earned and unbilled.
  • Projects pane: the selected client's projects with this month's hours and earned, "+ Add project", then the client's hourly rate, start date ("Since", from when the client was created), all-time hours and earnings, and unbilled amount with its entry count. The pane's border turns primary while it has the keys, and its rows get the ▌ cursor, so focus never rests on colour alone. Long project lists scroll, with "↑ N more" / "↓ N more" rows.
  • Keys: n new client, a add project, e edit, → (or enter) into projects, d delete. In the pane, e and d act on the project, enter edits it (or adds one on "+ Add project"), and ← or esc go back.
  • At 90 columns: below tui-wide (120) the list takes the whole width, and → opens the pane in its place.
  • Edit client: the modal is 60 wide, as on the board (new token tui-modal-width-narrow). A rate that isn't a number shows "✕ Enter a number, like 95 or 95.50." under Rate, and the status line counts it.
  • Project form and confirm (projects.go, now projectsPane): they keep their behaviour. Each stores the project ID when it opens and re-reads it, closing with "That project no longer exists" if it's gone. esc and n keep in the confirm, and the Client field with suggestions still moves a project to another client. New project opens with the selected client filled in and the focus on Name. Typing a client name without picking a suggestion now prefers the exact-case match.
  • IsBusy covers the project form and confirm, so q types there and only ctrl+c quits.
  • When the database changes while the Clients tab is showing, the tab reloads.
  • Tabs renumber to 1–3. The ? keys sheet (still fits at 90×32 without scrolling), the README key tables and the landing page follow.
  • New tokens in design/tokens.json: tui-modal-width-narrow, tui-client-name-min, tui-client-col-rate|hours|earned|unbilled, tui-client-pane-earned|label|gap. The usage notes for warning, tui-wide and tui-min-width are updated. No new colours.

Testing

  • gofmt -l . (empty), go vet ./..., go test -count=1 ./..., go run ./design/build -check (31 contrast pairs pass).
  • The Projects tab's list tests are replaced. Its form and confirm tests moved to projectsPane in projects_test.go.
  • New tests:
    • the layout at 140×40, column for column against the board (internal/ui/clients_test.go);
    • the list alone and → / ← at 90×32;
    • add project from the pane and from the list;
    • e and d following the focus;
    • moving a project to another client;
    • pane scrolling;
    • the selection following its client across reloads;
    • hotkeys by focus;
    • the Edit client rate error and its 60-wide modal;
    • the totals in loadClientsData;
    • q typing in the project form;
    • the reload on database change.
  • Each important test was shown failing with its code removed: layout, the a key, the modal width, rate validation, IsBusy, the reload, the keys sheet, the unbilled entry count, and e in the pane.

Design notes

  • Clients and projects are listed by name, as the CLI and database return them. The board's sample happens to show them by hours.
  • The board shows no state for the pane with focus or for 90 columns. The focused pane uses the primary border and a ▌ cursor, and at 90 columns → opens the pane in place of the list (like the Timers compact layout's details).

To try live

  • 2 on real data: check the figures against notch clients -json, and that the "Since" date reads right.
  • Move through the clients, → into a client's projects, add, rename, move and delete a project, and ← back.
  • Narrow the terminal below 120 columns and use → / ←.
  • Edit a client with a rate like 95/hr, and check the error and the "1 field needs fixing" status.

The TUI goes from four tabs to three. The Clients tab lists each client
with its rate, this month's hours and earned, its unbilled amount and a
project count, beside a pane with the selected client's projects (hours
and earned this month), "+ Add project", and the client's rate, start
date, all-time totals and unbilled. Below 120 columns the list takes the
width and → opens the pane in its place.

Keys: n new client, a add project, e edit, → into projects, d delete;
in the pane e and d act on the project, enter edits it or adds one on
"+ Add project", and ← or esc go back. The project form and delete
confirm keep their behaviour (ID stored on open, re-read on save, Client
field moves a project). The client modal is 60 wide, per the board.
Tabs renumber to 1-3; the keys sheet, README and landing page follow.

New layout tokens: tui-modal-width-narrow and the tui-client-* columns.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 1

A fresh reviewer ran code-review (high). Checks pass. Everything the old Projects tab did is still reachable from Clients:

  • new project (a, or "+ Add project");
  • edit and rename;
  • move a project to another client;
  • delete with a confirm;
  • the "no client yet" guard.

The decided rules hold:

  • forms and confirms keep the record's ID and re-read it from the database;
  • esc and n keep in confirms;
  • IsBusy covers both forms and both confirms.

Being fixed:

  • P2: the bottom bar's "✕ N fields need fixing" count ignores project form errors. This is a regression from the old Projects tab.
  • P3: if the selected client is deleted elsewhere, the pane stays open on a neighbour's projects.
  • P3: the tui-modal-width usage note is stale.
  • P3: n is missing from the pane's key line.
  • P3: the pane height is hand-counted, and misses the "No projects yet." row.
  • P3: large amounts are cut with "…" and read as a different number.

No change: loading every entry on each Clients reload is fine at normal data sizes.

- Count the project form's field errors in the status line.
- Close the projects pane, and say so, when a reload no longer has its
  client, instead of showing a neighbour's projects.
- Offer n new client in the pane's hotkey line; it fits at 90 columns.
- Count the pane's fixed rows from the rows it draws.
- Never cut an amount: money columns drop the cents, then go compact
  ($123k, $1.2M), to fit.
- Say which forms use tui-modal-width.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 2 (final, narrow)

f3a3af1 fixed round 1's findings:

  • P2: the bottom bar now counts project form errors.
  • P3:
    • The projects pane closes when its client is deleted elsewhere.
    • The pane's key line includes n.
    • The pane's height is derived from the rows it draws.
    • Amounts are never cut. They fall back to whole dollars, then a compact form like "$1.3M".
    • The token usage note is updated.

A fresh reviewer checked that commit. Its code-review skill run started in the background but didn't report back, so the reviewer checked each claim by hand. It ran vet, the tests and design/build -check, all passing, and ran the money boundaries in a scratch copy:

  • 999,950 gives "$1M", never "$1000k";
  • negative amounts keep their sign;
  • the longest compact form is 6 cells, well inside every column.

All six claims hold, and nothing was found at P1 or P2.

Not changed (P3, pre-existing):

  • A tiny negative amount would show "-$0". It's unreachable, since earnings can't be negative.
  • If the client is deleted elsewhere while a project form is open on it, two "no longer exists" messages can race. This is cosmetic only.

The review stops here.

@michaelaguiar
michaelaguiar marked this pull request as ready for review December 4, 2026 17:53
@michaelaguiar
michaelaguiar merged commit de36ad4 into main Dec 4, 2026
1 check passed
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