MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / open_file

Method open_file

masfactory/visualizer/client.py:290–319  ·  view source on GitHub ↗

Open a file in VS Code and optionally reveal the Visualizer panel. Args: options: Open-file options (path, target view, focus behavior). Returns: True if the request was sent, otherwise False.

(self, options: VisualizerOpenFileOptions)

Source from the content-addressed store, hash-verified

288 return resp if isinstance(resp, str) else str(resp)
289
290 def open_file(self, options: VisualizerOpenFileOptions) -> bool:
291 """Open a file in VS Code and optionally reveal the Visualizer panel.
292
293 Args:
294 options: Open-file options (path, target view, focus behavior).
295
296 Returns:
297 True if the request was sent, otherwise False.
298 """
299 file_path = options.file_path if isinstance(options.file_path, str) else ""
300 file_path = file_path.strip()
301 if not file_path:
302 return False
303
304 view: VisualizerView = options.view if options.view in ("auto", "preview", "vibe") else "auto"
305
306 preserve_focus = options.preserve_focus
307 if preserve_focus is None:
308 # Default UX: Vibe editing happens inside Visualizer, so keep focus there.
309 preserve_focus = view == "vibe"
310
311 payload: dict[str, object] = {
312 "type": "UI_OPEN_FILE",
313 "visualizerProtocolVersion": VISUALIZER_PROTOCOL_VERSION,
314 "filePath": os.path.abspath(file_path),
315 "view": view,
316 "reveal": bool(options.reveal),
317 "preserveFocus": bool(preserve_focus),
318 }
319 return self._runtime.send_message(payload, require_connection=True)
320
321_CLIENT_SINGLETON: VisualizerClient | None = None
322

Callers 1

_forwardMethod · 0.80

Calls 1

send_messageMethod · 0.45

Tested by

no test coverage detected