Repository: astral-sh/ruff
File: crates/ty_server/src/server/api.rs (Rust)

Code before:
            requests::DocumentSymbolRequestHandler,
        >(req, BackgroundSchedule::Worker),
        requests::WorkspaceSymbolRequestHandler::METHOD => background_request_task::<
            requests::WorkspaceSymbolRequestHandler,
        >(
            req, BackgroundSchedule::Worker
        ),
        lsp_types::request::Shutdown::METHOD => sync_request_task::<requests::ShutdownHandler>(req),

        method => {
            tracing::warn!("Received request {method} which does not have a handler");
            let result: Result<()> = Err(Error::new(
                anyhow!("Unknown request: {method}"),
                server::ErrorCode::MethodNotFound,
            ));
            return Task::immediate(id, result);
        }
    }
    .unwrap_or_else(|err| {
        tracing::error!("Encountered error when routing request with ID {id}: {err}");

        Task::sync(move |session, client| {
            if matches!(err.code, ErrorCode::InternalError) {
                client.show_error_message(format!(
                    "ty failed to handle a request from the editor. {}",
                    log_guidance(session.client_name())
                ));
            }

            respond_silent_error(
                id,
                client,
                lsp_server::ResponseError {
                    code: err.code as i32,
                    message: err.to_string(),
                    data: None,
                },
            );
        })
    })
}

pub(super) fn notification(notif: server::Notification) -> Task {
    match notif.method.as_str() {
        notifications::DidCloseTextDocumentHandler::METHOD => {
            sync_notification_task::<notifications::DidCloseTextDocumentHandler>(notif)
        }
        notifications::DidOpenTextDocumentHandler::METHOD => {
            sync_notification_task::<notifications::DidOpenTextDocumentHandler>(notif)
        }
        notifications::DidChangeTextDocumentHandler::METHOD => {

Review comment (bug):
Should we make `session.client` an `enum` instead of mapping at the use sides? 

```rust
#[derive(Debug, Clone)]
enum Client {
	Zed,
	Unknown(String)
}
```

Code after:
            requests::DocumentSymbolRequestHandler,
        >(req, BackgroundSchedule::Worker),
        requests::WorkspaceSymbolRequestHandler::METHOD => background_request_task::<
            requests::WorkspaceSymbolRequestHandler,
        >(
            req, BackgroundSchedule::Worker
        ),
        lsp_types::request::Shutdown::METHOD => sync_request_task::<requests::ShutdownHandler>(req),

        method => {
            tracing::warn!("Received request {method} which does not have a handler");
            let result: Result<()> = Err(Error::new(
                anyhow!("Unknown request: {method}"),
                server::ErrorCode::MethodNotFound,
            ));
            return Task::immediate(id, result);
        }
    }
    .unwrap_or_else(|err| {
        tracing::error!("Encountered error when routing request with ID {id}: {err}");

        Task::sync(move |session, client| {
            if matches!(err.code, ErrorCode::InternalError) {
                client.show_error_message(format!(
                    "ty failed to handle a request from the editor. {}",
                    session.client_name().log_guidance()
                ));
            }

            respond_silent_error(
                id,
                client,
                lsp_server::ResponseError {
                    code: err.code as i32,
                    message: err.to_string(),
                    data: None,
                },
            );
        })
    })
}

pub(super) fn notification(notif: server::Notification) -> Task {
    match notif.method.as_str() {
        notifications::DidCloseTextDocumentHandler::METHOD => {
            sync_notification_task::<notifications::DidCloseTextDocumentHandler>(notif)
        }
        notifications::DidOpenTextDocumentHandler::METHOD => {
            sync_notification_task::<notifications::DidOpenTextDocumentHandler>(notif)
        }
        notifications::DidChangeTextDocumentHandler::METHOD => {