feat: project-scoped bus + immediate auto-ingest + app.log warnings #151 #152 #153#155
Conversation
|
No actionable comments were generated in the recent review. 🎉 Recent review infoRun configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughWalkthroughAuto-ingest is moved from the ChangesAuto-ingest timing fix and project-scoped status bus
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Tip: You can configure your own custom pre-merge checks in the settings. Finishing TouchesGenerate docstrings
Generate unit tests (beta)
Simplify code
Comment |
|
|
||
| // Trigger auto-ingest immediately (fire-and-forget, not deferred to session.created). | ||
| // updateStatus("ready") is NOT called here — auto-ingest transitions to ready/success/error on its own. | ||
| if (autoIngest && !shouldSkip && !_autoIngestDone) { |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/status.ts (1)
139-155:⚠️ Potential issue | 🔴 CriticalUpdate TUI subscription to match project-scoped publishing.
The publisher at line 149 sends status events to
bus.forService("brain").forProject(projectId), but the TUI insrc/tui.tsxline 65 remains subscribed to a session-scoped channel:useServiceBus("brain", () => props.sessionId, "status", (payload) => { handleStatus(payload as BrainStatusEvent); });The TUI must switch from
props.sessionIdtoforProject(projectId)to receive the published events. Update the subscription to:useServiceBus("brain", () => deriveProjectId(props.directory), "status", (payload) => { handleStatus(payload as BrainStatusEvent); });Also correct the comment at line 140 to reflect the actual subscription method.
Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/status.ts` around lines 139 - 155, The TUI subscription in src/tui.tsx at the useServiceBus call is subscribed to a session-scoped channel using props.sessionId, but the publisher in src/status.ts sends status events to a project-scoped channel using forProject(projectId). Update the useServiceBus subscription in src/tui.tsx to use deriveProjectId(props.directory) instead of props.sessionId as the scope identifier so the TUI receives the project-scoped status events being published. After making this change, verify that the comment at line 140 in src/status.ts accurately reflects the updated subscription behavior.
Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/status.ts`:
- Line 7: The import statement in the status.ts file is trying to import
deriveProjectId from the opencode-plugin-lib library, but this export does not
exist in the currently installed version 0.6.1. Update the dependency version
for `@four-bytes/opencode-plugin-lib` in package.json to ^0.7.1, which is the
required version that exports deriveProjectId and supports the forProject()
method referenced in the PR objectives.
---
Outside diff comments:
In `@src/status.ts`:
- Around line 139-155: The TUI subscription in src/tui.tsx at the useServiceBus
call is subscribed to a session-scoped channel using props.sessionId, but the
publisher in src/status.ts sends status events to a project-scoped channel using
forProject(projectId). Update the useServiceBus subscription in src/tui.tsx to
use deriveProjectId(props.directory) instead of props.sessionId as the scope
identifier so the TUI receives the project-scoped status events being published.
After making this change, verify that the comment at line 140 in src/status.ts
accurately reflects the updated subscription behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ff8e443c-651a-4366-ad9e-3f527cb33d7b
Files selected for processing (3)
package.jsonsrc/four-opencode-brain.tssrc/status.ts
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/four-opencode-brain.ts">
<violation number="1" location="src/four-opencode-brain.ts:174">
P2: Auto-ingest top-level rejection path only logs and does not update status, so startup can be stuck in busy state. Handle the catch by publishing an error status.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| runAutoIngest().catch((err) => { | ||
| log("error", "auto-ingest", `Auto-ingest failed: ${String(err)}`); | ||
| }); |
There was a problem hiding this comment.
P2: Auto-ingest top-level rejection path only logs and does not update status, so startup can be stuck in busy state. Handle the catch by publishing an error status.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/four-opencode-brain.ts, line 174:
<comment>Auto-ingest top-level rejection path only logs and does not update status, so startup can be stuck in busy state. Handle the catch by publishing an error status.</comment>
<file context>
@@ -91,102 +91,91 @@ const _serverPlugin = async (input: PluginInput) => {
+ // updateStatus("ready") is NOT called here — auto-ingest transitions to ready/success/error on its own.
+ if (autoIngest && !shouldSkip && !_autoIngestDone) {
+ _autoIngestDone = true;
+ runAutoIngest().catch((err) => {
+ log("error", "auto-ingest", `Auto-ingest failed: ${String(err)}`);
+ });
</file context>
| runAutoIngest().catch((err) => { | |
| log("error", "auto-ingest", `Auto-ingest failed: ${String(err)}`); | |
| }); | |
| runAutoIngest().catch((err) => { | |
| const errMsg = `Auto-ingest failed: ${String(err)}`; | |
| log("error", "auto-ingest", errMsg); | |
| updateStatus("error", { text: errMsg, toast: errMsg }); | |
| }); |
Closes #151, closes #152, closes #153
Changes
Depends on
Summary by cubic
Switch brain status updates to project-scoped bus channels, start auto-ingest immediately at plugin init, and inline project ID hashing so server and TUI share the same channel. Adds app.log warnings for bus issues and fixes the startup “ready” race. (#151, #152, #153, #155)
New Features
bus.forService("brain").forProject(deriveProjectId(directory))instead of session-scoped channels. ([FIX] Project-scoped bus for startup/ingest status — drop session routing #152)app.logviaonWarn; show a toast when falling back toMemoryBusClient. (Route BusClient fallback warnings to app.log + toast instead of console.warn #153)@four-bytes/opencode-plugin-libv0.7.1.Bug Fixes
updateStatus("ready")when no ingest is running to avoid the startup race. ([FIX] Project-scoped bus for startup/ingest status — drop session routing #152)deriveProjectIdand switch TUI toforProject(...)subscription to match server publishing. (feat: project-scoped bus + immediate auto-ingest + app.log warnings #151 #152 #153 #155)Written for commit 049e925. Summary will update on new commits.
Summary by CodeRabbit