Last time: the Projected tab, and a night that ended with one rule for what counts as money, in one function every tab calls. This chapter is the first feature built on that rule from the start.
TL;DR
- Categories say what a transaction is: food, transport, lodging. Tags say what it belongs to: a trip, a project. The Tags tab adds up tagged transactions over time, one stacked segment per tag.
- A transaction can carry several tags. Stacking each tag’s full total would count it twice, and the bar would overstate what was spent.
- The agent’s first version put every multi-tag transaction into one gray “Several tags” segment. I replaced it: each combination of checked tags gets its own segment. Every transaction still lands in exactly one segment, so the bar is still the true total.
- The analytics service returns each transaction’s exact set of tags per period, which is what made the change a dashboard-only one.
What it’s for
I wrote the why before any code, on Oct 13:
“I need this feature b/c I want to see the total and average expense of a common collection of transactions. Tags are cross-category and mark transactions that should be viewed as one. Ex. I could tag all expenses of a trip under a tag; since the expenses vary in function they would be in different categories, but I can pull them together using the tag.”
The rest of the request: the same time chart as the other tabs, several tags selectable at once and stacked, each tag identified in the stack, and the usual percentages in the legend and tooltip.
Reading before building
Claude Code read the three existing chart tabs and the analytics service first. The /tags endpoint was a stub that answered 501. The most recent tab was the template.
It also loaded its chart guidance before writing any chart code, and made one decision there: reuse the dashboard’s existing 8-color palette in its fixed order. That palette had already been validated for color-blind readers in both themes, so nothing new needed checking.
The backend: exact tag sets
The new report, in reports/tags.ts, returns two things:
- Each tag’s own total. Every transaction carrying the tag counts toward it. So tag totals can add up to more than the overall total, and that’s correct.
- Per period, the exact set of tags each group of transactions carries. Not “Trip” and “Work” as two sums, but “Trip alone”, “Trip and Work together”, and so on. This is the detail that mattered later.
Two smaller fixes went into the loader on the way:
- Tags are matched by id, not by name. Two tags can share a name.
- A duplicated tag link counts once. A backup can link the same tag to the same transaction twice.
The money follows the rule from the last chapter: executed transactions only, nothing from excluded accounts, no transfers between included accounts. The agent didn’t restate those rules in the new report. It called the shared function.
The dashboard
The stacking logic went into a small pure module, tags.ts, with its own tests, separate from the TagsTab.tsx component. The tab works like Trends:
- Up to 8 tags can be checked, one palette color each, and a tag keeps its color when others are toggled.
- The top 5 are checked by default.
- A dimmed Average bar sits at the right end, and the tooltip shows each segment’s amount and share of the bar.
The agent added three things I hadn’t asked for, and listed them:
- An Expense/Income switch, as Trends has.
- A “Clear” link next to “Reset”, so focusing on one tag doesn’t take five clicks.
- A second average. The main average counts empty periods as zero, like Trends. On a long range that drags a trip’s average toward nothing, so the tile adds a line like “11,725 across the 4 of 10 months with spending”.
That second average is worth noting. About two weeks later I asked for the same idea on every chart, as a dropdown.
Two tags on one transaction
The agent’s summary ended with “one decision for you to check”:
“if a transaction carries two of the checked tags (say a dinner tagged both ‘Trip’ and ‘Work’), stacking each tag’s full total would count it twice and the bars would overstate what the collection cost. Instead, it’s counted once in a gray ‘Several tags’ segment, so every bar adds up to what was actually spent.”
It was a careful answer. The bars were honest. But the gray segment threw away the part I wanted: which tags overlapped. Half an hour later I replied:
“if a transaction is tagged multiple ways, and both tags are selected to be displayed, the transactions that have both tags will have their own stack, and the rest will have a separate stack. This way we can tell unions of tags and the total stack height will be the true value.”
So each combination of checked tags became its own segment. In the synthetic data, a June bar now reads: “Lisbon trip”, then “Lisbon trip + Work travel”, then “Car”, then the three-way combination. Each transaction lands in exactly one segment, the one matching the checked tags it actually carries.
The backend didn’t change. It already returned exact tag sets. The dashboard regroups them by whichever tags are checked.
How the combinations behave
Membership follows the checkboxes. With only “Lisbon trip” and “Work travel” checked, a transaction also tagged “Car” sits in the pair, because “Car” isn’t on screen. Check “Car” and it moves to “Lisbon trip + Car + Work travel”. The bar’s height doesn’t change. Only the split does.
The legend gets a second section. Under the tags, a heading reads “Carrying several checked tags (each transaction counted once)”, and each combination is listed with its amount and share.
Colors:
- A combination takes a palette color that no checked tag is using, and keeps it while it is on screen. The agent checked in the browser that unchecking a tag doesn’t repaint the remaining combinations.
- If there are more combinations than free colors, the smallest fold into a gray “Other combinations (n)”.
- It considered striping each combination in its members’ colors and turned it down. The chart guidance reserves stripes for accessibility and print modes, where a pattern has to stand in for color.

How it was checked
The agent checked this one on screen with the harness from the last chapter: made-up tags behind a mock /api, headless Chrome, light and dark screenshots, a hover tooltip, and a two-tag overlap case. For the combination change, it added a transaction carrying three tags to the mock data, so several combinations would show at once.
The sandbox Claude Code runs in made the recipe change in two places:
tsx watch, the TypeScript runner the services use in development, opens a Unix socket for its own messages, and the sandbox blocks it. Runningtsxas a plain Node loader avoids the socket.- Chrome wouldn’t run inside the sandbox at all, so each render needed one approved run outside it.
Both went into the memory note, so the next session didn’t rediscover them. The docs changed in the same commit: the README, the analytics plan, the architecture notes and the service README all describe combinations.
Tests at the end: 99 in analytics, 23 in drive-sync, 13 in the dashboard, including new ones for combination segments, folding past the palette, and colors staying put.
What the agent got right, and what I changed
Its first answer was defensible: no double counting, flagged as a decision rather than slipped in. A reviewer could have approved it. What it optimized was the total. What I wanted from tags was the overlap, and a gray lump hides exactly that.
The general version: when an agent flags a decision, it has usually found the right problem. Whether its answer fits depends on what you wanted to learn from the chart, and only you know that.
Takeaways
- Return the exact sets, not the per-tag sums. A backend that keeps each transaction’s full tag set lets the client regroup any way it likes, without double counting.
- A stacked bar must add up to the truth. Give every item exactly one segment. If items can belong to several groups, the segments are the combinations.
- Hiding the overlap is not the same as handling it. A “Several” bucket is honest about the total and silent about the thing you wanted to see.
- Put chart logic in a pure module. The stacking rules in
tags.tswere tested without rendering anything.
What’s next
The next chapter is Reports: a tab where you build the filter yourself, and the first time several agents worked in the same files at once.
The story continues as the work does.
Source: github.com/eyosias-k-negash/ivk8. Commit: e4c668b.