feat: route BusClient warnings to app.log + toast on fallback #153#154
feat: route BusClient warnings to app.log + toast on fallback #153#154four-bytes-robby wants to merge 1 commit into
Conversation
WalkthroughWalkthrough
ChangesBusClient warning routing and local dependency reference
Estimated code review effort3 (Moderate) | ~15 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
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 `@package.json`:
- Line 18: The `"`@four-bytes/opencode-plugin-lib`":
"file:../four-opencode-plugin-lib"` dependency in package.json uses a local file
reference that will break when the package is published to npm. Either configure
the project to use a workspace setup that conditionally resolves this for
development while maintaining a valid publishable dependency for releases, or
replace the file: reference with a proper semver version number or git reference
to `@four-bytes/opencode-plugin-lib` that is installable for npm consumers.
Additionally, ensure that bun.lock is regenerated after resolving the dependency
to reflect the publishable state.
🪄 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: 724976ea-b499-44e7-a529-06c1f1c690cd
Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
Files selected for processing (2)
package.jsonsrc/status.ts
| ], | ||
| "dependencies": { | ||
| "@four-bytes/opencode-plugin-lib": "github:four-bytes/four-opencode-plugin-lib#v0.6.1", | ||
| "@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether the repo documents/enforces sibling checkout for local file deps
# and whether package managers will need ../four-opencode-plugin-lib to exist.
set -euo pipefail
echo "== package.json dependency =="
cat package.json | sed -n '1,140p' | rg -n '"`@four-bytes/opencode-plugin-lib`"|\"name\"|\"version\"'
echo
echo "== docs/scripts mentioning four-opencode-plugin-lib sibling checkout =="
rg -n -C2 'four-opencode-plugin-lib|file:\.\./four-opencode-plugin-lib|git submodule|workspace|monorepo' README.md docs/ .github/ scripts/ 2>/dev/null || true
echo
echo "== lockfiles (if present) containing local file reference =="
fd -HI '(^|/)(bun\.lockb|bun\.lock|package-lock\.json|pnpm-lock\.yaml|yarn\.lock)$' | while read -r f; do
echo "-- $f"
rg -n 'four-opencode-plugin-lib|file:\.\./four-opencode-plugin-lib' "$f" || true
doneRepository: four-bytes/four-opencode-brain
Length of output: 277
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== package.json content (lines 1-50) =="
head -50 package.json
echo ""
echo "== Package name and version =="
cat package.json | grep -E '"name"|"version"'
echo ""
echo "== All dependencies mentioning four-opencode-plugin-lib =="
cat package.json | grep -n 'four-opencode-plugin-lib'Repository: four-bytes/four-opencode-brain
Length of output: 1877
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== README or documentation mentioning sibling checkout or monorepo =="
for file in README.md README.rst CONTRIBUTING.md SETUP.md docs/SETUP.md; do
if [ -f "$file" ]; then
echo "-- Found: $file"
cat "$file" | head -100
fi
done
echo ""
echo "== Check if ../four-opencode-plugin-lib is documented =="
rg 'four-opencode-plugin-lib|sibling|monorepo|workspace' --type md --type txt 2>/dev/null || echo "No matches found"Repository: four-bytes/four-opencode-brain
Length of output: 8546
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Lockfiles present in repo =="
fd -HI '\.(lock|lockb|yaml)$' | grep -E '(package-lock|pnpm-lock|yarn\.lock|bun\.lock|bun\.lockb)' || echo "No lockfiles found"
echo ""
echo "== Directory structure - check for sibling four-opencode-plugin-lib =="
ls -la ../ 2>/dev/null | grep four-opencode || echo "Cannot list parent directory"Repository: four-bytes/four-opencode-brain
Length of output: 216
Resolve local file: dependency before publishing to npm.
"@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib" at line 18 makes this published npm package uninstallable by consumers. Installation instructions in README.md and docs/SETUP.md do not document the required sibling checkout; users and CI runners following the documentation will fail with missing module errors. The bun.lock file locks this broken state.
For development: gate the file: dependency behind a dev-only condition or workspace setup. For releases: replace with a publishable semver/git ref to @four-bytes/opencode-plugin-lib, or build/publish it separately.
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 `@package.json` at line 18, The `"`@four-bytes/opencode-plugin-lib`":
"file:../four-opencode-plugin-lib"` dependency in package.json uses a local file
reference that will break when the package is published to npm. Either configure
the project to use a workspace setup that conditionally resolves this for
development while maintaining a valid publishable dependency for releases, or
replace the file: reference with a proper semver version number or git reference
to `@four-bytes/opencode-plugin-lib` that is installable for npm consumers.
Additionally, ensure that bun.lock is regenerated after resolving the dependency
to reflect the publishable state.
There was a problem hiding this comment.
2 issues 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="package.json">
<violation number="1" location="package.json:18">
P1: The `file:../four-opencode-plugin-lib` reference will make this package uninstallable for any consumer or CI runner that doesn't have the sibling directory checked out. If this merges and gets published to npm, all installations will fail with a missing module error. Replace with a publishable semver or git ref (e.g., `github:four-bytes/four-opencode-plugin-lib#v0.7.0`) before merging, or gate it behind a workspace/dev-only mechanism.</violation>
</file>
<file name="src/status.ts">
<violation number="1" location="src/status.ts:94">
P2: Bus-connect failure toast is unthrottled and can spam on repeated status writes during outages. Gate this toast (once per window/once per outage) before showing it.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ], | ||
| "dependencies": { | ||
| "@four-bytes/opencode-plugin-lib": "github:four-bytes/four-opencode-plugin-lib#v0.6.1", | ||
| "@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib", |
There was a problem hiding this comment.
P1: The file:../four-opencode-plugin-lib reference will make this package uninstallable for any consumer or CI runner that doesn't have the sibling directory checked out. If this merges and gets published to npm, all installations will fail with a missing module error. Replace with a publishable semver or git ref (e.g., github:four-bytes/four-opencode-plugin-lib#v0.7.0) before merging, or gate it behind a workspace/dev-only mechanism.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At package.json, line 18:
<comment>The `file:../four-opencode-plugin-lib` reference will make this package uninstallable for any consumer or CI runner that doesn't have the sibling directory checked out. If this merges and gets published to npm, all installations will fail with a missing module error. Replace with a publishable semver or git ref (e.g., `github:four-bytes/four-opencode-plugin-lib#v0.7.0`) before merging, or gate it behind a workspace/dev-only mechanism.</comment>
<file context>
@@ -15,7 +15,7 @@
],
"dependencies": {
- "@four-bytes/opencode-plugin-lib": "github:four-bytes/four-opencode-plugin-lib#v0.6.1",
+ "@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib",
"@opencode-ai/plugin": "1.16.2",
"@opentui/core": "0.3.2",
</file context>
| "@four-bytes/opencode-plugin-lib": "file:../four-opencode-plugin-lib", | |
| "@four-bytes/opencode-plugin-lib": "github:four-bytes/four-opencode-plugin-lib#v0.7.0", |
| return bus; | ||
| }).catch((err) => { | ||
| _client?.app?.log({ body: { service: "brain", level: "error", message: "BusClient connect failed", extra: { error: String(err) } } }).catch(() => {}); | ||
| _client?.tui?.showToast({ body: { title: "Brain 🧠", message: "Bus connection failed: " + String(err).slice(0, 80), variant: "error", duration: 7000 } }); |
There was a problem hiding this comment.
P2: Bus-connect failure toast is unthrottled and can spam on repeated status writes during outages. Gate this toast (once per window/once per outage) before showing it.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/status.ts, line 94:
<comment>Bus-connect failure toast is unthrottled and can spam on repeated status writes during outages. Gate this toast (once per window/once per outage) before showing it.</comment>
<file context>
@@ -79,9 +79,20 @@ export function initStatus(client: PluginInput["client"], directory: string): vo
+ return bus;
+ }).catch((err) => {
+ _client?.app?.log({ body: { service: "brain", level: "error", message: "BusClient connect failed", extra: { error: String(err) } } }).catch(() => {});
+ _client?.tui?.showToast({ body: { title: "Brain 🧠", message: "Bus connection failed: " + String(err).slice(0, 80), variant: "error", duration: 7000 } });
+ _busPromise = null;
throw err;
</file context>
Closes #153
Changes
getBus()passesonWarncallback toBusClient.connect()— routes warnings toapp.logactivePort === 0) and shows a toast.catch()handler upgraded fromwarntoerrorlevel + toastDepends on
@four-bytes/opencode-plugin-libv0.7.0 (merged, not yet published — using local path)Summary by cubic
Routes
BusClientwarnings toapp.logand shows toasts when the bus falls back to memory or fails to connect. Improves visibility and guides users to install the local bus.New Features
BusClient.connect()warnings toapp.log.four-local-bus.Dependencies
@four-bytes/opencode-plugin-libv0.7.0 via localfile:path until published.1.7.8.Written for commit 0b9492b. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Chores