Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
Please review this pull request and provide feedback on:
- Code quality and best practices
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
id: claude
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
Expand Down
55 changes: 51 additions & 4 deletions app/analyze/[videoId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,25 @@ export default function AnalyzePage() {
setVideoInfo(null);
}

setTopics(hydratedTopics);
setBaseTopics(hydratedTopics);
// Separate base topics and theme topics
const baseTopicsFromCache = hydratedTopics.filter(topic => !topic.theme);
const themeTopicsFromCache = hydratedTopics.filter(topic => topic.theme);

// Reconstruct themeTopicsMap
const reconstructedThemeMap: Record<string, Topic[]> = {};
themeTopicsFromCache.forEach(topic => {
if (topic.theme) {
if (!reconstructedThemeMap[topic.theme]) {
reconstructedThemeMap[topic.theme] = [];
}
reconstructedThemeMap[topic.theme].push(topic);
}
});

setTopics(baseTopicsFromCache);
setBaseTopics(baseTopicsFromCache);
setThemeTopicsMap(reconstructedThemeMap);

const initialKeys = new Set<string>();
hydratedTopics.forEach(topic => {
if (topic.quote?.timestamp && topic.quote.text) {
Expand All @@ -525,7 +542,7 @@ export default function AnalyzePage() {
}
});
setUsedTopicKeys(initialKeys);
setSelectedTopic(hydratedTopics.length > 0 ? hydratedTopics[0] : null);
setSelectedTopic(baseTopicsFromCache.length > 0 ? baseTopicsFromCache[0] : null);

// Set cached takeaways and questions
if (cacheData.summary) {
Expand Down Expand Up @@ -1293,11 +1310,41 @@ export default function AnalyzePage() {
}
});
setUsedTopicKeys(nextUsedKeys);
themedTopics = hydratedThemeTopics;

// Tag theme topics with theme name
const themedTopicsWithTheme = hydratedThemeTopics.map(topic => ({
...topic,
theme: normalizedTheme
}));

themedTopics = themedTopicsWithTheme;
setThemeTopicsMap(prev => ({
...prev,
[normalizedTheme]: themedTopics || []
}));

// Save theme topics to database (background operation)
backgroundOperation(
'save-theme-topics',
async () => {
const allTopics = [
...baseTopics.map(t => ({ ...t, theme: null })),
...Object.entries(themeTopicsMap).flatMap(([theme, topics]) =>
topics.map(t => ({ ...t, theme }))
),
...themedTopicsWithTheme
];

await fetch("/api/update-video-analysis", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
videoId,
topics: allTopics
})
});
}
);
} catch (error) {
const isAbortError =
typeof error === "object" &&
Expand Down
7 changes: 6 additions & 1 deletion app/api/update-video-analysis/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ async function handler(req: NextRequest) {
videoId,
summary,
suggestedQuestions,
translatedTranscripts
translatedTranscripts,
topics
} = await req.json();

if (!videoId) {
Expand Down Expand Up @@ -37,6 +38,10 @@ async function handler(req: NextRequest) {
updateData.translated_transcripts = translatedTranscripts;
}

if (topics !== undefined) {
updateData.topics = topics;
}

const { data: updatedVideo, error: updateError } = await supabase
.from('video_analyses')
.update(updateData)
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Topic {
title: string;
description?: string;
duration: number;
theme?: string | null; // Theme name for theme-based topics, null/undefined for base topics
segments: {
start: number;
end: number;
Expand Down
3 changes: 2 additions & 1 deletion lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ export const checkVideoCacheRequestSchema = z.object({
export const updateVideoAnalysisRequestSchema = z.object({
videoId: youtubeIdSchema,
summary: z.any().optional(),
suggestedQuestions: z.any().optional()
suggestedQuestions: z.any().optional(),
topics: z.array(z.any()).optional()
});

// Rate limiting validation
Expand Down