| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
…nc error handling, hook timing, and two-phase init - Guard against undefined Agent.get()/Command.get() at all call sites with typed NamedError and available-name hints instead of silent TypeErrors - Add .catch() on prompt_async route to surface detached prompt failures via Session.Event.Error instead of silently swallowing them - Isolate plugin config hook errors with per-hook try/catch so one failing hook no longer kills the entire bootstrap - Move command.execute.before hook to fire before template parts are merged with input parts, giving plugins access to raw template content - Add two-phase plugin initialization so plugins injected by config hooks are loaded and initialized in the same startup pass - Add tests for agent/command resolution errors, async error handling, command hook timing, and plugin config hook ordering
|
lgtm, just need to resolve merge conflicts |
Sorry, something went wrong.
…stness # Conflicts: # packages/opencode/src/plugin/index.ts # packages/opencode/src/session/prompt.ts
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
…nc errors, hook timing, two-phase init (anomalyco#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Reset to upstream dev: - plugin/index.ts (upstream anomalyco#18280 rewrote plugin error handling) - cli/error.ts (upstream anomalyco#27803 reworked TUI error rendering) - session-data.ts (upstream error typing changes) - session/prompt.ts (massive upstream refactor) - cli/cmd/tui/worker.ts (restored — was deleted by stale merge) Removed dead artifacts: - script/patch-aft-lsp.sh (targets deleted worker.ts architecture) - session-ses_1d10.md, sessions.jsonl (stale session dumps) Backup: fork/local-backup
…nc errors, hook timing, two-phase init (#18280) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #18310
Type of change
What does this PR do?
Agent.get() and Command.get() return undefined for unknown names, but five call sites in prompt.ts dereference the result without null checks — producing a raw TypeError instead of a useful error. The prompt_async route drops errors silently because the detached SessionPrompt.prompt() call has no .catch(). Plugin config hooks aren't error-isolated, so one throwing hook kills the rest. The command.execute.before hook fires after template parts are merged with caller parts, making clean template replacement fragile. And plugins added by a config hook aren't loaded in the same startup pass because Plugin.state() is already cached.
Fixes:
Agent/command null guards — Added null checks at all five Agent.get()/Command.get() call sites (createUserMessage, loop normal + subtask, shell, command). On missing agent/command, throws NamedError.Unknown with the list of available names and publishes Session.Event.Error. Follows the existing guard pattern already at line 1858 of prompt.ts. Empty-string agent falls back to Agent.defaultAgent() instead of looking up "".
prompt_async error handling — Added .catch() on the detached SessionPrompt.prompt() call in the prompt_async route that logs the error and publishes Session.Event.Error. The route still returns 204 immediately — the fire-and-forget semantics are preserved, errors are just no longer invisible.
Config hook error isolation — Wrapped each individual hook.config?.() call in Plugin.init() with try/catch so a failing hook is logged but doesn't prevent others from running.
Command hook timing — Moved Plugin.trigger("command.execute.before") to fire before template parts are merged with input.parts. Plugins now receive template-only parts in output.parts and can replace template content cleanly. input.parts are merged after the hook returns. Subtask path unchanged. No hook type signature change.
Two-phase plugin init — After config hooks fire in Plugin.init(), the code now diffs config.plugin against what was originally loaded, imports any newly-added plugins using the same install/import path as state(), runs their config hooks once, and pushes them into the shared hooks array. One extra pass only — no recursive loading.
How did you verify your code works?
7 new test cases added to existing test files, all passing:
bun typecheck clean across all 13 packages. bun test passes.
Screenshots / recordings
N/A — no UI changes.
Checklist