Skip to content

Commit 2a9ae99

Browse files
committed
chore: drop dead estimateTokens and the unused ChatBar clear handle
estimateTokens had no callers. The imperative clear() had none either — it was the only caller left relying on clearAll's cleanupSources default, which is why abandoned sources looked like they were being swept when nothing invoked the path. setInput stays; it is used for prompt suggestions.
1 parent 4a43216 commit 2a9ae99

3 files changed

Lines changed: 1 addition & 15 deletions

File tree

components/chat-screen/ChatBar.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ interface Props {
5454
onSelectModel: () => void;
5555
onSelectPrompt: (prompt: string) => void;
5656
ref: Ref<{
57-
clear: () => void;
5857
setInput: (text: string) => void;
5958
}>;
6059
model: Model | undefined;
@@ -120,23 +119,14 @@ const ChatBar = ({
120119
useImperativeHandle(
121120
ref,
122121
() => ({
123-
clear: () => {
124-
setUserInput('');
125-
clearAll({ cleanupSources: true });
126-
extraContentPadding.set(0);
127-
if (Platform.OS === 'ios') {
128-
textInputRef.current?.setNativeProps({ text: ' ' });
129-
textInputRef.current?.setNativeProps({ text: '' });
130-
}
131-
},
132122
setInput: (text: string) => {
133123
setUserInput(text);
134124
if (Platform.OS === 'ios') {
135125
setIosInputKey((k) => k + 1);
136126
}
137127
},
138128
}),
139-
[clearAll, extraContentPadding]
129+
[]
140130
);
141131

142132
const handleBarLayoutForPadding = useCallback(

components/chat-screen/ChatScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default function ChatScreen({
6464
openModelSheetRef,
6565
}: Props) {
6666
const inputRef = useRef<{
67-
clear: () => void;
6867
setInput: (text: string) => void;
6968
}>(null);
7069
const messagesRef = useRef<MessagesHandle>(null);

constants/context-window.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ export const getContextWindowTokens = (model: Model): number =>
2222
(model.family ? CONTEXT_WINDOW_TOKENS_BY_FAMILY[model.family] : undefined) ??
2323
DEFAULT_CONTEXT_WINDOW_TOKENS;
2424

25-
export const estimateTokens = (text: string): number =>
26-
Math.ceil(text.length / CHARS_PER_TOKEN);
27-
2825
export const getPromptCharBudget = (model: Model): number => {
2926
const promptTokenBudget = Math.max(
3027
0,

0 commit comments

Comments
 (0)