Skip to content

Commit 2835dae

Browse files
fix(tui): add null safety for local.agent.current().name (anomalyco#8858)
1 parent f197b8a commit 2835dae

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function DialogAgent() {
2020
return (
2121
<DialogSelect
2222
title="Select agent"
23-
current={local.agent.current().name}
23+
current={local.agent.current()?.name}
2424
options={options()}
2525
onSelect={(option) => {
2626
local.agent.set(option.value)

‎packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ export function Prompt(props: PromptProps) {
531531
if (store.mode === "shell") {
532532
sdk.client.session.shell({
533533
sessionID,
534-
agent: local.agent.current().name,
534+
agent: local.agent.current()?.name ?? "build",
535535
model: {
536536
providerID: selectedModel.providerID,
537537
modelID: selectedModel.modelID,
@@ -552,7 +552,7 @@ export function Prompt(props: PromptProps) {
552552
sessionID,
553553
command: command.slice(1),
554554
arguments: args.join(" "),
555-
agent: local.agent.current().name,
555+
agent: local.agent.current()?.name ?? "build",
556556
model: `${selectedModel.providerID}/${selectedModel.modelID}`,
557557
messageID,
558558
variant,
@@ -569,7 +569,7 @@ export function Prompt(props: PromptProps) {
569569
sessionID,
570570
...selectedModel,
571571
messageID,
572-
agent: local.agent.current().name,
572+
agent: local.agent.current()?.name ?? "build",
573573
model: selectedModel,
574574
variant,
575575
parts: [
@@ -690,7 +690,7 @@ export function Prompt(props: PromptProps) {
690690
const highlight = createMemo(() => {
691691
if (keybind.leader) return theme.border
692692
if (store.mode === "shell") return theme.primary
693-
return local.agent.color(local.agent.current().name)
693+
return local.agent.color(local.agent.current()?.name ?? "build")
694694
})
695695

696696
const showVariant = createMemo(() => {
@@ -701,7 +701,7 @@ export function Prompt(props: PromptProps) {
701701
})
702702

703703
const spinnerDef = createMemo(() => {
704-
const color = local.agent.color(local.agent.current().name)
704+
const color = local.agent.color(local.agent.current()?.name ?? "build")
705705
return {
706706
frames: createFrames({
707707
color,
@@ -935,7 +935,7 @@ export function Prompt(props: PromptProps) {
935935
/>
936936
<box flexDirection="row" flexShrink={0} paddingTop={1} gap={1}>
937937
<text fg={highlight()}>
938-
{store.mode === "shell" ? "Shell" : Locale.titlecase(local.agent.current().name)}{" "}
938+
{store.mode === "shell" ? "Shell" : Locale.titlecase(local.agent.current()?.name ?? "build")}{" "}
939939
</text>
940940
<Show when={store.mode === "normal"}>
941941
<box flexDirection="row" gap={1}>

0 commit comments

Comments
 (0)