Skip to content

Generic Handler and Easier Future Protocol Extensions#43

Open
tris203 wants to merge 11 commits into
tliron:mainfrom
tris203:factory2
Open

Generic Handler and Easier Future Protocol Extensions#43
tris203 wants to merge 11 commits into
tliron:mainfrom
tris203:factory2

Conversation

@tris203

@tris203 tris203 commented Jul 4, 2025

Copy link
Copy Markdown
Collaborator

Supersedes #42

Essentially a complete rewrite of the handler side to use a generic handler

I accept this is probably almost unreviewable

@tris203 tris203 changed the title wip Generic Handler and Easier Future Protocol Extensions Jul 4, 2025
@tris203
tris203 requested a review from Copilot July 4, 2025 19:11

This comment was marked as outdated.

@tris203

tris203 commented Jul 4, 2025

Copy link
Copy Markdown
Collaborator Author

@tliron when you have a moment, could you enable actions for the repo?

@tris203
tris203 requested a review from Copilot July 5, 2025 21:20

This comment was marked as outdated.

@tris203
tris203 requested a review from Copilot July 5, 2025 21:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR rewrites the server-side to use a generic handler interface, swaps out the old commonlog for Go’s structured slog, and introduces translation helpers for future protocol extensions.

  • Migrated all loggers to use log/slog and removed commonlog
  • Updated Server to accept glsp.RPCHandler and centralized request handling via HandlerHandle
  • Added generic translation functions and simplified custom request registration

Reviewed Changes

Copilot reviewed 38 out of 42 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/server.go Swapped in slog.Logger, changed Handler type
server/run-websocket.go Updated WebSocket serving to use slog, error wrapping
server/serve.go Refactored stream and WS methods to use slog.Logger
protocol/translation/handler_translation.go Introduced generic translation handlers
protocol/custom.go Added global custom-method registry and registration API
Comments suppressed due to low confidence (3)

server/handler.go:81

  • [nitpick] Consider adding a doc comment above HandlerHandle to explain its purpose, parameters, and the meaning of its return values (validMethod, validParams).
func (s *Server) HandlerHandle(context *glsp.Context) (r any, validMethod bool, validParams bool, err error) {

server/run-websocket.go:11

  • [nitpick] The parameter named address is clear, but internal log variables are named log, which shadows the log package in other contexts. For consistency with other methods taking a logger argument, consider renaming local variables to logger.
func (s *Server) RunWebSocket(address string) error {

Comment thread protocol/custom.go Outdated
Comment thread server/run-websocket.go Outdated
@tris203

tris203 commented Jul 15, 2025

Copy link
Copy Markdown
Collaborator Author

I think this is ready as soon as we can get CI turned on for the repo

tris203 added 2 commits June 6, 2026 11:13
Add unit tests for the protocol package covering position/range byte
indexing, document change (marshal/unmarshal/validation) and URI parsing.
New tests added:
- protocol/ranges_test.go
- protocol/ts_documentchanges_test.go
- protocol/uri_test.go

Update CI workflow (.github/workflows/test.yml) to run tests for all
packages using `go test -race ./...` so the new tests are executed.
@tris203
tris203 marked this pull request as ready for review June 6, 2026 10:30
@tris203

tris203 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

@jmbarzee, @WhyNotHugo

I think that for the future support im going to go down this route.

As zk is one of the biggest consumers of this library, are you able to test this branch and see how breaking it is for you?

@WhyNotHugo

Copy link
Copy Markdown

I'll try and have a look in the coming week.

@jmbarzee

jmbarzee commented Jun 8, 2026

Copy link
Copy Markdown

@tris203 I'm not picky on how it gets implemented, just looking for the more recent protocol changes to land.

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.

4 participants