Skip to content

Let a plugin's watch say when something changed - #78

Open
cornedor wants to merge 7 commits into
omacom:mainfrom
cornedor:plugin-watch
Open

cornedor wants to merge 7 commits into
omacom:mainfrom
cornedor:plugin-watch

Conversation

@cornedor

@cornedor cornedor commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #77.

A manifest's watch is a command Folio starts when the plugins are read and leaves running. Each line it prints has the plugin polled at once and its details asked for again, so a change the plugin learns about shows in the details column when it happens, not at the next poll or F5.

The first line is acted on at once and those within half a second after it together, so a watch can print one per change. One that ends is started again every 5 seconds; it ends with Folio or its plugin, with everything it started, and F5 leaves a running one be. Unlike the other commands it isn't waited for in a pool: its lines come in as events on Folio's own thread. A details command still running when a line comes finishes and its answer is shown; whoever still shows the file then asks again, so a file nobody shows isn't asked about until it's shown again.

The bundled Dropbox plugin uses it. Its watch stays on ~/.dropbox/iface_socket, the socket Dropbox's own Nautilus extension (and Nemo's and Caja's) listens on, and prints a line for each shell_touch Dropbox sends there, and when Dropbox stops or starts. It's sh with the python3 that dropbox-cli already needs, so there's nothing new to install; without Dropbox or python3 it waits quietly and the plugin works as before, at the poll's pace.

Tried against Dropbox 274.4.4905 (x86_64, in a VM, on my own account):

  • Dropbox sends shell_touch only for files a client has asked about. filestatus asks about the file whose details are shown, so that's the one the watch hears about: of two files changed on dropbox.com, only the one asked about was touched.
  • It touches a file once for each time it was asked about. Asked once and not again, a file was touched as its sync started and not when it ended. Asked again after each touch, as Folio does, it was touched at each change: the file said "syncing" 0.2 seconds after the first touch and "up to date" after the next, 1.5 seconds later, with a last touch as the sync finished.
  • Dropbox's own status lags the touch: right after the first one it still said "Up to date", so the poll at once sees nothing new there and the details row follows the touches.
  • When Dropbox starts it touches every file once (2,622 here, within 1.5 seconds); those lines are taken together.
  • Two listeners on the socket at once both got every message.

The asking after each touch was done by a probe keeping Folio's timing (one ask per touch, half a second of settling), not by Folio's window itself.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous multi-window update bug is fixed.

Summary

Adds plugin watches that trigger polls and refresh file details, with a bundled Dropbox watch.

  • Plugin watch commands refresh results when something changes.
  • File details keep updating while a plugin’s state changes.
  • Dropbox updates file status when its socket reports a change.

Reviews (6) · Last reviewed commit: "Keep an early answer early until a fresh..." · Reviewed by Greptile

Comment thread src/plugins.cpp Resolved
Comment thread src/plugins.cpp Resolved
Comment thread src/plugins.cpp Resolved
Comment thread src/plugins.cpp Resolved
@omarchybot omarchybot added the enhancement New feature or request label Nov 15, 2026
@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, and for writing up #77 first. The interface reads well, but it's a new piece of the plugin API (a long-running command per plugin, restarts, process groups, and a change to how details are forgotten), and nothing bundled uses it yet, so it needs a product decision before it goes in. What would make it mergeable:

  1. A user for it. Pair it with a bundled plugin that needs it, e.g. the Dropbox plugin's details going stale after a sync finishes, so the API is proven by something Folio ships rather than only by tests.
  2. The open Greptile thread is real. A run once more after an early answer starts with no callers, so wanted is empty and it runs even for a file nobody shows any more; with a busy watch that keeps commands running for files the user has left. Keep a way to ask whether the file is still wanted (e.g. carry the last caller's wanted into the follow-up) without keeping callers that already have their answer.
  3. Rebase onto today's main, which it conflicts with now.

Happy to look again once it's there.

cornedor and others added 5 commits November 22, 2026 17:19
A poll asks on a timer, and a file's details are asked for once and kept, so
a plugin whose state changes on its own (a sync finishing) showed it late, or
not until F5. A manifest's "watch" is a command Folio leaves running; each
line it prints has the plugin polled at once and its details asked for again.
Lines that come close together are acted on once, a watch that ends is
started again every 5 seconds, and it ends with Folio or its plugin, with
everything it started.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…a watch's last error line

A watch printing a line every half second had each details command's answer
dropped before it came, so a command slower than that showed nothing for a
file until the watch went quiet, while the dropped commands kept running. A
command still running when its plugin's state changes is now left to finish,
its answer shown, and run once more after, as a poll is. F5 still drops the
answers on their way.

A watch ending on a line of standard error without a newline has it printed
too, as other commands do, since it can be the only reason it stopped.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
While a watch kept printing, every answer was an early one, and its callers
were kept for the command's next run while each change added another, so
the list grew for as long as the watch went on. Callers are now let go once
told, the next run starts without any, and whoever shows the file is told
to read it again when that run had nobody waiting.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A details command whose plugin's state changed while it ran used to run
itself once more, carrying along what its callers had asked so it could
tell whether the file was still shown. The early answer is now kept and
shown but stays marked, and whoever still shows the file asks again the
usual way; a file nobody shows isn't asked about until it's shown again.

A watch's standard error is split into lines by the same code as other
commands', and its held lines are acted on the way its first is.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Comment thread src/plugins.cpp Resolved
@cornedor

Copy link
Copy Markdown
Contributor Author

Thanks for the look. All three are in now:

  1. A user for it. The bundled Dropbox plugin has a watch (71f6077). It doesn't invent anything: it listens on ~/.dropbox/iface_socket, the socket Dropbox's own Nautilus, Nemo and Caja extensions listen on, and prints a line for each shell_touch and when Dropbox stops or starts. I checked what Dropbox really sends there against Dropbox 274.4.4905 in a VM: it touches a file at each change of its status, once for each time the file was asked about, and filestatus asks about the file shown. Asked after each touch, as Folio does, the row went to "syncing" as the sync started and back to "up to date" as it finished, without waiting for the poll. Dropbox's own status lags the touch, so the details row follows the touches and the poll catches the rest. That was a probe keeping Folio's timing, not Folio's window itself. It's sh plus the python3 dropbox-cli already needs, so nothing new to install; without Dropbox or python3 it waits quietly and the plugin works as before.
  2. The Greptile thread. Fixed in d7955e4, and simpler than carrying wanted along: a details command no longer runs itself once more. An early answer is shown and stays marked, and whoever still shows the file asks again through describe(), with their own wanted. A file nobody shows isn't asked about until it's shown again; pluginWatchStopsAskingAboutAFileLeft covers it.
  3. Rebased onto today's main.

Whether an answer came early was kept with the command still running, and forgotten when the first window asked again. A second window showing the same file then took the early answer for the plugin's latest and wasn't told of the fresh one, and a follow-up skipped because its caller had moved on left the early answer looking current. It's now kept with the answer itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let a plugin say when something changed (a watch command)

3 participants