Skip to content

E4 — Channels & Discovery#109

Open
aloewright wants to merge 2 commits into
mainfrom
conductor/alo-123-e4-channels-discovery
Open

E4 — Channels & Discovery#109
aloewright wants to merge 2 commits into
mainfrom
conductor/alo-123-e4-channels-discovery

Conversation

@aloewright
Copy link
Copy Markdown
Owner

@aloewright aloewright commented May 8, 2026

Closes ALO-123.

Summary

E4 (channel pages, trending feed, search, tags, related videos, up-next queue) was already shipped across earlier tickets (ALO-145/152/153/156, etc). This PR closes out the remaining E4 scope items.

Recommendations — simple co-watch. /api/videos/:id/related now runs a watch_history self-join between the same-channel pass and the FTS5 pass:

  1. Same-channel (existing)
  2. Co-watch (new) — videos other viewers of this one also watched, ranked by co-occurrence count
  3. FTS5 over title (existing)
  4. Trending top-up (existing)

Empty watch_history overlap gracefully falls through. KV cache key/TTL unchanged.

Co-watch index (migration 0019). Adds idx_watch_history(video_id) so the wh1 anchor of the self-join is an index seek instead of a full table scan; otherwise every related-video request scales with total catalog watches. schema.sql is updated to mirror watch_history + both indexes so a fresh clone starts from the same shape the migrations produce.

Browse by topic on Home. New rail under Trending fetches /api/tags?limit=12 and renders chips linking to /tag/:slug. Logged-out visitors get the category surface without leaving the home feed. Hidden cleanly when no tagged videos exist yet so we don't render an empty section.

Test plan

  • npm test — 494/494 pass (co-watch ordering + migration assertions)
  • npm run lint — clean, AI-gateway guard clean
  • npm run type-check — clean
  • npm run build — clean
  • Manual: log in, watch a video, log in as second user, watch the same + a sibling, then load related on the original — sibling should appear above FTS picks
  • Manual: hit / logged-out — Trending → Browse by topic → Start here in that order; tag chips link to /tag/:slug

…LO-123)

Inserts a watch_history self-join between same-channel and FTS passes so
viewers get videos that other people who watched this one also watched.
Ranks by co-occurrence count, view count, recency.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 8, 2026 14:57
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@aloewright aloewright added the conductor Conductor-managed PR label May 8, 2026
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools Bot commented May 8, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Warning

Rate limit exceeded

@aloewright has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 1 second before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ca5fadf-5119-45dd-9ae5-6c1b53b2d2a5

📥 Commits

Reviewing files that changed from the base of the PR and between 4d3c13f and 9ec6f2a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • src/db/migrations.test.ts
  • src/db/migrations/0019_co_watch_index.sql
  • src/db/schema.sql
  • src/frontend/App.tsx
  • src/workers/related.test.ts
  • src/workers/related.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch conductor/alo-123-e4-channels-discovery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9b02279f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workers/related.ts
Comment on lines +123 to +127
FROM watch_history wh1
JOIN watch_history wh2 ON wh2.user_id = wh1.user_id AND wh2.video_id != wh1.video_id
JOIN videos v ON v.id = wh2.video_id
LEFT JOIN user u ON u.id = v.user_id
WHERE wh1.video_id = ?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a video_id index for the new co-watch scan

The new co-watch pass filters on wh1.video_id = ? and then self-joins watch_history, but the existing schema only defines PRIMARY KEY (user_id, video_id) plus idx_watch_history_user_recent (see src/db/migrations/0015_watch_history.sql), so this path has no dedicated leading index on video_id. As watch_history grows, related-video requests will degrade into large scans/high row reads on a hot endpoint, which can materially hurt latency and cost in production; adding an index like (video_id, user_id) for this query shape would avoid that regression.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Builds on the existing co-watch step in /api/videos/:id/related to finish
the E4 scope:

- Migration 0019 adds idx_watch_history(video_id) so the co-watch self-join
  starts from an index seek on the cohort of viewers, instead of scanning
  the full watch_history table.
- Schema mirror picks up watch_history + both indexes so a fresh dev clone
  starts from the same shape the migrations produce.
- Browse-by-topic rail on Home fetches /api/tags top tags and renders them
  as chips linking to /tag/:slug. Logged-out visitors get the category
  surface without leaving the home feed; the section hides cleanly when
  the catalog has no tagged videos yet.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools Bot commented May 9, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conductor Conductor-managed PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants