Skip to content

Commit 2f9d1f2

Browse files
authored
🤖 feat: move token estimate inside text input (#1204)
Shows the token count next to the mic icon inside the textarea. --- _Generated with `mux` • Model: `mux-gateway:anthropic/claude-opus-4-5` • Thinking: `high`_
1 parent 1ae0377 commit 2f9d1f2

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

‎src/browser/components/ChatInput/index.tsx‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,14 @@ const ChatInputInner: React.FC<ChatInputProps> = (props) => {
16471647
aria-expanded={showCommandSuggestions && commandSuggestions.length > 0}
16481648
className={variant === "creation" ? "min-h-24" : undefined}
16491649
/>
1650+
{/* Token count - positioned to left of mic */}
1651+
{preferredModel && hasTypedText && (
1652+
<div className="absolute right-8 bottom-2">
1653+
<Suspense fallback={<span className="text-muted/50 text-xs">…</span>}>
1654+
<TokenCountDisplay reader={tokenCountReader} />
1655+
</Suspense>
1656+
</div>
1657+
)}
16501658
{/* Floating voice input button inside textarea */}
16511659
<div className="absolute right-2 bottom-2">
16521660
<VoiceInputButton
@@ -1734,23 +1742,6 @@ const ChatInputInner: React.FC<ChatInputProps> = (props) => {
17341742
<ModelSettings model={baseModel || ""} />
17351743
</div>
17361744

1737-
{preferredModel && (
1738-
<div className={hasTypedText ? "block" : "hidden"}>
1739-
<Suspense
1740-
fallback={
1741-
<div
1742-
className="text-muted flex items-center gap-1 text-xs"
1743-
data-component="TokenEstimate"
1744-
>
1745-
<span>Calculating tokens…</span>
1746-
</div>
1747-
}
1748-
>
1749-
<TokenCountDisplay reader={tokenCountReader} />
1750-
</Suspense>
1751-
</div>
1752-
)}
1753-
17541745
<div
17551746
className="ml-auto flex items-center gap-2"
17561747
data-component="ModelControls"
@@ -1802,8 +1793,8 @@ const TokenCountDisplay: React.FC<{ reader: TokenCountReader }> = ({ reader }) =
18021793
return null;
18031794
}
18041795
return (
1805-
<div className="text-muted flex items-center gap-1 text-xs" data-component="TokenEstimate">
1806-
<span>{tokens.toLocaleString()} tokens</span>
1807-
</div>
1796+
<span className="text-muted/50 text-xs" data-component="TokenEstimate">
1797+
{tokens.toLocaleString()} tokens
1798+
</span>
18081799
);
18091800
};

0 commit comments

Comments
 (0)