Skip to content

Find definitions by symbol, and decide against a second index - #77

Merged
Seungpyo1007 merged 1 commit into
developfrom
feature/find-symbol
Aug 7, 2026
Merged

Find definitions by symbol, and decide against a second index#77
Seungpyo1007 merged 1 commit into
developfrom
feature/find-symbol

Conversation

@Seungpyo1007

Copy link
Copy Markdown
Member

Step 1 of the 0.4.0 plan, and the measurement that closes step 2.

What was broken

Ctrl+T returned nothing in a TypeScript project. It asked lspClient only, but TS/JS is served by Monaco's built-in worker, not an LSP session — this repository is exactly that case, so workspace symbol search has never worked here.

What it does now

src/editor/symbolIndex.ts merges both sources: the TS worker and any live LSP sessions. Ctrl+T and a new find_symbol agent tool share it.

Monaco's worker proxy does not expose getNavigateToItems — it answers Missing requestHandler or method. It does expose getNavigationTree, so workspace symbols are assembled from per-file trees. Flattening lives in src/engine/navTree.ts as pure functions with 18 tests.

The tool distinguishes no index from no match. Without that, "no such symbol" silently swallows "this language has no index at all", and the model concludes the thing does not exist.

Two kinds of noise are filtered out of the TS tree, both found by measuring rather than reading:

  • import aliases — asking where applyProposal is defined returned the import line in a test file.
  • describe("name", …) blocks — TS names those nodes after the string, so a test suite outranked the definition. These are pushed to the back rather than dropped, since sometimes the test is what you want.

Exact name matches are ranked first.

Measurement (this repository, 207 models)

Query symbols ms grep ms first symbol result
applyProposal 5 200 27 36 engine/editApply.ts:41
flattenNavTree 2 171 25 36 engine/navTree.ts:38
writeAtomic 1 283 4 43 electron/checkpoints.cjs:66
notifyActiveEditor 1 150 3 31 ext/extHost.ts:90
planFileOps 6 155 33 29 ext/fileOps.ts:55
makeTouchSet 4 172 13 26 electron/touchSet.cjs:39

grep returns 5.5× more (105 vs 19). Symbols are 4–6× slower in absolute terms, but 150–280 ms is nothing inside an agent round. All six first results are the real definition.

What the measurement decided

Step 2 of the plan — building our own index — is dropped. The precision problem is already solved, TS/JS is covered by the worker and everything else by LSP, and a second table of the same facts would only add a staleness problem to maintain. The remaining gap is languages with neither, and that is a question of attaching a language server, not of building an index — and it pays better, since definitions, references and diagnostics all arrive together.

That also removes the update-strategy work the plan spent a section on: if we hold no table, nothing goes stale.

1089 unit tests passing. npm run typecheck clean. Verified in the real app on a fresh TypeScript project: 5/5, including that a comment mentioning the name and the call site are not returned.

Ctrl+T 가 TypeScript 프로젝트에서 늘 빈 목록이었음. lspClient 만 물어보는데
TS/JS 는 LSP 세션이 아니라 Monaco 내장 워커가 맡아서. 이 저장소가 딱 그랬다.

getNavigateToItems 는 Monaco 워커가 노출 안 함(Missing requestHandler or
method). getNavigationTree 는 되니까 파일별 트리를 모아서 만듦.

에이전트용 find_symbol 도구도 같은 소스. 색인이 아예 없는 경우와 찾았는데
없는 경우를 구분해서 답한다 — 안 그러면 "그런 심볼 없음" 이 "그 언어 지원
안 함" 을 덮어버림.

트리에서 걸러낸 것 두 가지. import 로 끌어온 이름(alias)과
describe("이름", ...) 블록. 둘 다 "정의가 어디" 의 답이 아님. 앞은 빼고
뒤는 뒤로 민다.

0.4.0 계획서에 실측 결과와 2단계(자체 인덱스) 접는 근거 반영.
@Seungpyo1007 Seungpyo1007 added this to the v0.3 (2026-09-30) milestone Aug 7, 2026
@Seungpyo1007 Seungpyo1007 added the enhancement New feature or request label Aug 7, 2026
@Seungpyo1007 Seungpyo1007 self-assigned this Aug 7, 2026
@Seungpyo1007
Seungpyo1007 merged commit 7b76d7a into develop Aug 7, 2026
1 check passed
@Seungpyo1007
Seungpyo1007 deleted the feature/find-symbol branch August 7, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant