From e82e89333e9b305e586ac5a14115ee283931d7cc Mon Sep 17 00:00:00 2001 From: Byron Wall Date: Sun, 22 Nov 2026 16:08:59 -0500 Subject: [PATCH 1/2] fix(scan): share tracked source visibility across views --- README.md | 2 + client/e2e/symbols.spec.ts | 9 ++ client/src/viz/deps/DependencyView.tsx | 18 +++- client/src/viz/deps/symbols/SymbolsView.tsx | 2 +- docs/CODE_MAP.md | 2 +- server/app/services/analysis.py | 44 +++++++-- server/app/services/deps/common.py | 41 ++++++-- server/app/services/deps/graph.py | 21 ++-- server/tests/test_source_inventory.py | 104 ++++++++++++++++++++ 9 files changed, 210 insertions(+), 33 deletions(-) create mode 100644 server/tests/test_source_inventory.py diff --git a/README.md b/README.md index 32cedf6e..b2c2b64b 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,8 @@ uvx srcly report . --out .srcly --verbose Use `uvx srcly scan . --out .srcly/tree.json` or `uvx srcly report . --include-tree` when you need the full raw tree. Use `--include-dependencies` to add the TypeScript/TSX dependency graph artifact. +In a Git worktree, the tree, Imports and Symbols start from the same Git-listed files: tracked files stay visible even if they match an ignore rule; ignored untracked files do not. Imports and Symbols then limit the list to supported JavaScript, TypeScript and Python source up to 1 MB, excluding `.d.ts` and files under hidden or pruned directories such as `node_modules`. A file can appear in the tree without being eligible for these views. These filters do not define which files changed between revisions. + `explain --at` reads one scope of the analysis: the repo or a folder (child folders ranked by their worst file, then the worst files below), a file (its functions and classes), or `file::symbol` (its lines and every measured metric). Commands share the app's analysis cache, so after the first scan each call takes about a second while no file has changed; `--refresh` rescans. Each answer ends with an `Analysis:` line: reused or fresh scan, the Git HEAD and uncommitted files, the checkers that ran, and how many code files none covers. Same-named symbols are `file::name@line`, and any printed "Start at" value (`path:line name`) works as `--at`. A symbol answer splits its CCN into statements and `&&`/`||`/`?:` operators with the deepest lines, so a flat router reads differently from nested control flow, and lists test files that import its module and name it (a name match, not coverage). Findings rank **code** files. Each file is also classed as test, docs, style (CSS and other stylesheets), fixture, generated, vendored, config or data from its path, and the report names how many of each it left out and why (`--include-class test` ranks one too). A long README or a test snapshot is never a refactor target by accident, and never silently dropped. diff --git a/client/e2e/symbols.spec.ts b/client/e2e/symbols.spec.ts index 046792e1..ae0acef4 100644 --- a/client/e2e/symbols.spec.ts +++ b/client/e2e/symbols.spec.ts @@ -84,6 +84,15 @@ test.describe("Symbols mode on solid-route", () => { await page.goto(url({ view: "graph", symbols: "src/components/RecordTable.tsx#Nope" })); await expect(page.getByText("Not in the index")).toBeVisible({ timeout: 90_000 }); }); + + test("explain when a tree file isn't eligible for structural views", async ({ page }) => { + await page.goto(url({ view: "graph", at: "README.md" })); + const notice = page.locator("[data-imports-excluded]"); + await expect(notice).toContainText("README.md is in the tree but not in Imports", { timeout: 90_000 }); + await page.goto(url({ view: "graph", symbols: "README.md" })); + await expect(page.getByText("Not in the index")).toBeVisible({ timeout: 90_000 }); + await expect(page.getByText(/Symbols indexes JavaScript, TypeScript and Python source/)).toBeVisible(); + }); }); test.describe("Symbols mode paths on solid-route", () => { diff --git a/client/src/viz/deps/DependencyView.tsx b/client/src/viz/deps/DependencyView.tsx index 24f1ca27..bd481a15 100644 --- a/client/src/viz/deps/DependencyView.tsx +++ b/client/src/viz/deps/DependencyView.tsx @@ -24,7 +24,7 @@ import { layoutWithHubs } from "./hubs"; import type { ViewLayout } from "./layout"; import { viewContents, viewMetrics, type MetricsIndex } from "./metrics"; import { buildViewModel, DEFAULT_BUDGET, type ViewNode } from "./viewModel"; -import { folderOf, graphIdFor, isDataFlow, isSymbols } from "../../navigation/location"; +import { folderOf, graphIdFor, isDataFlow, isSymbols, splitAt } from "../../navigation/location"; import { addAnchorPatch, refsPatch, tracePatch } from "../../navigation/nodeActions"; import NodeActionsMenu, { type NodeMenuTarget } from "../../navigation/NodeActionsMenu"; import { go, graphFilters as filters, location, replace, setGraphFilters as setFilters } from "../../navigation/store"; @@ -88,6 +88,15 @@ function ImportView(props: { return g ? buildIndex(applyFilters(g, filters())) : null; }); + const unindexedFile = createMemo(() => { + const nodes = graph()?.nodes; + const { file } = splitAt(location().at); + if (!nodes || !file || !props.metricsIndex) return null; + const separator = props.rootPath.includes("\\") ? "\\" : "/"; + const full = `${props.rootPath.replace(/[\\/]$/, "")}${separator}${file.replaceAll("/", separator)}`; + return props.metricsIndex.get(full)?.type === "file" && !nodes.some((n) => n.id === file) ? file : null; + }); + const effectiveFocus = createMemo(() => { const idx = index(); if (!idx) return null; @@ -420,6 +429,13 @@ function ImportView(props: { + + {(file) => ( +

+ {file()} is in the tree but not in Imports. Imports covers JavaScript, TypeScript and Python source up to 1 MB, excluding .d.ts files and hidden or pruned folders. +

+ )} +
diff --git a/client/src/viz/deps/symbols/SymbolsView.tsx b/client/src/viz/deps/symbols/SymbolsView.tsx index a9c66bdf..a4a33b7f 100644 --- a/client/src/viz/deps/symbols/SymbolsView.tsx +++ b/client/src/viz/deps/symbols/SymbolsView.tsx @@ -406,7 +406,7 @@ export default function SymbolsView(props: { rootPath: string; onOpen: (at: stri