Skip to content

Fold the untouched links of a call chain into one row - #1559

Merged
milanb17 merged 1 commit into
mainfrom
diffr-chain-link-scopes
Nov 22, 2026
Merged

milanb17 merged 1 commit into
mainfrom
diffr-chain-link-scopes

Conversation

@milanb17

@milanb17 milanb17 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A change in one link of a call chain such as new Hono().get(…).post(…).put(…) left every other link's arguments open, each folded on its own, and the lines between them folded separately. In cloudboard's apps/api/src/app.ts that was twelve folded rows back to back above a one-link change.

Why

  • Chained calls nest leftwards in the tree, so no node covers one link. The only folds inside the chain were each call's arguments, all of them context:body children of the one statement around the chain.
  • The context plugin keeps the body of a changed scope open (item in plugins/shape/context/rust/src/lib.rs), so a change in any link opened every link's arguments.
  • merge_runs joins hidden siblings only, so the open bodies split the unchanged lines into one row each.

Change

  • plugins/shape/context/queries/javascript.scm (TypeScript, TSX and JSX inherit it): a chain link that starts its own line is a context:scope, from its . to the end of its arguments. An unchanged link is then an item like any other scope and joins its neighbours' row.
  • A link that starts mid-line (actions.read().then() is left alone. Its scope would start on the arguments' first line, take the body's range, and open the callbacks inside it: the diffr_config_section_folds_unchanged_ai_summaries contract caught this in a first version, which showed two more lines there.

Result

File (diffr 0.1.23, with and without this query) Folded rows before After
cloudboard apps/api/src/app.ts, one link added 24 9
cloudboard apps/api/src/repos/routes.server.ts 47 15
30 other recently changed .ts/.tsx files in cloudboard same same
cloudboard apps/web/src/routes/_app.welcome.repo.$owner.$name.tsx 9 9, one more line shown

In the last file a chain was rewritten onto one line. The row before its last line is one line shorter, and the re-indented </ArrowRow> closer under it now shows as removed and added.

Tests

  • Two contracts in tests/fixtures/context-contracts/typescript.rs: a change in the last link, and one in a middle link. Each shows the chain's first line, one row for the untouched links, and the changed link.
  • cargo test --no-fail-fast in diffr/: all pass, the existing contracts unchanged.

Not done

  • Other languages with method chains (Rust, Java, Kotlin, Python and others) likely have the same gap. Only the JavaScript family is changed and tested here.
  • No changelog entry and no release.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xt4XEn4WzwdKXhfWPUiy97

A change in one link of a chain such as new Hono().get(…).post(…) left
every other link's arguments open, each folded on its own, with the lines
between them folded separately: a dozen rows where one would do. Chained
calls nest leftwards, so no node covers one link, and every link's
arguments were bodies of the one statement around the chain. A link that
starts its own line is now a scope.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xt4XEn4WzwdKXhfWPUiy97
@milanb17
milanb17 merged commit e191f05 into main Nov 22, 2026
13 checks passed
@milanb17
milanb17 deleted the diffr-chain-link-scopes branch November 22, 2026 00:15
milanb17 added a commit that referenced this pull request Nov 22, 2026
Diffr Release. Ships #1559: the untouched links of a call chain fold
into one row.

Also included since 0.1.23: #1541 (zod namespace imports) and #1473
(Dependabot advisory patches).

After this merges, the release is cut by pushing the tag `diffr/0.1.24`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Xt4XEn4WzwdKXhfWPUiy97

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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