My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(js_top_worker): add filename parameter to client_msg API

Add optional ?filename parameter to complete, type_at, and errors
functions. When provided, filename is included in the JSON message
sent to the worker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+27 -15
+27 -15
js_top_worker/idl/js_top_worker_client_msg.ml
··· 239 239 ("code", Js.Unsafe.inject (Js.string code)); 240 240 |] in 241 241 Js.to_string (Json.output obj) 242 - | `Complete (cell_id, env_id, source, position) -> 243 - let obj = Js.Unsafe.obj [| 242 + | `Complete (cell_id, env_id, source, position, filename) -> 243 + let pairs = [| 244 244 ("type", Js.Unsafe.inject (Js.string "complete")); 245 245 ("cell_id", Js.Unsafe.inject cell_id); 246 246 ("env_id", Js.Unsafe.inject (Js.string env_id)); 247 247 ("source", Js.Unsafe.inject (Js.string source)); 248 248 ("position", Js.Unsafe.inject position); 249 249 |] in 250 - Js.to_string (Json.output obj) 251 - | `TypeAt (cell_id, env_id, source, position) -> 252 - let obj = Js.Unsafe.obj [| 250 + let pairs = match filename with 251 + | Some f -> Array.append pairs [| ("filename", Js.Unsafe.inject (Js.string f)) |] 252 + | None -> pairs 253 + in 254 + Js.to_string (Json.output (Js.Unsafe.obj pairs)) 255 + | `TypeAt (cell_id, env_id, source, position, filename) -> 256 + let pairs = [| 253 257 ("type", Js.Unsafe.inject (Js.string "type_at")); 254 258 ("cell_id", Js.Unsafe.inject cell_id); 255 259 ("env_id", Js.Unsafe.inject (Js.string env_id)); 256 260 ("source", Js.Unsafe.inject (Js.string source)); 257 261 ("position", Js.Unsafe.inject position); 258 262 |] in 259 - Js.to_string (Json.output obj) 260 - | `Errors (cell_id, env_id, source) -> 261 - let obj = Js.Unsafe.obj [| 263 + let pairs = match filename with 264 + | Some f -> Array.append pairs [| ("filename", Js.Unsafe.inject (Js.string f)) |] 265 + | None -> pairs 266 + in 267 + Js.to_string (Json.output (Js.Unsafe.obj pairs)) 268 + | `Errors (cell_id, env_id, source, filename) -> 269 + let pairs = [| 262 270 ("type", Js.Unsafe.inject (Js.string "errors")); 263 271 ("cell_id", Js.Unsafe.inject cell_id); 264 272 ("env_id", Js.Unsafe.inject (Js.string env_id)); 265 273 ("source", Js.Unsafe.inject (Js.string source)); 266 274 |] in 267 - Js.to_string (Json.output obj) 275 + let pairs = match filename with 276 + | Some f -> Array.append pairs [| ("filename", Js.Unsafe.inject (Js.string f)) |] 277 + | None -> pairs 278 + in 279 + Js.to_string (Json.output (Js.Unsafe.obj pairs)) 268 280 | `CreateEnv env_id -> 269 281 let obj = Js.Unsafe.obj [| 270 282 ("type", Js.Unsafe.inject (Js.string "create_env")); ··· 326 338 stream 327 339 328 340 (** Get completions *) 329 - let complete t ?(env_id = "default") source position = 341 + let complete t ?filename ?(env_id = "default") source position = 330 342 let open Lwt.Infix in 331 343 wait_ready t >>= fun () -> 332 344 let cell_id = next_cell_id t in 333 345 let promise, resolver = Lwt.wait () in 334 346 Hashtbl.add t.pending cell_id resolver; 335 - send t (`Complete (cell_id, env_id, source, position)); 347 + send t (`Complete (cell_id, env_id, source, position, filename)); 336 348 promise >>= fun msg -> 337 349 match msg with 338 350 | Msg.Completions { completions; _ } -> ··· 342 354 | _ -> Lwt.fail (Failure "Unexpected response") 343 355 344 356 (** Get type at position *) 345 - let type_at t ?(env_id = "default") source position = 357 + let type_at t ?filename ?(env_id = "default") source position = 346 358 let open Lwt.Infix in 347 359 wait_ready t >>= fun () -> 348 360 let cell_id = next_cell_id t in 349 361 let promise, resolver = Lwt.wait () in 350 362 Hashtbl.add t.pending cell_id resolver; 351 - send t (`TypeAt (cell_id, env_id, source, position)); 363 + send t (`TypeAt (cell_id, env_id, source, position, filename)); 352 364 promise >>= fun msg -> 353 365 match msg with 354 366 | Msg.Types { types; _ } -> ··· 358 370 | _ -> Lwt.fail (Failure "Unexpected response") 359 371 360 372 (** Get errors *) 361 - let errors t ?(env_id = "default") source = 373 + let errors t ?filename ?(env_id = "default") source = 362 374 let open Lwt.Infix in 363 375 wait_ready t >>= fun () -> 364 376 let cell_id = next_cell_id t in 365 377 let promise, resolver = Lwt.wait () in 366 378 Hashtbl.add t.pending cell_id resolver; 367 - send t (`Errors (cell_id, env_id, source)); 379 + send t (`Errors (cell_id, env_id, source, filename)); 368 380 promise >>= fun msg -> 369 381 match msg with 370 382 | Msg.ErrorList { errors; _ } ->