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
  • If the FilePicker API is not disponible, the button was not disponibe annd shows a message
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.

@AykutSarac
Copy link
Owner

I ran into an error when I clicked the Watcher button, we should add 'showOpenFilePicker' in window to check if user's browser supports the feature. Apparently it's disabled in Brave for privacy reasons, so I couldn't test it at the moment.

I like the idea though, good job! Let's wait for comments on the PR for now. 🏁

@AykutSarac AykutSarac added the open to review Please share your insights about this issue/PR label Oct 16, 2025
@eliyya
Copy link
Author

eliyya commented Oct 19, 2025

To show it in the UI, I think it would be good to disable the button and use a tooltip with a 500ms delay to show the reason like a...

image

Any opinion?

Copy link

@atilaahmettaner atilaahmettaner left a comment

Choose a reason for hiding this comment

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

The initial watch state does not transfer the file to the editor, it transfers it when changes are made. Can you also resolve the initial watch state here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open to review Please share your insights about this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants