Skip to content

arch(lsp): split server.go into focused sibling files - #680

Merged
jeduden merged 7 commits into
mainfrom
claude/youthful-knuth-rl5xf2
Jun 22, 2026
Merged

arch(lsp): split server.go into focused sibling files#680
jeduden merged 7 commits into
mainfrom
claude/youthful-knuth-rl5xf2

Conversation

@jeduden

@jeduden jeduden commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • internal/lsp/server.go was 1007 lines (flagged by the 2026-06-21 architecture audit). Split session management and utility helpers into two new sibling files within the lsp package, trimming server.go to 555 lines.
  • Created internal/lsp/server_session.go: rebuildSession, currentSession, snapshotConfig, reloadConfig, resolveConfig, fetchClientSettings, registerPendingResponse, unregisterPendingResponse, deliverResponse
  • Created internal/lsp/server_util.go: workspaceRelative, dirFSForPath, frontMatterEnabled, isFixable, uriToPath, uriToPathOnOS, hasDriveLetterPrefix, pickRoot
  • Pure reorganisation — zero logic changes. Plan 2606211909 marked complete.

Test plan

  • go build ./... passes
  • go test ./... passes (all packages)
  • wc -l internal/lsp/server.go is 555 (under 800)
  • go tool golangci-lint run — no new issues

🤖 Generated with Claude Code

https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e


Generated by Claude Code

server.go was 1007 lines. Split the session management and utility
helpers into two new sibling files within the lsp package:

- server_session.go: rebuildSession, currentSession, snapshotConfig,
  reloadConfig, resolveConfig, fetchClientSettings, registerPendingResponse,
  unregisterPendingResponse, deliverResponse
- server_util.go: workspaceRelative, dirFSForPath, frontMatterEnabled,
  isFixable, uriToPath, uriToPathOnOS, hasDriveLetterPrefix, pickRoot

server.go trimmed to 555 lines (core struct, types, New, Run,
recoverPanic, logPanic, and the dispatch functions). Pure reorganisation
— zero logic changes.

Closes plan/2606211909_arch-fix-lsp-server-split.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (4a16047) to head (26c3096).

Additional details and impacted files
Components Coverage Δ
Go 98.61% <100.00%> (+<0.01%) ⬆️
TypeScript 99.54% <ø> (ø)

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

claude added 6 commits June 21, 2026 22:33
…generate PLAN.md

The agent dropped `defer s.recoverPanic("fetch client settings")` when
extracting fetchClientSettings to server_session.go, causing panics to
escape instead of being logged. Restored the recover, trimmed the
trailing blank line that golangci-lint flagged, and regenerated the
PLAN.md catalog for the new plan entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
The `1. - [x]` nested-list structure in the Tasks section caused
TestListscanMatchesASTCorpus to diverge on this file — goldmark
saw 9 lists (7 nested unordered sublists inside each ordered item)
while listscan saw only 2. Use the plain numbered list format from
the proto.md template instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
The godoc said "disposes the previous one" but the function body
explicitly does the opposite: it intentionally leaves the superseded
session alive for GC so that in-flight lint goroutines (which hold a
reference obtained before the swap) never observe a disposed session.
Point the godoc at the in-body explanation instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
…ndows drive root

- watchedFilesTreeChanged: non-file:// URIs (e.g. git://, untitled:)
  returned "" from uriToPath, which bypassed the .mdsmith.yml filter
  and could trigger a spurious InvalidateWikilinks on Created/Deleted
  events from non-conformant clients. Now skip URI="" entries.

- uriToPathOnOS: file:///Z: (bare Windows drive root) produced "Z:."
  after filepath.Clean("Z:") because the stripped path "Z:" is treated
  as a relative drive path. Append "\" before Clean when the result
  is exactly two chars (X:).

- Corrected the url.Parse error comment: the branch is reachable on
  invalid percent-encoded hosts (e.g. file://%GH/path) and is covered
  by TestUriToPathInvalidURL; it is not "unreachable in practice".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
… fix UNC stub

Tests:
- TestUriToPathOnWindowsBareRoot: drives the `len(p)==2` early-return
  branch red/green — file:///C: must resolve to "C:\" not "C:."
- TestUriToPathOnWindowsHostOnlyReturnsEmpty: drives the new UNC
  host-only guard — file://server (no share) must return ""
- TestWatchedFilesTreeChangedSkipsNonFileURI: drives the path==""
  continue branch — a git:// Created event must not trigger a
  wikilink-index rebuild

Fixes:
- uriToPathOnOS: return early for bare Windows drive root ("C:") to
  bypass filepath.Clean's platform-dependent "C:." behaviour; use
  backslash directly so the result is the canonical Windows root "C:\"
- uriToPathOnOS: UNC construction now returns "" when the path has no
  share component (len(p)<=1), preventing "\\server" stubs from
  passing callers' path!="" guards and reaching filesystem operations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
All lint findings are pre-existing prealloc warnings in files not
touched by this PR — no new issues introduced by the server.go split.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhyAzFuAuKB7s5N1FQAx9e
@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Jun 22, 2026
@jeduden

jeduden commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-680-1782128092 alongside #681. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden
jeduden merged commit f917212 into main Jun 22, 2026
31 checks passed
@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Jun 22, 2026
@jeduden

jeduden commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit ff7ab4d. CI run that validated the merge.

Next: Done — nothing more to do here.

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