Skip to content

Link a clip's post text on the review page - #181

Merged
A21-devs merged 1 commit into
mainfrom
feat/post-text-download
Dec 5, 2026
Merged

A21-devs merged 1 commit into
mainfrom
feat/post-text-download

Conversation

@A21-devs

@A21-devs A21-devs commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Closes #115.

What

  • The files row on each clip card is built by showFiles(), which adds download text (the <clip>.txt from --copy or Write title, clip.post in the manifest) after mp4, srt and cover when the clip has one. Like the others it uses the download attribute with the file's own name, so a batch of clips lands next to their text files.
  • After Write title / Rewrite title succeeds, the card takes post from the returned manifest along with copy and rebuilds just the files row. The first title on a run without --copy adds the link without rebuilding the card, so the videos keep playing.

Testing

  • uv run ruff check src tests, uv run pytest -q tests/test_write_title.py: 15 passed (the page has no JS test setup, so the full suite and CI cover the Python side).
  • New tests: after a title is written through the endpoint, the manifest's post file downloads through /api/jobs/<id>/files/<name> byte-for-byte (UTF-8, text/plain). A check on index.html that the files row includes clip.post and that the Write title handler sets clip.post and calls showFiles().
  • Real page in headless Edge, driven over the DevTools protocol from a small node script (no window opened). clipwright serve with CLIPWRIGHT_OPENAI_URL pointing at a local stub backend, job on a 240 s synthetic video (TTS speech over Roblox gameplay), 2 clips, no --copy:
    • on load: both cards download mp4 / srt / cover, no text link (no post file yet)
    • Write title on clip 1 with "openai" chosen in the form: clip 1 gets download text, clip 2 is unchanged
    • the link's download name is talk_clip01.txt, and fetching it returns the stub's title, description and #roblox
    • still 2 <video> elements on the page, the cards weren't rebuilt

@A21-devs A21-devs added the ui label Dec 5, 2026

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Checked the page side:

  • showFiles() reads the clip object the closure already holds, and Write title updates clip.post before calling it, so the link shows up without the card being rebuilt (the headless run in the description confirms the videos stay).
  • A Rewrite keeps the same .txt name, so the link doesn't change. Files are served with Cache-Control: no-cache, so a second download revalidates instead of handing back the old title.
  • Clips without a post file get no link, same as srt and cover.

One real problem, in the new test, inline. It only shows up once #180 is merged.

Comment thread tests/test_write_title.py Outdated
manifest.write_text(json.dumps(data))
return dict(data["clips"][n - 1])

monkeypatch.setattr(server, "write_clip_copy", fake)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

#180 (open, CI running) removes write_clip_copy from server's imports: the endpoint now calls draft_clip_copy and then save_clip_copy. If that merges first, monkeypatch.setattr(server, "write_clip_copy", fake) raises AttributeError (setattr's default raising=True) and this test fails on main. The two PRs touch different lines, so git won't flag a conflict. Whichever merges second has to follow the other. With #180 in, the fake should be a draft_clip_copy that returns a draft, and .txt writing then goes through the real save_clip_copy, which tests the download better anyway.

The .txt that --copy and Write title make was served but not linked, so
batch uploads meant copying title, description and hashtags by hand.
The files row now has 'download text' for clips with a post file and
is rebuilt after Write title, so the first title adds the link.
@A21-devs
A21-devs force-pushed the feat/post-text-download branch from 3f35dda to b14c502 Compare December 5, 2026 00:57
@A21-devs

A21-devs commented Dec 5, 2026

Copy link
Copy Markdown
Owner Author

#180 merged first, so I rebased onto main (force-pushed, now b14c502). The new test and #180's tests were both added at the end of tests/test_write_title.py, so git did flag a conflict there after all. The resolution is in the rebased commit:

  • test_the_post_text_can_be_downloaded_after_writing_a_title now fakes draft_clip_copy (returning a draft titled Title é), and the real save_clip_copy writes the .txt. The test checks that post is my clip_clip01.txt, that the download matches the file on disk byte for byte, that the first line decodes as Title é, and that it's served as text/plain.
  • tests/test_write_title.py: 20 passed, ruff clean.
  • Reran the headless Edge check on the rebased branch (now with Write a clip's title without holding the edit lock #180's draft/save endpoint): same result. Clip 1 gets download text after Write title, the link points to talk_clip01.txt with the stub's text, clip 2 is unchanged, and the 2 videos stay.

The page code is unchanged from the first push.

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Second pass over the rebased b14c502. The finding is fixed: the test no longer touches server.write_clip_copy. It fakes draft_clip_copy, which exists on main since #180, and goes through the real save_clip_copy, so the .txt it downloads is the one the endpoint actually wrote. I diffed index.html against the first push and it's identical. The rest of the test file is #180's tests unchanged plus the page check. Clean.

@A21-devs
A21-devs merged commit eaab74c into main Dec 5, 2026
4 checks passed
@A21-devs
A21-devs deleted the feat/post-text-download branch December 5, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review page has no download link for a clip's post text

1 participant