Skip to content

fix(web): disable transcript editor during pending saves to prevent discarding later typing (#3502) - #3542

Open
ghazy2001 wants to merge 2 commits into
CapSoftware:mainfrom
ghazy2001:fix/transcript-save-pending-draft-3502
Open

ghazy2001 wants to merge 2 commits into
CapSoftware:mainfrom
ghazy2001:fix/transcript-save-pending-draft-3502

Conversation

@ghazy2001

@ghazy2001 ghazy2001 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3502
Linear: CAP-949

When editing a transcript cue in the share page (apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx), saving the edit sends an async update request via updateTranscriptMutation.mutateAsync(...).

While the save request was in flight:

  1. The textarea remained enabled and editable. Any characters typed by the user while the mutation was resolving were abruptly overwritten and discarded once the mutation resolved, as Transcript replaced the cue with the saved response snapshot.
  2. Clicking other transcript rows or action buttons during save was permitted, risking race conditions and lost edits.
  3. If an edit was triggered for a different cue while a previous save was in flight, setEditingEntry(null) cleared the active edit state unconditionally when the previous save completed.

Changes

  • apps/web/app/s/[videoId]/_components/tabs/transcript-row.tsx:
    • Bound disabled={isSaving} on the editing <textarea> with disabled:cursor-not-allowed disabled:opacity-50 styling, visually indicating save in flight and preventing user keystrokes from being discarded on settlement.
  • apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx:
    • Guarded handleTranscriptClick, startEditing, cancelEditing, and saveEdit against isSaving.
    • Captured entryIdToSave = editingEntry before initiating the async mutation; only clears editingEntry (setEditingEntry(null)) if editingEntry === entryIdToSave when the mutation settles.
    • Passed canEdit={canEdit && !isSaving} to TranscriptRow to disable action buttons while a cue save is in progress.

Test plan

  • Ran unit tests with Bun:
    • bun test apps/web/__tests__/unit/transcript-vtt.test.ts (4 passed in 279ms)
    • bun test apps/web/__tests__/unit/transcript-text.test.ts (9 passed in 160ms)
  • Verified textarea is disabled during isSaving === true and re-enabled once mutation finishes.
  • Verified clicking other cues or cancel while saving does not trigger race conditions or discard draft edits.

RetriggerView in GreptileConfidence Score: 4/5

Update the existing pending-save test before merging.

Findings

  1. P1 Existing transcript test fails ▶
Fix with agent prompt
### Issue 1
apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx:824
The pending-save test in `share-transcript-rendering.test.ts:299` calls `editCue(3)` while a save is pending. This change removes that row's edit button, so the helper throws `Missing edit button` before the test finishes. Update the test to expect editing to stay blocked, check that the textarea is disabled, and then resolve the save.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR prevents typing and switching transcript rows while a save is pending.

  • Transcript edits stay locked until each save finishes.

ghazy2001 explicitly describes blocking other transcript rows during saves as intentional.
Tests were inspected, not run.

Reviews (1) · Last reviewed commit: "fix(web): disable transcript editor duri..." · Reviewed by Greptile

…iscarding later typing (CapSoftware#3502)

When saving a transcript cue correction, the editor previously remained writable while the request was in flight. Any edits typed during the save were discarded when the earlier request resolved and closed the editor. Additionally, triggering an edit on another cue during a pending save could cause its draft to be cleared.

- Disable the active cue textarea while isSaving is true
- Hide and disable cue edit actions across other transcript rows while isSaving is true
- Guard startEditing, cancelEditing, and handleTranscriptClick against running during pending saves
- Capture entryIdToSave in saveEdit and only close the editor if the active entry still matches the saved entry

Closes CapSoftware#3502
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 29, 2026 5:23pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 29, 2026 12:27 Inactive
entry={entry}
selected={selectedEntry === entry.id}
canEdit={canEdit}
canEdit={canEdit && !isSaving}

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.

P1 Existing transcript test fails

The pending-save test in share-transcript-rendering.test.ts:299 calls editCue(3) while a save is pending. This change removes that row's edit button, so the helper throws Missing edit button before the test finishes. Update the test to expect editing to stay blocked, check that the textarea is disabled, and then resolve the save.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
Line: 824

Comment:
**Existing transcript test fails**

The pending-save test in `share-transcript-rendering.test.ts:299` calls `editCue(3)` while a save is pending. This change removes that row's edit button, so the helper throws `Missing edit button` before the test finishes. Update the test to expect editing to stay blocked, check that the textarea is disabled, and then resolve the save.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in commit \2c33594b: updated test assertions in \share-transcript-rendering.test.ts\ to verify the active textarea is disabled, other cue edit buttons remain blocked (null) during pending saves, and then resolves the save cleanly.

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 29, 2026 17:23 Inactive

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 2c33594b Deployed Oct 29, 2026 by vercel[bot]
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.

Pending transcript saves discard later typing

1 participant