feat(dashboard): stream business context research through oRPC - #812
Conversation
|
The latest updates on your projects. Learn more about Unkey Deploy
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
This comment has been minimized.
This comment has been minimized.
Greptile SummaryThis PR moves organization business-context research from the Insights queue into an API-hosted oRPC stream while preserving billing, recovery, and concurrency guarantees.
Confidence Score: 5/5The exact final head appears safe to merge; the previously reported cancellation and rolling-deployment failures are resolved and no new actionable issue remains. Final publication now checks the request signal inside the database transaction and rolls back cancellation observed before commit authorization, while cleanup is constrained to the matching active generation. The worker compatibility handler matches the prior API’s legacy job payload and deterministic job ID and safely leaves newer or terminal generations unchanged. Both previous threads were manually resolved after their fixes, and no repository-rule violation or new merge-blocking behavior was found. Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Dashboard editor
participant RPC as oRPC generate stream
participant API as API research runner
participant DB as Business-context service
participant AI as AI provider
participant Billing as Usage settlement
UI->>RPC: generate(organization, website, sources)
RPC->>DB: atomically begin generation
DB-->>RPC: running generation
RPC-->>UI: initial running state
RPC->>API: generate(generationId, request signal)
API->>DB: publish reading/writing progress
DB-->>API: current state
API-->>UI: streamed state updates
API->>AI: research and synthesize
AI-->>API: output and usage
API->>Billing: settle consumed usage independently
API->>DB: publish ready draft within cancellation-aware transaction
DB-->>UI: ready draft for explicit acceptance
alt request cancelled before completion
UI--xRPC: abort stream
RPC--xAPI: abort matching request
RPC->>DB: remove matching active generation only
end
Reviews (4): Last reviewed commit: "fix(api): retire queued research during ..." | Re-trigger Greptile |
dec9dd6 to
be7ebd8
Compare
|
The cancellation and queued-job findings are addressed in 2c5ccce and 0d80edb, with replies in their threads. The streaming fixture also uses portable Promise constructors in 2951dec, fixing the older Node runtime failure reported by CI. The resume.ts / legacy investigation billing removals mentioned in the summary belong to staging commit a6e0c25: git diff origin/staging...HEAD -- apps/insights/src/resume.ts is empty. This PR is rebased onto staging 8a3ecda, including the separate merged scheduler fixture repair #813. Please assess the final head against that current base. |
|
@greptileai review this final head (0d80edb) against current staging (8a3ecda). The prior cancellation and rollout findings have fixes and regression coverage; all CI checks now pass, including 53 browser tests and both new PostgreSQL regressions. Please refresh the review on this exact head. |
Business-context research now runs inside an active oRPC streaming request. The draft updates as sources are read and the brief is written; stopping, navigating away, or refreshing aborts the request and clears only its matching active generation. Manual edits and research inputs remain recoverable, and completed drafts still require explicit acceptance.
The API owns the existing bounded research runner instead of the insights queue. Atomic admission prevents duplicate runs, and cancellation is checked inside the publication transaction. Independent usage settlement preserves credit accounting after cancellation. The worker retires jobs admitted by an older API during rollout with a refresh/retry message; it no longer generates business context. The first draft remains included; subsequent drafts retain the existing credit checks. No new dependency or schema migration.
Validation: final-head CI is green, including all 53 browser tests, 27 PostgreSQL business-context tests, and the native worker regression for retiring legacy jobs. Repository lint, all 33 typecheck tasks, all 27 test tasks, 57 runner cases, and 27 RPC cases also pass. Coverage includes incremental streaming, desktop/mobile layout stability, cancellation before the first event and during billing/publication, saving during streaming, disconnect recovery, research-input recovery, and history/measurement controls. The runner uses the real installed AI SDK with a synthetic provider in tests. Live staging provider smoke remains pending a selected organization and website.
Scope: business-context generation, request cancellation, and recovery of its editor/research inputs. No outstanding dependencies; the separate scheduler fixture repair #813 is already merged into the base. Known file overlap: #790 also touches packages/rpc/src/orpc.ts for billing configuration; this change only adds the API-hosted generation callback. AI-assisted implementation and review.