feat: add recent paths suggestions and improve UX polish

- Add recent paths hook to persist and suggest working directories
- Update Android icon assets and simplify adaptive icon configuration
- Remove background styling from header icon buttons for cleaner look
- Export expandTilde utility for path normalization in agent creation
- Add horizontal scrollable chips for recent path suggestions
```
This commit is contained in:
Mohamed Boudra
2025-10-23 11:26:36 +02:00
parent 8177aa0c2a
commit 85a0e46ba9
10 changed files with 130 additions and 16 deletions
@@ -13,6 +13,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { X } from "lucide-react-native";
import { StyleSheet } from "react-native-unistyles";
import { theme as defaultTheme } from "@/styles/theme";
import { useRecentPaths } from "@/hooks/use-recent-paths";
interface CreateAgentModalProps {
isVisible: boolean;
@@ -40,6 +41,7 @@ export function CreateAgentModal({
}: CreateAgentModalProps) {
const insets = useSafeAreaInsets();
const { height: keyboardHeight } = useReanimatedKeyboardAnimation();
const { recentPaths, addRecentPath } = useRecentPaths();
const [workingDir, setWorkingDir] = useState("");
const [selectedMode, setSelectedMode] = useState("plan");
@@ -56,13 +58,23 @@ export function CreateAgentModal({
};
});
function handleCreate() {
async function handleCreate() {
if (!workingDir.trim()) {
setErrorMessage("Working directory is required");
return;
}
onCreateAgent(workingDir.trim(), selectedMode);
const path = workingDir.trim();
// Save to recent paths
try {
await addRecentPath(path);
} catch (error) {
console.error("[CreateAgentModal] Failed to save recent path:", error);
// Continue anyway - don't block agent creation
}
onCreateAgent(path, selectedMode);
handleClose();
}
@@ -123,6 +135,28 @@ export function CreateAgentModal({
Absolute path to the project directory
</Text>
)}
{/* Recent Paths Chips */}
{recentPaths.length > 0 && (
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
contentContainerStyle={styles.recentPathsContainer}
keyboardShouldPersistTaps="handled"
>
{recentPaths.map((path) => (
<Pressable
key={path}
style={styles.recentPathChip}
onPress={() => setWorkingDir(path)}
>
<Text style={styles.recentPathChipText} numberOfLines={1}>
{path}
</Text>
</Pressable>
))}
</ScrollView>
)}
</View>
{/* Mode Selector */}
@@ -339,4 +373,23 @@ const styles = StyleSheet.create((theme) => ({
fontSize: theme.fontSize.base,
fontWeight: theme.fontWeight.semibold,
},
recentPathsContainer: {
flexDirection: "row",
gap: theme.spacing[2],
paddingVertical: theme.spacing[3],
},
recentPathChip: {
backgroundColor: theme.colors.muted,
borderRadius: theme.borderRadius.full,
paddingHorizontal: theme.spacing[4],
paddingVertical: theme.spacing[2],
borderWidth: theme.borderWidth[1],
borderColor: theme.colors.border,
maxWidth: 200,
},
recentPathChipText: {
color: theme.colors.foreground,
fontSize: theme.fontSize.sm,
fontWeight: theme.fontWeight.medium,
},
}));
+2 -4
View File
@@ -12,11 +12,9 @@ export function EmptyState({ onCreateAgent }: EmptyStateProps) {
return (
<View style={styles.container}>
<Text style={styles.title}>Hammock</Text>
<Text style={styles.subtitle}>
What would you like to work on?
</Text>
<Text style={styles.subtitle}>What would you like to work on?</Text>
<Pressable onPress={onCreateAgent} style={styles.button}>
<Plus size={20} color={theme.colors.foreground} />
<Plus size={20} color={styles.buttonText.color} />
<Text style={styles.buttonText}>New agent</Text>
</Pressable>
</View>
@@ -34,10 +34,7 @@ export function HomeHeader({ onCreateAgent }: HomeHeaderProps) {
>
<MessageSquare size={20} color={theme.colors.foreground} />
</Pressable>
<Pressable
onPress={onCreateAgent}
style={styles.iconButton}
>
<Pressable onPress={onCreateAgent} style={styles.iconButton}>
<Plus size={20} color={theme.colors.foreground} />
</Pressable>
</View>
@@ -74,6 +71,5 @@ const styles = StyleSheet.create((theme) => ({
iconButton: {
padding: theme.spacing[3],
borderRadius: theme.borderRadius.lg,
backgroundColor: theme.colors.muted,
},
}));