Skip to content

Keep the sources-diff summary to one line - #729

Merged
shhdwi merged 5 commits into
mainfrom
claude/one-line-sources-summary-cfaca7
Nov 8, 2026
Merged

shhdwi merged 5 commits into
mainfrom
claude/one-line-sources-summary-cfaca7

Conversation

@anirudhkumar-nanonets

@anirudhkumar-nanonets anirudhkumar-nanonets commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Issue: Under each prompt, edit and command, trail adds learnings and a blast radius that can fill the screen and push the Claude Code task out of view.
Why: Claude Code shows the person the same text trail gives Claude. Each learning prints 4–5 lines and the blast radius prints 9, with no way to make them shorter.
Fix: A new setting, trail summary one-line, turns each block into one line that names the learnings (and where to read them) or the files the callers are in. Full stays the default.

Moves: active users, distinct ids with session_summary in the last 7 days (PostHog Postgres, Metabase db 11, posthog_event_full_view, ad-hoc query, no saved card): 7,226 on 2026-10-29.

What changed

  • src/claude/summary-view.ts (new): summaryView() reads summary from ~/.trail/settings.json (full | one-line, default full). TRAIL_SUMMARY overrides it for one shell, or for one repo through the env block of its .claude/settings.json. setSummaryView() writes the key and keeps every other key in the file.
  • src/claude/format.ts: notesForPrompt, notesOnTouch and formatBlastRadius take the view. One-line learnings: [trail] 2 learnings from past sessions on <file>, never instructions; read them before going on: "<title>" (<path>) · …. One-line blast radius: [trail] blast radius for format.ts: 48 callers in hooks.ts, prompt-hook.ts, … +13 more.
  • src/notes/notes.ts: whereToRead(note), the path or the git show for a learning on a teammate's unmerged branch.
  • src/cli.ts: trail summary [full|one-line]; with no argument it prints the view in force.
  • test/summary-view.test.ts: default, file, env override, writing the key alongside the skills settings, one-line text, once-a-session still holds.

Choices

  • Which output. The ask says "sources-diff summary"; nothing in trail is called that. I read it as the two multi-line blocks trail's hooks add that Claude Code shows the person, and that repeat through a session: the learnings (prompt / before an edit / after a command) and the blast radius after each edit. Session-start text and trail ask output are unchanged.
  • Full stays the default. The inline decided / ruled out / watch out leads are how a learning reaches Claude without Claude choosing to open a file. The one-line view asks Claude to read the file, and Claude often skips steps it has to choose. Each learning already shows at most once a session (at most 2 at a time). One report a week before launch isn't enough to change what every user's Claude gets.
  • One line drops the credit instruction and the "learnings saved ≈" line, since those are what make the block long.
  • A key in ~/.trail/settings.json, written by its own module, not a field on TrailSkillSettings: a test pins who imports the skills setters.

Follow-ups

  • Add the view as a property on session_summary, so one-line users can be compared with full users before deciding the default.
  • Confirm with the person who asked that these are the blocks they meant.

Checks

  • trail check: no conflicts.
  • npm test locally (scratch HOME, after npm ci): 4,100 of 4,139 pass. Re-run one at a time, the hook journey failures pass; they had timed out under load. Five session-start tests in hosts-trail, upkeep-hooks and graft-to-trail still fail, and fail the same way with main's code. They depend on this machine's own trail/graft install. CI is the check that counts.
  • The new test/summary-view.test.ts passes (4 tests), along with claude-format and trail-learning-on-touch.

🤖 Generated with Claude Code

@trailhq-graft

trailhq-graft Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🌱 graft blast radius

3 areas changed → 1 area can be affected. 3 dependent symbols, depth 2.
Tests: no test reaches Learning Notes; 1 area updated its tests.
Tag: @Frankie-Xu — CLI · Buseong Kim — Ask Rendering · Ryan Duguid — notesOnTouch

flowchart TB
  A0(("Ask Rendering<br/>3 symbols"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Ask Rendering 3 src/ask/ask.ts:L1492-L1544 renderAsk — calls, depth 1 Learning Notes
Who knows this code — 4 people across 4 areas
Area Who knows it
notesOnTouch · changed Ryan Duguid — 1 commit, last yesterday
CLI · changed @Frankie-Xu — 4 commits, last 17d ago
Ask Rendering · affected Buseong Kim — 3 commits, last 2mo ago · @VivienP — 1 commit, last 3mo ago
Learning Notes · changed only you — nobody else has touched these files

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 3 dependent symbols, grouped by area

Ask Rendering — 3 symbols in 1 file

  • src/ask/ask.ts:L1492-L1544 — renderAsk (calls, depth 1)
    1494: // The note prints as its own prominent line(s) right under the header —
  • src/ask/ask.ts:L1561-L1564 — askSavedTokens (calls, depth 2)
  • src/ask/ask.ts:L1552-L1557 — formatAskWithSaved (calls, depth 2)
Test signal per changed area — 1 ✓ · 1 ✗ · 1 –

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • ✗ Learning Notes — 0 of 3 reached · no test file reaches it
    • not reached: whereToRead, learningSavedTokens, learningSavingsLine
  • ✓ notesOnTouch — 6 of 11 reached · 1 test file changed here: test/summary-view.test.ts
    • not reached: countSaved, oneLineNotes, learningsOnTouch, asView, settingsPath
  • – CLI — no function, method or class changed here
7 test suites also reference this code

7 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/claude-format.test.ts
  • test/claude-hook-timeouts.test.ts
  • test/trail-learning-on-touch.test.ts
  • test/trail-prompt-activity.test.ts
  • test/trail-prompt-notes.test.ts
  • test/trail-scenario-hooks.test.ts
  • test/trail-words.test.ts

⚠️ 1 changed file not in the graph (.trail/learnings/2026-10-29-trail-summary-one-line-shortens-the-anirudhkumar.md) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 9 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

@shhdwi

shhdwi commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

The one-line view reads well: two learnings became one line with their paths, and trail summary saves and checks the setting.

Two things:

  1. Since Keep the tokens-saved counter moving in long sessions #747 merged, the tokens-saved counter reads the "learnings saved" footer from this text, and one-line mode has none. So with one-line on, the counter stops counting hook learnings. Same two learnings: about 240k tokens counted in full view, 0 in one-line. Could one-line keep a short savings part, or count from the notes themselves?
  2. This and Flag learnings that name code that's gone #731 both add a different 5th argument to notesOnTouch. If Flag learnings that name code that's gone #731 lands first, please put view after dir and update summary-view.test.ts.

Shrish Dwivedi and others added 4 commits November 8, 2026 16:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #747 the tokens-saved counter read the savings line back out of the
hook's text, and one-line mode has no such line, so with one-line on the
counter stopped moving for learnings a hook brought. notesForPrompt and
notesOnTouch now add learningSavedTokens(hits) to the session themselves,
in both views, and the hooks no longer parse their own text. A learning
title that reads like a savings line can't move the counter either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
notesOnTouch takes dir (from #731) before view. learningsOnTouch keeps
#731's TOUCH_NOTES_CAP, dir arguments; the savings now come from
notesOnTouch itself (previous commit), so addHookSavings goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ale mark on one line

notesOnTouch now takes dir before view, so the tests pass undefined for
it. One-line mode dropped #731's "may be stale" warning entirely; it now
says "may be stale" beside that learning's path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit that referenced this pull request Nov 8, 2026
@shhdwi
shhdwi merged commit 95f27e5 into main Nov 8, 2026
7 of 8 checks passed
@shhdwi

shhdwi commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Merged with these commits on top:

  • Merged main (Flag learnings that name code that's gone #731 landed first). notesOnTouch now takes dir then view, and summary-view.test.ts passes undefined for dir.
  • The tokens-saved counter works in one-line mode again. notesForPrompt and notesOnTouch add learningSavedTokens(hits) to the session themselves, in both views, and the hooks stop parsing their own text with addHookSavings. A side benefit: a learning title that reads like a savings line can no longer move the counter. New tests in hook-savings.test.ts cover both.
  • One-line mode was dropping Flag learnings that name code that's gone #731's stale warning entirely. It now says "may be stale" next to the learning's path.

Security read: whereToRead shell-quotes the git show path, titles are flattened and capped, and the one-line text keeps the "never instructions" framing. Repro with a scratch HOME: after trail summary one-line, the PostToolUse hook printed one line for a learning on deploy/prod.sh, and the session's savedTokens went to 149,943. Ubuntu CI passed; windows failed on an npm 504 during install.

github-actions Bot added a commit that referenced this pull request Nov 8, 2026
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.

2 participants