fix(tui): add null check for local.agent.current()#8745
fix(tui): add null check for local.agent.current()#8745wydrox wants to merge 2 commits intoanomalyco:devfrom
Conversation
…lity (anomalyco#8658) Co-authored-by: Mark Henderson <Mark.Henderson99@hotmail.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
The `local.agent.current()` function can return undefined when no agents are available (empty agents list). This caused a TypeError when trying to access `.name` property on undefined. Fix by adding optional chaining and nullish coalescing for safe access: - `local.agent.current()?.name ?? "build"` for agent names - `local.agent.current()?.name ?? ""` for UI display Affected files: - packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx (6 locations) - packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx (1 location)
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundSeveral PRs address similar or overlapping issues with
Recommendation: Check if PR #8745 is addressing a newly discovered case or if it's duplicating work from earlier PRs, particularly #7920 (prompt-specific) or #7748/#7689 (general agent.current() handling). |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
fix(tui): add null check for local.agent.current()
The
local.agent.current()function can return undefined when no agents areavailable (empty agents list). This caused a TypeError when trying to access
.nameproperty on undefined.Fix by adding optional chaining and nullish coalescing for safe access:
local.agent.current()?.name ?? "build"for agent nameslocal.agent.current()?.name ?? ""for UI displayAffected files: