Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions apps/mobile/src/features/threads/ComposerCommandPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Pressable, ScrollView, useColorScheme, View, type ViewStyle } from "rea

import { AppText as Text } from "../../components/AppText";
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
import { composerCommandEmptyText } from "./composerCommandPopoverText";
export type ComposerCommandItem =
| {
readonly id: string;
Expand Down Expand Up @@ -59,7 +60,7 @@ function PopoverSurface(props: {
if (isLiquidGlassSupported) {
return (
<LiquidGlassView
effect="clear"
effect="regular"
interactive={false}
tintColor={props.isDarkMode ? "rgba(30,30,32,0.95)" : "rgba(255,255,255,0.92)"}
colorScheme={props.isDarkMode ? "dark" : "light"}
Expand Down Expand Up @@ -111,26 +112,11 @@ function groupLabel(triggerKind: ComposerTriggerKind | null): string | null {
}
}

function emptyText(triggerKind: ComposerTriggerKind | null, isLoading: boolean): string {
if (isLoading) {
return triggerKind === "path" ? "Searching files…" : "Loading…";
}
switch (triggerKind) {
case "path":
return "No matching files or folders.";
case "skill":
return "No skills found.";
case "slash-command":
return "No matching commands.";
default:
return "No results.";
}
}

const CommandRow = memo(function CommandRow(props: {
readonly item: ComposerCommandItem;
readonly onPress: () => void;
readonly isLast: boolean;
readonly isDarkMode: boolean;
}) {
const iconName = itemIcon(props.item);
const iconColor = "#a1a1aa";
Expand All @@ -146,7 +132,7 @@ const CommandRow = memo(function CommandRow(props: {
gap: 10,
opacity: pressed ? 0.6 : 1,
borderBottomWidth: props.isLast ? 0 : 0.5,
borderBottomColor: "rgba(255,255,255,0.1)",
borderBottomColor: props.isDarkMode ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.1)",
})}
>
{props.item.type === "path" ? (
Expand Down Expand Up @@ -193,13 +179,14 @@ export const ComposerCommandPopover = memo(function ComposerCommandPopover(
item={item}
onPress={() => props.onSelect(item)}
isLast={index === props.items.length - 1}
isDarkMode={isDarkMode}
/>
))}
</ScrollView>
) : (
<View className="px-3.5 py-2.5">
<Text className="text-xs text-foreground-tertiary">
{emptyText(props.triggerKind, props.isLoading)}
{composerCommandEmptyText(props.triggerKind, props.isLoading)}
</Text>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, it } from "vite-plus/test";

import { composerCommandEmptyText } from "./composerCommandPopoverText";

describe("composerCommandEmptyText", () => {
it("uses legible loading copy for path and command searches", () => {
expect(composerCommandEmptyText("path", true)).toBe("Searching files…");
expect(composerCommandEmptyText("slash-command", true)).toBe("Loading…");
});

it("uses trigger-specific empty copy", () => {
expect(composerCommandEmptyText("path", false)).toBe("No matching files or folders.");
expect(composerCommandEmptyText("skill", false)).toBe("No skills found.");
expect(composerCommandEmptyText("slash-command", false)).toBe("No matching commands.");
expect(composerCommandEmptyText(null, false)).toBe("No results.");
});
});
21 changes: 21 additions & 0 deletions apps/mobile/src/features/threads/composerCommandPopoverText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { ComposerTriggerKind } from "@t3tools/shared/composerTrigger";

export function composerCommandEmptyText(
triggerKind: ComposerTriggerKind | null,
isLoading: boolean,
): string {
if (isLoading) {
return triggerKind === "path" ? "Searching files…" : "Loading…";
}

switch (triggerKind) {
case "path":
return "No matching files or folders.";
case "skill":
return "No skills found.";
case "slash-command":
return "No matching commands.";
default:
return "No results.";
}
}
Loading