Skip to content
Open
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
44 changes: 32 additions & 12 deletions apps/mobile/src/app/(app)/agent-chat/repo-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,38 @@ export default function RepoPickerScreen() {
headerContent={
<View className="flex-row items-center gap-2 rounded-full bg-secondary px-3 py-2 mx-4 mb-3 mt-3">
<Search size={18} color={colors.mutedForeground} />
<TextInput
accessibilityLabel={t('agentChat.repoPicker.searchLabel')}
placeholder={t('agentChat.repoPicker.searchPlaceholder')}
placeholderTextColor={colors.mutedForeground}
autoCapitalize="none"
autoCorrect={false}
clearButtonMode="while-editing"
returnKeyType="search"
className="h-8 flex-1 p-0 text-base text-foreground"
style={{ color: colors.foreground }}
onChangeText={setSearch}
/>
{/* The placeholder is a single-line Text overlay, not the input's own
placeholder: Android lays the native hint out at the field's width
with no line cap, so copy wider than a narrow field wraps onto a
second line that the field's fixed height clips against its
border. A tail-ellipsized Text truncates the copy at any width
instead. Both texts share leading-[normal] and a centred text rect
so the overlay sits exactly where the typed text will. */}
<View className="relative flex-1">
<TextInput
accessibilityLabel={t('agentChat.repoPicker.searchLabel')}
autoCapitalize="none"
autoCorrect={false}
clearButtonMode="while-editing"
returnKeyType="search"
textAlignVertical="center"
className="h-8 p-0 text-base leading-[normal] text-foreground"
style={{ color: colors.foreground }}
onChangeText={setSearch}
/>
{search.length === 0 ? (
<View className="absolute inset-0 justify-center" pointerEvents="none">
<Text
accessible={false}
numberOfLines={1}
ellipsizeMode="tail"
className="text-base leading-[normal] font-normal text-muted-foreground"
>
{t('agentChat.repoPicker.searchPlaceholder')}
</Text>
</View>
) : null}
</View>
</View>
}
>
Expand Down
29 changes: 29 additions & 0 deletions apps/mobile/src/components/agents/picker-search.mounted.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,35 @@ describe('repository picker Bitbucket scope note', () => {
});
});

describe('repository picker search placeholder', () => {
const copy = 'Search repositories...';

it('renders a single tail-ellipsized line instead of a wrapping native hint', async () => {
const renderer = await mount(RepoPickerScreen);
const input = hosts(renderer, 'TextInput')[0];
if (!input) {
throw new Error('Picker search input did not mount');
}
// The native hint is what Android lays out at the field width with no line
// cap, wrapping onto a second line the fixed-height field then clips.
expect(input.props.placeholder).toBeUndefined();

const placeholder = hosts(renderer, 'Text').find(node => node.props.children === copy);
if (!placeholder) {
throw new Error('Search placeholder overlay did not mount');
}
expect(placeholder.props.numberOfLines).toBe(1);
expect(placeholder.props.ellipsizeMode).toBe('tail');
expect(placeholder.parent?.props.pointerEvents).toBe('none');

const changeSearch = input.props.onChangeText as (text: string) => void;
act(() => {
changeSearch('org/repo');
});
expect(hosts(renderer, 'Text').some(node => node.props.children === copy)).toBe(false);
});
});

async function mount(Component: () => ReactNode) {
const mounted = await renderWithProviders(createElement(Component));
onTestFinished(mounted.unmount);
Expand Down
Loading