Skip to content

fix(web): close the marker editor when the player switches file version - #4210

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/4107-marker-draft-version-switch
Nov 15, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/4107-marker-draft-version-switch

Conversation

@Rhainland

@Rhainland Rhainland commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #4107
Related issue: #1150
Validation tasks: changes #1153 C1 (not run yet)

Other clients: Apple N/A (no marker editor); Android N/A (no marker editor); Roku N/A (no marker editor)

In the web player, a marker draft started on one file version could be saved onto a different version. If you opened Edit markers, changed a range, then picked another version in Playback settings, the panel stayed open with the old draft, and Save sent it to the file now playing. That file got a range built from the other file's values, and the file you actually edited stayed unchanged. Anyone with marker editing on an item with more than one version is affected.

The player now closes the Edit markers panel when the playing file changes, so a draft only ever saves to the file it was made on.

Approach

useMarkerEditor remembers which file its draft belongs to. A version switch keeps the player mounted and only hands the hook a new file ID, so when that ID changes the hook closes the draft, and Save does nothing unless a draft is open. Reopening the panel takes a fresh copy of the new file's markers. Picking the version that is already playing does not close the panel.

A save still in flight when the file changes finishes against the file it started on, then leaves the editor alone, so it can't replace or close a draft opened on the new version.

The issue also allowed saving the draft to the original file instead. Closing is simpler, and the alternative would leave the seek bar showing one file's markers over another file's video.

Web only. The server and API are unchanged.

Validation

  • Web hook test: a draft closes when the file ID changes, Save afterwards sends nothing, and switching back does not restore the draft. Fails on main, passes here.
  • Web hook test: a save that finishes after a version switch leaves the new version's open draft alone and still reports the old file's change. Fails on the head before that fix, passes here.
  • pnpm run lint, format:check, build, budget:check, make test-web: pass.
  • make verify-local-paths, verify-size-ratchet, verify-bidi, verify-case-collisions: pass. Go checks not run: no Go changes.
  • Local build with the real web bundle, an episode with two synthetic versions holding different preview markers, headless Chromium at 1440 and 390 px: same steps on main and on this branch (results below).

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-4210/

Episode with two versions: file 3 (720p, preview 2:30–2:50) and file 4 (1080p, preview 2:30–2:55). Playing file 4: open Edit markers, Preview, Set start, switch to 720p, Save.

main:
  panel after switch: open, Preview 0:05 – 2:55
  PUT /api/v2/markers/files/3 {"preview":{"start_seconds":5.174601,"end_seconds":175}}
  stored after: file 3 preview 5.17–175, file 4 preview 150–175 (unchanged)

this branch:
  panel after switch: closed
  no PUT sent
  stored after: file 3 preview 150–170, file 4 preview 150–175 (both unchanged)

this branch, reopen Edit markers on the new version and save:
  panel shows file 4's own preview (2:30 – 2:55)
  PUT /api/v2/markers/files/4 {"preview":{"start_seconds":60.447728,"end_seconds":175}}

Risks

An unsaved draft is discarded whenever the playing file changes while the panel is open. Before, Save would have written that draft to the wrong file.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code (via T3 Code); Codex CLI for code review
  • Tool(s): Claude Code, Codex CLI, Playwright (headless Chromium), GitHub CLI
  • Model(s): claude-opus-5-5; gpt-6.1-sol (code review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: independent reviews of the full diff by claude-opus-5-5 and gpt-6.1-sol on correctness, repository standards, and the issue's requirements. Neither found anything to change.

Note

Close marker editor in useMarkerEditor when the player switches file version

  • The useMarkerEditor hook now tracks the file ID for the current draft. When the fileId prop changes, it closes editing and clears the error.
  • A save attempted while editing is closed returns immediately and issues no request.
  • If a save request completes after the file ID changed, its success or failure no longer updates the new file's draft or error. A successful save still calls onSaved with the submitted body.
  • Risk: check useMarkerEditor.ts if any consumer relied on late save results applying to the newly loaded file version.

Macroscope summarized 0c2fd7e.

A version switch keeps the player mounted and hands useMarkerEditor the
new file id, so an open draft from the previous file was saved onto the
file now playing. The hook now closes the draft when its file changes,
and Save does nothing unless a draft is open.
@silo-triage silo-triage Bot added the size/S 0–49 added + deleted lines (all files); change volume, not priority. label Nov 14, 2026
@silo-kody

silo-kody Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The marker editor now closes its draft and clears errors when the playing file changes. It does not send a save request when editing is inactive. A test covers switching files, attempting to save, and switching back.

Changes: Marker editor file switching

Layer / File(s) Summary
Reset and guard marker drafts
web/src/player/hooks/useMarkerEditor.ts, web/src/player/hooks/useMarkerEditor.test.tsx
The hook tracks the file associated with the draft. When the file changes, it exits editing and clears the error. Saving now also requires editing to be active. The test verifies that saving after a switch makes no fetch request and switching back does not reopen editing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: quick104

Merge Risk: Low · up to d2d67

Switching file versions now closes the marker editor and blocks saves while editing is inactive. One narrow edge case remains: if a save is still in flight during a switch and the user reopens the editor, the late save result can replace the new draft and close the panel. Marker data is not written to the wrong file. This is worth fixing or accepting before merge.

Security architecture risk: Minimal · up to d2d67

The change prevents an old marker draft from being saved after switching files. The inspected code establishes no introduced or worsened risk to security, failure containment, rollback, or ownership guarantees.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The assessed effect is confined to initiating file-marker writes from the web editor. The endpoint and file identifier construction remain unchanged; no increased service or credential authority is established by this change.

Security Findings and Attack Paths

  • inferred — The previously described edit-file-A, switch-to-B, then-save path is narrowed: switching ends editing, and the current save callback cannot issue a request until editing is restarted. This supports improved draft-to-file isolation, not a claim that all marker authorization paths are secure.

Resilience and Maintainability Implications

  • observed — Closing editing does not abort an already-started request. Its file ID remains captured, but completion can update hook state after cancellation or reopening. The same completion logic and enabled cancellation controls existed before this PR, so this is pre-existing behavior rather than an introduced architecture concern. Draft invalidation is not transactional rollback.
Pre-merge checks: Passed 2

Check name Status Explanation
Title check Passed The title names the main change: the marker editor now closes when the player switches file version. It matches the changeset in useMarkerEditor.ts and its test, and it uses the conventional fix(web) …
Description check Passed The description explains the problem (a marker draft saved to a different file version), the approach (useMarkerEditor tracks the draft's file ID and closes editing when it changes), validation steps,…
Full details: Title check

Explanation

The title names the main change: the marker editor now closes when the player switches file version. It matches the changeset in useMarkerEditor.ts and its test, and it uses the conventional fix(web) prefix. The title is 71 characters, which is within a normal range.

Full details: Description check

Explanation

The description explains the problem (a marker draft saved to a different file version), the approach (useMarkerEditor tracks the draft's file ID and closes editing when it changes), validation steps, and risks. It matches the changes in the hook and its test.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment thread web/src/player/hooks/useMarkerEditor.ts Resolved
@silo-triage silo-triage Bot added bug Something isn't working javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Nov 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83595587-e12c-414a-9fb3-3ae85a1b5f35
Commits

Reviewing files that changed from the base of the PR and between feae205 and 11466e2.

Files selected for processing: 2

  • web/src/player/hooks/useMarkerEditor.test.tsx
  • web/src/player/hooks/useMarkerEditor.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment thread web/src/player/hooks/useMarkerEditor.ts Resolved
Quick104 and others added 2 commits November 14, 2026 19:45
A version switch now closes the Edit markers panel, so the editor can be
reopened on the new file while a save from the old one is still in flight.
When that save finished, it replaced the new draft with the old file's and
closed the panel, and a failure showed its error on the new file's panel.
The save still reports what it wrote to the old file, but leaves the
editor state alone once the playing file has changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added size/M 50–199 added + deleted lines (all files); change volume, not priority. and removed size/S 0–49 added + deleted lines (all files); change volume, not priority. labels Nov 15, 2026
@silo-kody

silo-kody Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@Quick104

Copy link
Copy Markdown
Contributor

Review of 0c2fd7e10c, which is this PR's change plus a merge of main (main had changed the same hook in #4231) and one fix commit.

The approach holds. Closing the Edit markers panel when the playing file changes is the simplest fix #4107 allows, and it keeps the seek bar from showing one file's markers over another file's video.

Addressed

  • A save still in flight during a version switch could replace and close a draft opened on the new version (raised by CodeRabbit and Kody). Fixed in 0c2fd7e10c. Such a save still reports what it wrote to the old file, but no longer touches the editor. Marker data was never written to the wrong file on this path.

Remaining: nothing.

Tests

  • The PR's version-switch test fails on main (the panel stays open) and passes here.
  • The new late-save test fails on the head before 0c2fd7e10c (the new draft closes) and passes here.
  • Prettier, eslint, the web typecheck, and the hook tests pass locally.

Cross-provider review: gpt-6.1-sol reviewed the merged head with extra temporary tests (StrictMode, same-file refreshes, null file ids, late seek-bar edits) and found nothing beyond the in-flight save.

Validated features: Marker authoring & editing, Web (#1153). C1 covers editing markers from the web player and has not been run yet, so no passed case can regress. The Validation tasks: line stands.

User manual: unaffected. The markers page doesn't describe what the player's panel does on a version switch.

Other clients: only the web player has a marker editor, as the PR says.

Evidence: still current. My fix touches only a save that finishes after the file changed, which none of the captured steps do.

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

  • Fit: a small web-only fix that stops a save going to the wrong file, with no new settings or API surface.
  • Readiness: both fixes have tests that fail without them, and the author's browser run shows the reported behavior gone. I did not reproduce it live myself.

🤖 Claude Code (claude-opus-5-5)

Comment on lines 227 to 228
try {
onSaved?.(body);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Late saves notify the host with markers from the previous file

Because onSaved receives no file ID, a save that finishes after a version switch can overwrite the current file's markers with values from the previous file. Include the saved file ID in onSaved and apply the update only to the matching file.

Prompt for LLM
File web/src/player/hooks/useMarkerEditor.ts, lines 227-228:

Late saves notify the host with markers from the previous file

A save that completes after a version switch still sends the old file's marker changes to `onSaved`, whose contract provides no file ID for the host to distinguish them from updates to the currently playing file. This can patch the new version's local markers with the old version's values; include the saved file ID in the callback and apply the update only to the matching file.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@Quick104
Quick104 merged commit da3b11f into Silo-Server:main Nov 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Web player saves a marker draft to the other file version after a version switch

2 participants