-
Notifications
You must be signed in to change notification settings - Fork 4
feat: dashboard landing, auto-ingestion, stale article fixes #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dadde4d
a155887
332689b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||
| import { useEffect } from 'react' | ||||||
| import { toast } from 'sonner' | ||||||
|
|
||||||
| const MCP_URL = 'https://perception-mcp-w53xszfqnq-uc.a.run.app' | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| const SESSION_KEY = 'perception-auto-ingestion-fired' | ||||||
|
|
||||||
| export default function useAutoIngestion() { | ||||||
| useEffect(() => { | ||||||
| if (sessionStorage.getItem(SESSION_KEY)) return | ||||||
|
|
||||||
| sessionStorage.setItem(SESSION_KEY, '1') | ||||||
|
|
||||||
| fetch(`${MCP_URL}/trigger/ingestion`, { | ||||||
| method: 'POST', | ||||||
| headers: { 'Content-Type': 'application/json' }, | ||||||
| body: JSON.stringify({ | ||||||
| trigger: 'auto', | ||||||
| time_window_hours: 24, | ||||||
| max_items_per_source: 50, | ||||||
| }), | ||||||
| }) | ||||||
| .then(async (res) => { | ||||||
| if (res.status === 202) { | ||||||
| const data = await res.json() | ||||||
| toast.info('Refreshing your feed...', { | ||||||
| description: `Run ID: ${data.run_id}`, | ||||||
| }) | ||||||
|
Comment on lines
+22
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🛡️ Proposed fix- if (res.status === 202) {
- const data = await res.json()
- toast.info('Refreshing your feed...', {
- description: `Run ID: ${data.run_id}`,
- })
- window.dispatchEvent(
- new CustomEvent('auto-ingestion-started', {
- detail: { run_id: data.run_id },
- })
- )
- }
+ if (res.status === 202) {
+ const data = await res.json() as { run_id?: string }
+ if (data.run_id) {
+ toast.info('Refreshing your feed...', {
+ description: `Run ID: ${data.run_id}`,
+ })
+ window.dispatchEvent(
+ new CustomEvent('auto-ingestion-started', {
+ detail: { run_id: data.run_id },
+ })
+ )
+ }
+ }🤖 Prompt for AI Agents |
||||||
| window.dispatchEvent( | ||||||
| new CustomEvent('auto-ingestion-started', { | ||||||
| detail: { run_id: data.run_id }, | ||||||
| }) | ||||||
| ) | ||||||
| } | ||||||
| // 409 = already running, silently ignore | ||||||
| }) | ||||||
| .catch(() => { | ||||||
| // Fire-and-forget — don't block dashboard load | ||||||
| }) | ||||||
|
Comment on lines
+13
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. useautoingestion() swallows fetch errors The new auto-ingestion request silently ignores network/JSON/server failures and unexpected HTTP statuses, making production issues hard to detect and debug. This can leave users with a stale dashboard with no actionable feedback or telemetry. Agent Prompt
Comment on lines
+9
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Session guard blocks retry The auto-ingestion sessionStorage guard is set before the POST succeeds and errors are swallowed. If the request fails, auto-ingestion won’t retry for the rest of the browser session, leaving the feed stale. Agent Prompt
|
||||||
| }, []) | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,18 +234,21 @@ export default function Articles() { | |
|
|
||
| try { | ||
| const articlesRef = collection(db, 'articles') | ||
| const cutoff = new Date(Date.now() - 48 * 60 * 60 * 1000).toISOString() | ||
| let q | ||
|
|
||
| if (selectedCategory === 'all') { | ||
| q = query( | ||
| articlesRef, | ||
| where('published_at', '>=', cutoff), | ||
| orderBy('published_at', 'desc'), | ||
| limit(100) | ||
| ) | ||
| } else { | ||
| q = query( | ||
| articlesRef, | ||
| where('category', '==', selectedCategory), | ||
| where('published_at', '>=', cutoff), | ||
| orderBy('published_at', 'desc'), | ||
| limit(100) | ||
|
Comment on lines
248
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This query combines an equality filter ( |
||
| ) | ||
|
Comment on lines
247
to
254
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify that this composite query works without additional Firestore indexes. The query combines |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Missed auto-ingestion event
🐞 Bug⛯ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools