Skip to content

feat: edit AI summaries and chapters - #2233

Merged
richiemcilroy merged 3 commits into
mainfrom
feature/editable-ai-content
Sep 7, 2026
Merged

feat: edit AI summaries and chapters#2233
richiemcilroy merged 3 commits into
mainfrom
feature/editable-ai-content

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Sep 7, 2026

Copy link
Copy Markdown
Member

Owners can now edit summaries and chapter titles/timestamps from the share page Summary tab, with add/remove chapters, Save/Cancel, inline validation, pending/error states, and unsaved-draft protection. Saved content updates the shared query cache so the summary, chapter list, and player markers stay in sync.

Owner-authorized writes use a short row-locked transaction, field-level conflict detection, and atomic JSON updates. Manual edits survive late AI results; replacing video content still permits regeneration. Generation queueing also preserves concurrent metadata edits. Deliberately cleared fields stay empty; replacing video content deletes their JSON keys and permits fresh generation even when old manual flags remain. No database migration or new dependency.

Validation: 96 focused tests passed; Biome passed for all changed files; no TypeScript diagnostics in changed files (existing dependency diagnostics remain). Actual React components verified in Chromium at desktop and mobile widths, covering validation, failed-save recovery, saving, chapter seeking, fixture reload persistence, and read-only viewers. Browser save boundary was mocked; live database-backed verification was unavailable because local Cap services were not running.

Greptile Summary

This PR lets video owners edit AI summaries and chapter titles/timestamps from the share page while preserving concurrent metadata updates and manual content during later AI generation.

  • Adds an owner-authorized, row-locked server action with field-level conflict detection and validation.
  • Adds an inline summary and chapter editor with save, cancellation, validation, cache synchronization, and unsaved-draft protection.
  • Updates generation metadata writes to preserve concurrent and manually edited fields.
  • Adds focused unit coverage for editing, timestamps, regeneration, conflicts, permissions, and UI state.

Confidence Score: 5/5

The PR appears safe to merge; both previous findings are resolved and no actionable new issue remains.

Media replacement removes summary and chapter paths before regeneration, so cleared manual content no longer blocks replacement AI results. The resolved whitespace thread is also addressed through consistent normalization in the editor and server action.

Important Files Changed

Filename Overview
apps/web/actions/videos/edit-ai-content.ts Adds authenticated, entitled, row-locked AI-content editing with validation, conflict detection, and atomic JSON field updates.
apps/web/app/s/[videoId]/_components/tabs/SummaryEditor.tsx Implements the client-side summary and chapter editor, including normalized dirty tracking, validation, save recovery, and cache updates.
apps/web/app/s/[videoId]/_components/tabs/Summary.tsx Integrates owner-only editing and accessible chapter seeking into the Summary tab.
apps/web/lib/ai-content-metadata.ts Protects existing manual content during AI result writes while allowing regeneration after media replacement removes content paths.
apps/web/lib/ai-content.ts Centralizes AI-content normalization, equality checks, validation, and chapter timestamp parsing and formatting.
apps/web/workflows/generate-ai.ts Applies generated summaries and chapters atomically without overwriting protected manual edits.
apps/web/lib/generate-ai.ts Queues generation through an atomic JSON status update that preserves concurrent metadata changes.

Reviews (2): Last reviewed commit: "fix: normalize AI content before detecti..." | Re-trigger Greptile

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment on lines +11 to +13
return sql`IF(
JSON_UNQUOTE(JSON_EXTRACT(${videos.metadata}, ${editedPath})) = 'true'
AND JSON_CONTAINS_PATH(${videos.metadata}, 'one', ${path}),

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 Cleared content blocks regeneration

When an owner clears the summary or chapters, the edit action keeps the empty JSON path and sets its manual-edit flag. This condition then treats that empty field as protected, so later AI generation discards the generated replacement. As a result, replacing the video content cannot restore the cleared summary or chapters as intended.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/lib/ai-content-metadata.ts
Line: 11-13

Comment:
**Cleared content blocks regeneration**

When an owner clears the summary or chapters, the edit action keeps the empty JSON path and sets its manual-edit flag. This condition then treats that empty field as protected, so later AI generation discards the generated replacement. As a result, replacing the video content cannot restore the cleared summary or chapters as intended.

---

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

Comment thread apps/web/app/s/[videoId]/_components/tabs/SummaryEditor.tsx Outdated
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@richiemcilroy
richiemcilroy merged commit c5f22d7 into main Sep 7, 2026
27 checks passed
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.

1 participant