Detect external CLI runs in Web UI operation banner#130
Merged
StudioNirin merged 10 commits intoApr 7, 2026
Conversation
Owner
|
@Brandon-Haney I'm having to do this from mobile so ill give you a change to reply before I go through and do more checks in case ive mucked something up. |
Extract activity recording (FileActivity, load/save, run summary) from web/services/operation_runner.py into core/activity.py so CLI-triggered runs are visible in the Web UI dashboard. FileMover gains an optional file_activity_callback for per-file recording during CLI runs.
When PlexCache is triggered via docker exec or cron, the web UI banner now detects the running process via plexcache.lock and tails the shared log file to show live progress. Displays a purple CLI badge, phase info, file counts, and ETA — same detail as web-triggered runs. Idle banner poll reduced from 30s to 10s for faster detection.
Log files use plexcache_log_latest.log symlink, not plexcache.log. This was preventing log parsing for external CLI run detection.
Track external CLI process lifecycle so the banner shows a completion pill with file counts and duration when the CLI run finishes. Completion banner auto-dismisses after 60 seconds or on manual dismiss. Shows CLI badge in completed state. Also fixes dismiss to clear external state.
- Parse error messages from log (up to 10, shown in completion detail) - Detect dry run mode from log header (DRY RUN / --dry-run) - Add user lookups from OnDeck/Watchlist trackers for cached files - Apply dry run prefix to phase display during external runs
CLI process registers a SIGTERM handler that calls request_stop() for graceful shutdown (finishes current file, then exits). The web banner's Stop button sends SIGTERM to the external PID read from plexcache.lock. Same behavior as web-triggered stop — no data loss.
FileMover now logs [Copying] before each file copy starts. The external log parser tracks [Copying] entries minus completed [Cached]/[Restored] to derive currently-active files. Tier 3 detail now shows COPYING rows for external CLI runs, matching web-triggered run behavior.
The parser read the last 200KB of the log file, but verbose runs easily exceed 600KB. Once the file outgrew the read window, the run header fell outside and the parser returned default Starting/0s state. Now reads backwards in 256KB chunks to find the header, then reads forward from there. Works for any log size with minimal I/O per poll.
Stop requests during _process_media() and _process_watchlist() were ignored until the entire phase completed because checks only existed between sections, not inside the per-item loops. Now bails within one iteration of OnDeck tracker, watchlist local, and watchlist RSS loops.
signal.signal() raises ValueError when called from a background thread. Skip registration when run from web UI's OperationRunner thread — the web UI uses request_stop() directly instead.
Brandon-Haney
force-pushed
the
pr/external-cli-detection
branch
from
April 7, 2026 14:32
e608e8d to
3b217d6
Compare
Collaborator
Author
@StudioNirin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core/activity.py) so CLI and Web UI share activity trackingshould_stopchecks inside media processing loops for faster shutdownRelates to #127
Test plan
--verboseto generate large logs — parser should not lose state