Skip to content

A personal agent with a browser, terminal, files, and work that keeps going built with CopilotKit and AG-UI.

TypeScript

fix: stop leaking empty strings into Views (#56)

Asem ahmed01b93a102492
diff --git a/apps/mobile/src/agent-ui.tsx b/apps/mobile/src/agent-ui.tsx
index 3e1b891..e7034b5 100644
--- a/apps/mobile/src/agent-ui.tsx
+++ b/apps/mobile/src/agent-ui.tsx
@@ -78,7 +78,7 @@ export function AgentStatus() {
return (
<View style={{ gap: 8 }}>
<ErrorNotice error={error ? `Agent updates unavailable. ${error}` : ""} />
- {error && (
+ {!!error && (
<Button small onPress={() => void refresh().catch(() => {})}>
Reconnect agent
</Button>
@@ -523,7 +523,7 @@ export function TaskDetail({ taskId }: { taskId: string }) {
))}
</Card>
)}
- {task.result && (
+ {!!task.result && (
<Card style={{ backgroundColor: colors.green }}>
<Text selectable style={s.text}>
{resultSummary(task.result)}
@@ -1036,7 +1036,7 @@ export function IdeasScreen() {
<Card key={idea.id} style={{ gap: 7 }}>
<Text style={s.heading}>{idea.title}</Text>
<Chip tint={colors.green}>Started</Chip>
- {idea.taskId && <TaskLink taskId={idea.taskId} />}
+ {!!idea.taskId && <TaskLink taskId={idea.taskId} />}
</Card>
))}
</View>
@@ -1582,7 +1582,7 @@ function MonitorCard({ monitor, onOpenTask }: { monitor: Monitor; onOpenTask?: (
Last check: {stamp(monitor.lastCheckedAt)}
{monitor.status === "active" ? `\nNext check: ${stamp(monitor.nextCheckAt)}` : ""}
</Text>
- {monitor.lastValue && (
+ {!!monitor.lastValue && (
<Text selectable numberOfLines={5} style={s.muted}>
{monitor.lastValue}
</Text>
diff --git a/apps/mobile/src/chat.tsx b/apps/mobile/src/chat.tsx
index 26f3d36..683332b 100644
--- a/apps/mobile/src/chat.tsx
+++ b/apps/mobile/src/chat.tsx
@@ -540,7 +540,7 @@ export function ChatScreen({
</View>
)}
<ErrorNotice error={error} />
- {error && (
+ {!!error && (
<Button
style={{ alignSelf: "flex-start" }}
icon={RotateCcw}
diff --git a/apps/mobile/src/computer-workspace.tsx b/apps/mobile/src/computer-workspace.tsx
index 9150d97..a9298cf 100644
--- a/apps/mobile/src/computer-workspace.tsx
+++ b/apps/mobile/src/computer-workspace.tsx
@@ -140,7 +140,7 @@ export function LinuxWorkspace({ tab }: { tab: "Terminal" | "Files" }) {
</View>
{!snapshot && !error && <ActivityIndicator color={colors.blueDark} />}
</View>
- {snapshot?.message && <Text style={s.small}>{snapshot.message}</Text>}
+ {!!snapshot?.message && <Text style={s.small}>{snapshot.message}</Text>}
{snapshot?.enabled && (
<View style={[s.row, { gap: 8, flexWrap: "wrap" }]}>
{running ? (
diff --git a/apps/mobile/src/details.tsx b/apps/mobile/src/details.tsx
index fa27880..1ff3a14 100644
--- a/apps/mobile/src/details.tsx
+++ b/apps/mobile/src/details.tsx
@@ -184,7 +184,7 @@ function MailDetail({ mail: m }: { mail: Mail }) {
</Card>
))}
<ErrorNotice error={error} />
- {error && <Button onPress={() => setRetry(retry + 1)}>Reload conversation</Button>}
+ {!!error && <Button onPress={() => setRetry(retry + 1)}>Reload conversation</Button>}
<Button
primary
icon={Reply}
@@ -674,7 +674,7 @@ function ReviewDetail({ initial }: { initial: ActionProposal }) {
)}
</Card>
<ErrorNotice error={error || action.error} />
- {action.result && (
+ {!!action.result && (
<Card style={{ marginTop: 16, backgroundColor: colors.green, padding: 18 }}>
<Text selectable style={s.text}>
{resultSummary(action.result)}
diff --git a/apps/mobile/src/screens.tsx b/apps/mobile/src/screens.tsx
index 8b0639b..86ba851 100644
--- a/apps/mobile/src/screens.tsx
+++ b/apps/mobile/src/screens.tsx
@@ -778,7 +778,7 @@ export function CalendarScreen() {
{selected?.name || "Your calendar"} · {zone}. Events show their own time zone.
</Text>
<ErrorNotice error={error} />
- {error && (
+ {!!error && (
<Button small onPress={() => setRetry(retry + 1)}>
Try again
</Button>
@@ -898,7 +898,7 @@ export function BrowserScreen() {
<Chip tint={b.status === "active" ? colors.green : colors.canvas}>{b.status}</Chip>
<ArrowUpRight size={17} color={colors.muted} />
</View>
- {b.previewUrl && (
+ {!!b.previewUrl && (
<Image
source={{ uri: api.url(b.previewUrl) }}
resizeMode="cover"
diff --git a/apps/mobile/src/thread-artifacts.tsx b/apps/mobile/src/thread-artifacts.tsx
index 2444a01..9aa98c4 100644
--- a/apps/mobile/src/thread-artifacts.tsx
+++ b/apps/mobile/src/thread-artifacts.tsx
@@ -104,7 +104,7 @@ export function TaskThreadCard({ task }: { task: AgentTask }) {
<ArtifactCard key={artifact.id} artifact={artifact} />
))}
<ErrorNotice error={error} />
- {error && (
+ {!!error && (
<Button small onPress={() => setAttempt((value) => value + 1)}>
Reload task results
</Button>
diff --git a/apps/mobile/src/ui.tsx b/apps/mobile/src/ui.tsx
index e9e95af..ce36605 100644
--- a/apps/mobile/src/ui.tsx
+++ b/apps/mobile/src/ui.tsx
@@ -295,7 +295,7 @@ export function Sheet({
>
<View style={{ flex: 1, gap: 4 }}>
<Text style={s.title}>{title}</Text>
- {subtitle && <Text style={s.muted}>{subtitle}</Text>}
+ {!!subtitle && <Text style={s.muted}>{subtitle}</Text>}
</View>
<IconButton icon={X} label="Close details" onPress={onClose} />
</View>
@@ -393,7 +393,7 @@ export function LinkRow({
</View>
<View style={{ flex: 1, gap: 3 }}>
<Text style={[s.text, { fontWeight: "500" }]}>{title}</Text>
- {detail && <Text style={s.small}>{detail}</Text>}
+ {!!detail && <Text style={s.small}>{detail}</Text>}
</View>
<ChevronRight size={15} color={colors.muted} />
</Pressable>