Elffuss BraidHub

kikocis/continue public

main · 977 BRawPermalink
1import { Text } from "ink";
2import React, { useMemo } from "react";
3
4import { useTerminalSize } from "../hooks/useTerminalSize.js";
5import { getResponsiveRepoText } from "../hooks/useTUIChatHooks.js";
6
7interface ResponsiveRepoDisplayProps {
8 remoteUrl?: string;
9 reservedWidth?: number; // Width reserved for other elements in the same row
10}
11
12export const ResponsiveRepoDisplay: React.FC<ResponsiveRepoDisplayProps> = ({
13 remoteUrl,
14}) => {
15 const { columns } = useTerminalSize();
16
17 const repoText = useMemo(() => {
18 // Calculate available width for repo display
19 // Reserve space for margins, mode indicator, context percentage, and other UI elements
20 const availableWidth = Math.floor(columns / 2);
21
22 return getResponsiveRepoText(remoteUrl, availableWidth);
23 }, [remoteUrl, columns]);
24
25 // Don't render if no text to show
26 if (!repoText) {
27 return null;
28 }
29
30 return (
31 <Text color="dim" wrap="truncate-start">
32 {repoText}
33 </Text>
34 );
35};