Conversation
WalkthroughSubDetect language-detection is added end-to-end: user schema gains an optional Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Frontend as Frontend UI
participant Backend as AIOStreams
participant DB as User Data Store
participant SubDetectAPI as SubDetect API
User->>Frontend: Enable SubDetect
alt API Key missing
Frontend->>Backend: POST /generate-api-key
Backend->>SubDetectAPI: Request key / register
SubDetectAPI-->>Backend: API key
Backend-->>Frontend: API key returned
end
Frontend->>DB: Save subdetect {enabled, apiKey}
DB-->>Frontend: Persisted
rect rgba(100, 150, 255, 0.5)
Backend->>Backend: Collect streams grouped by release name
Backend->>SubDetectAPI: POST releases (batched ≤20)
SubDetectAPI-->>Backend: Results with language_codes
Backend->>Backend: Convert ISO-639-2 → language names
Backend->>Backend: Merge languages into stream.parsedFile.languages
end
Backend-->>Frontend: Enriched streams
Frontend->>User: Display languages
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/core/src/main.ts`:
- Around line 2172-2230: The _enrichWithSubDetectLanguages method currently
calls this.subdetectService.detectLanguages which can throw and break the
pipeline; wrap the detectLanguages call in a try/catch and on any error log a
warning via logger.warn including the error and return the original streams
(i.e., fail open) so enrichment is optional; ensure subsequent logic only runs
when detectLanguages succeeds (e.g., skip enrichment if detectedLanguages is
undefined/null).
In `@packages/server/src/app.ts`:
- Around line 16-17: The import fails because subdetectApi is not exported from
the API barrel; open the module that should declare the route (the router or
handler named subdetectApi in packages/server/src/routes/api/index.ts or its
submodule) and either add a named export for subdetectApi (export const
subdetectApi = ... or export { subdetectApi } from './subdetect') or re-export
it from the barrel (export { subdetectApi } from './subdetect') so the import in
app.ts can resolve; confirm the route module exists and that the exported symbol
name exactly matches subdetectApi used in the import.
🧹 Nitpick comments (3)
packages/core/src/utils/subdetect.ts (2)
8-9: Consider making the SubDetect base URL configurable.Hard-coding the API host makes self-hosting or staging environments awkward. A small Env-driven override would keep the default while enabling custom deployments.
♻️ Possible tweak
-import { makeRequest } from './http.js'; +import { makeRequest } from './http.js'; +import { Env } from './env.js'; ... -const SUBDETECT_API_URL = 'https://subdetect.chromeknight.dev'; +const SUBDETECT_API_URL = + Env.SUBDETECT_API_URL ?? 'https://subdetect.chromeknight.dev';
39-44: Avoid repeated linear scans for language lookups.
FULL_LANGUAGE_MAPPING.find(...)runs for every language code; a precomputed map is a low-cost optimisation when processing batches.♻️ Suggested change
-export function convertISO6392ToLanguage(code: string): string | undefined { - const lang = FULL_LANGUAGE_MAPPING.find( - (language) => language.iso_639_2 === code.toLowerCase() - ); - return lang?.english_name?.split('(')?.[0]?.trim(); -} +const ISO6392_TO_NAME = new Map( + FULL_LANGUAGE_MAPPING.map((language) => [ + language.iso_639_2?.toLowerCase(), + language.english_name?.split('(')?.[0]?.trim(), + ]).filter( + (entry): entry is [string, string] => Boolean(entry[0] && entry[1]) + ) +); + +export function convertISO6392ToLanguage(code: string): string | undefined { + return ISO6392_TO_NAME.get(code.toLowerCase()); +}packages/frontend/src/components/menu/miscellaneous.tsx (1)
451-459: Consider avoiding the hard-coded SubDetect host.Using a fixed external URL makes the feature brittle for self-hosted or proxied deployments, and bypasses the new server route. It would be more flexible to call your own API route (or a configurable base URL) so deployments can override the host cleanly.
/generate-keyendpointSummary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.