Skip to content

Conversation

eliyya
Copy link

@eliyya eliyya commented Oct 6, 2025

Description

This PR introduces a new “Watcher” mode under the File > Import menu, allowing users to monitor changes to a selected local file and automatically update the editor and graph.

Motivation

I work a lot with generating JSON files and I use jsoncrack.com a lot to view the generation, but having to re-import the JSON every time it is regenerated really disrupts my workflow. jsoncrack.com is already perfect, but I thought that if the tool had a watch mode it would be much better, so I implemented that option.

Implementation Details

  • Added a "Watcher" button in the import modal.
image
  • When activated, the file picker (window.showOpenFilePicker) opens for the user to select a file.
  • The selected file is loaded initially, and a setInterval runs every 3 seconds to check for changes using fileHandle.getFile().
  • If the file changes, the content is reloaded into the editor, the graph is refreshed and a toast appears.
image
  • A global state is used to manage the watcher and its interval.
  • While watcher mode is active:
    • The editor is set to readonly.
    • Format change options and Live Transform are disabled.
  • A “Stop Watching” button is available to stop the watcher, clear the interval, and re-enable disabled features.
image

Benefits

  • Allows real-time monitoring and visualization of local files without manual re-import.
  • Ideal for workflows where files are generated or updated externally.
  • Maintains compatibility with the existing import flow.

Co-authored-by: Ted Thibodeau Jr <[email protected]>
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