Skip to content

Commit daba41c

Browse files
committed
chat: modernizing names of actions
1 parent 0bc44b2 commit daba41c

File tree

8 files changed

+48
-48
lines changed

8 files changed

+48
-48
lines changed

src/packages/frontend/chat/actions.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class ChatActions extends Actions<ChatState> {
9595
initFromSyncDB({ syncdb: this.syncdb, store: this.store });
9696
};
9797

98-
syncdb_change = (changes): void => {
98+
syncdbChange = (changes): void => {
9999
if (this.syncdb == null) {
100100
return;
101101
}
@@ -151,7 +151,7 @@ export class ChatActions extends Actions<ChatState> {
151151
// chatgpt, which is currently managed by the frontend
152152
// (not the project). Also the async doesn't finish until
153153
// chatgpt is totally done.
154-
send_chat = ({
154+
sendChat = ({
155155
input,
156156
sender_id = this.redux.getStore("account").get_account_id(),
157157
reply_to,
@@ -165,7 +165,7 @@ export class ChatActions extends Actions<ChatState> {
165165
noNotification?: boolean;
166166
}): string => {
167167
if (this.syncdb == null || this.store == null) {
168-
console.warn("attempt to send_chat before chat actions initialized");
168+
console.warn("attempt to sendChat before chat actions initialized");
169169
// WARNING: give an error or try again later?
170170
return "";
171171
}
@@ -195,7 +195,7 @@ export class ChatActions extends Actions<ChatState> {
195195
};
196196
this.syncdb.set(message);
197197
if (!reply_to) {
198-
this.delete_draft(0);
198+
this.deleteDraft(0);
199199
// NOTE: we also clear search, since it's confusing to send a message and not
200200
// even see it (if it doesn't match search). We do NOT clear the hashtags though,
201201
// since by default the message you are sending has those tags.
@@ -255,7 +255,7 @@ export class ChatActions extends Actions<ChatState> {
255255
return time_stamp_str;
256256
};
257257

258-
set_editing = (message: ChatMessageTyped, is_editing: boolean) => {
258+
setEditing = (message: ChatMessageTyped, is_editing: boolean) => {
259259
if (this.syncdb == null) {
260260
// WARNING: give an error or try again later?
261261
return;
@@ -281,7 +281,7 @@ export class ChatActions extends Actions<ChatState> {
281281
// NOTE: this is inefficient; it assumes
282282
// the number of edits is small, which is reasonable -- nobody makes hundreds of distinct
283283
// edits of a single message.
284-
send_edit = (message: ChatMessageTyped, content: string): void => {
284+
sendEdit = (message: ChatMessageTyped, content: string): void => {
285285
if (this.syncdb == null) {
286286
// WARNING: give an error or try again later?
287287
return;
@@ -302,11 +302,11 @@ export class ChatActions extends Actions<ChatState> {
302302
editing: message.get("editing").set(author_id, null).toJS(),
303303
date: message.get("date").toISOString(),
304304
});
305-
this.delete_draft(message.get("date")?.valueOf());
305+
this.deleteDraft(message.get("date")?.valueOf());
306306
this.save_to_disk();
307307
};
308308

309-
save_history = (
309+
saveHistory = (
310310
message: ChatMessage,
311311
content: string,
312312
author_id: string,
@@ -334,7 +334,7 @@ export class ChatActions extends Actions<ChatState> {
334334
return { date, prevHistory };
335335
};
336336

337-
send_reply = ({
337+
sendReply = ({
338338
message,
339339
reply,
340340
from,
@@ -362,18 +362,18 @@ export class ChatActions extends Actions<ChatState> {
362362
date: new Date(message.date).valueOf(),
363363
messages: store.get("messages"),
364364
});
365-
const time_stamp_str = this.send_chat({
365+
const time_stamp_str = this.sendChat({
366366
input: reply,
367367
sender_id: from ?? this.redux.getStore("account").get_account_id(),
368368
reply_to: new Date(reply_to_value),
369369
noNotification,
370370
});
371371
// negative date of reply_to root is used for replies.
372-
this.delete_draft(-reply_to_value);
372+
this.deleteDraft(-reply_to_value);
373373
return time_stamp_str;
374374
};
375375

376-
delete_draft = (
376+
deleteDraft = (
377377
date: number,
378378
commit: boolean = true,
379379
sender_id: string | undefined = undefined,
@@ -401,11 +401,11 @@ export class ChatActions extends Actions<ChatState> {
401401
}
402402
};
403403

404-
set_input = (input: string): void => {
404+
setInput = (input: string): void => {
405405
this.setState({ input });
406406
};
407407

408-
private _llm_estimate_cost = async (
408+
private _llmEstimateCost = async (
409409
input: string,
410410
type: "room" | "reply",
411411
message?: ChatMessage,
@@ -455,13 +455,13 @@ export class ChatActions extends Actions<ChatState> {
455455
}
456456
};
457457

458-
llm_estimate_cost: typeof this._llm_estimate_cost = debounce(
459-
reuseInFlight(this._llm_estimate_cost),
458+
llmEstimateCost: typeof this._llmEstimateCost = debounce(
459+
reuseInFlight(this._llmEstimateCost),
460460
1000,
461461
{ leading: true, trailing: true },
462462
);
463463

464-
set_is_preview = (is_preview): void => {
464+
setIsPreview = (is_preview): void => {
465465
this.setState({ is_preview });
466466
};
467467

@@ -673,9 +673,9 @@ export class ChatActions extends Actions<ChatState> {
673673
// prevHistory: in case of regenerate, it's the history *before* we added the "Thinking..." message (which we ignore)
674674
const { date, prevHistory = [] } =
675675
tag === "regenerate"
676-
? this.save_history(message, thinking, sender_id, true)
676+
? this.saveHistory(message, thinking, sender_id, true)
677677
: {
678-
date: this.send_reply({
678+
date: this.sendReply({
679679
message,
680680
reply: thinking,
681681
from: sender_id,
@@ -982,7 +982,7 @@ export class ChatActions extends Actions<ChatState> {
982982
const tokens = numTokensUpperBound(prompt, getMaxTokens(model));
983983
return { prompt, tokens, truncated: txtFull != txt };
984984
} else {
985-
this.send_chat({
985+
this.sendChat({
986986
input: prompt,
987987
tag: `chat:summarize`,
988988
noNotification: true,

src/packages/frontend/chat/chatroom.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function ChatRoom({
131131
cursor: "pointer",
132132
fontSize: "13pt",
133133
}}
134-
onClick={() => actions.set_is_preview(false)}
134+
onClick={() => actions.setIsPreview(false)}
135135
>
136136
<Icon name="times" />
137137
</div>
@@ -185,7 +185,7 @@ export function ChatRoom({
185185
<VideoChatButton
186186
project_id={project_id}
187187
path={path}
188-
sendChat={(value) => actions.send_chat({ input: value })}
188+
sendChat={(value) => actions.sendChat({ input: value })}
189189
/>
190190
);
191191
}
@@ -308,7 +308,7 @@ export function ChatRoom({
308308
function on_send(): void {
309309
const input = submitMentionsRef.current?.();
310310
scrollToBottomRef.current?.(true);
311-
actions.send_chat({ input });
311+
actions.sendChat({ input });
312312
setTimeout(() => {
313313
scrollToBottomRef.current?.(true);
314314
}, 100);
@@ -344,11 +344,11 @@ export function ChatRoom({
344344
on_send={on_send}
345345
height={INPUT_HEIGHT}
346346
onChange={(value) => {
347-
actions.set_input(value);
347+
actions.setInput(value);
348348
// submitMentionsRef will not actually submit mentions; we're only interested in the reply value
349349
const reply =
350350
submitMentionsRef.current?.(undefined, true) ?? value;
351-
actions?.llm_estimate_cost(reply, "room");
351+
actions?.llmEstimateCost(reply, "room");
352352
}}
353353
submitMentionsRef={submitMentionsRef}
354354
syncdb={actions.syncdb}
@@ -398,7 +398,7 @@ export function ChatRoom({
398398
</Tooltip>
399399
<div style={{ height: "5px" }} />
400400
<Button
401-
onClick={() => actions.set_is_preview(true)}
401+
onClick={() => actions.setIsPreview(true)}
402402
style={{ height: "47.5px" }}
403403
disabled={is_preview}
404404
>

src/packages/frontend/chat/message.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export default function Message(props: Readonly<Props>) {
338338
// no editing functionality or not in a project with a path.
339339
return;
340340
}
341-
props.actions.set_editing(message, true);
341+
props.actions.setEditing(message, true);
342342
setAutoFocusEdit(true);
343343
props.scroll_into_view?.();
344344
}
@@ -503,7 +503,7 @@ export default function Message(props: Readonly<Props>) {
503503
}}
504504
type="text"
505505
size="small"
506-
onClick={() => props.actions?.set_editing(message, true)}
506+
onClick={() => props.actions?.setEditing(message, true)}
507507
>
508508
<Icon name="pencil" /> Edit
509509
</Button>
@@ -518,9 +518,9 @@ export default function Message(props: Readonly<Props>) {
518518
title="Delete this message"
519519
description="Are you sure you want to delete this message?"
520520
onConfirm={() => {
521-
props.actions?.set_editing(message, true);
521+
props.actions?.setEditing(message, true);
522522
setTimeout(
523-
() => props.actions?.send_edit(message, ""),
523+
() => props.actions?.sendEdit(message, ""),
524524
1,
525525
);
526526
}}
@@ -629,17 +629,17 @@ export default function Message(props: Readonly<Props>) {
629629
const value = newest_content(message);
630630
if (mesg !== value) {
631631
set_edited_message(mesg);
632-
props.actions.send_edit(message, mesg);
632+
props.actions.sendEdit(message, mesg);
633633
} else {
634-
props.actions.set_editing(message, false);
634+
props.actions.setEditing(message, false);
635635
}
636636
}
637637

638638
function on_cancel(): void {
639639
set_edited_message(newest_content(message));
640640
if (props.actions == null) return;
641-
props.actions.set_editing(message, false);
642-
props.actions.delete_draft(date);
641+
props.actions.setEditing(message, false);
642+
props.actions.deleteDraft(date);
643643
}
644644

645645
function renderEditMessage() {
@@ -672,8 +672,8 @@ export default function Message(props: Readonly<Props>) {
672672
<Button
673673
style={{ marginRight: "5px" }}
674674
onClick={() => {
675-
props.actions?.set_editing(message, false);
676-
props.actions?.delete_draft(date);
675+
props.actions?.setEditing(message, false);
676+
props.actions?.deleteDraft(date);
677677
}}
678678
>
679679
Cancel
@@ -692,7 +692,7 @@ export default function Message(props: Readonly<Props>) {
692692
if (!reply) {
693693
reply = replyMentionsRef.current?.() ?? replyMessageRef.current;
694694
}
695-
props.actions.send_reply({ message: message.toJS(), reply });
695+
props.actions.sendReply({ message: message.toJS(), reply });
696696
props.actions.scrollToBottom(props.index);
697697
}
698698

@@ -727,7 +727,7 @@ export default function Message(props: Readonly<Props>) {
727727
replyMessageRef.current = value;
728728
// replyMentionsRef does not submit mentions, only gives us the value
729729
const reply = replyMentionsRef.current?.(undefined, true) ?? value;
730-
props.actions?.llm_estimate_cost(reply, "reply", message.toJS());
730+
props.actions?.llmEstimateCost(reply, "reply", message.toJS());
731731
}}
732732
placeholder={"Reply to the above message..."}
733733
/>
@@ -736,7 +736,7 @@ export default function Message(props: Readonly<Props>) {
736736
style={{ marginRight: "5px" }}
737737
onClick={() => {
738738
setReplying(false);
739-
props.actions?.delete_draft(replyDate);
739+
props.actions?.deleteDraft(replyDate);
740740
}}
741741
>
742742
Cancel

src/packages/frontend/chat/register.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function initChat(project_id: string, path: string): string {
4343
syncdb.once("ready", () => {
4444
actions.set_syncdb(syncdb, store);
4545
actions.init_from_syncdb();
46-
syncdb.on("change", actions.syncdb_change.bind(actions));
46+
syncdb.on("change", actions.syncdbChange);
4747
syncdb.on("has-uncommitted-changes", (val) =>
4848
actions.setState({ has_uncommitted_changes: val }),
4949
);

src/packages/frontend/chat/side-chat.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export default function SideChat({ project_id, path, style, fontSize }: Props) {
5959
const sendChat = useCallback(
6060
(options?) => {
6161
const input = submitMentionsRef.current?.();
62-
actions.send_chat({ input, ...options });
63-
actions.delete_draft(0);
62+
actions.sendChat({ input, ...options });
63+
actions.deleteDraft(0);
6464
scrollToBottomRef.current?.(true);
6565
setTimeout(() => {
6666
scrollToBottomRef.current?.(true);
@@ -121,7 +121,7 @@ export default function SideChat({ project_id, path, style, fontSize }: Props) {
121121
project_id,
122122
path,
123123
) as ChatActions;
124-
actions.send_chat({ input: value });
124+
actions.sendChat({ input: value });
125125
}}
126126
/>
127127
<Tooltip title="Show TimeTravel change history of this side chat.">
@@ -221,10 +221,10 @@ export default function SideChat({ project_id, path, style, fontSize }: Props) {
221221
style={{ height: INPUT_HEIGHT }}
222222
height={INPUT_HEIGHT}
223223
onChange={(value) => {
224-
actions.set_input(value);
224+
actions.setInput(value);
225225
// submitMentionsRef processes the reply, but does not actually send the mentions
226226
const reply = submitMentionsRef.current?.(undefined, true) ?? value;
227-
actions?.llm_estimate_cost(reply, "room");
227+
actions?.llmEstimateCost(reply, "room");
228228
}}
229229
submitMentionsRef={submitMentionsRef}
230230
syncdb={actions.syncdb}

src/packages/frontend/frame-editors/llm/create-chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default async function createChat({
3535
actions.path,
3636
);
3737

38-
await chatActions.send_chat({
38+
await chatActions.sendChat({
3939
input: message,
4040
tag: `${AI_ASSIST_TAG}-${tag ?? command}`,
4141
noNotification: true,

src/packages/frontend/frame-editors/llm/help-me-fix.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export async function getHelp({
211211
// scroll to bottom *after* the message gets sent.
212212
const actions = await getChatActions(redux, project_id, path);
213213
setTimeout(() => actions.scrollToBottom(), 100);
214-
await actions.send_chat({
214+
await actions.sendChat({
215215
input: message,
216216
tag: `help-me-fix${tag ? `:${tag}` : ""}`,
217217
noNotification: true,

src/packages/frontend/jupyter/llm/cell-tool.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export function LLMCellTool({ actions, id, style, llmTools }: Props) {
330330
// scroll to bottom *after* the message gets sent.
331331
const chatActions = await getChatActions(actions.redux, project_id, path);
332332
setTimeout(() => chatActions.scrollToBottom(), 100);
333-
chatActions.send_chat({
333+
chatActions.sendChat({
334334
input: message,
335335
tag: `jupyter-cell-llm:${mode}`,
336336
noNotification: true,

0 commit comments

Comments
 (0)