Skip to content

Commit cc0a9ad

Browse files
committed
fix #6016 -- do not mangle draft messages based on hashtags
1 parent a599552 commit cc0a9ad

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

src/packages/frontend/chat/actions.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
toOllamaModel,
4040
type LanguageModel,
4141
} from "@cocalc/util/db-schema/llm-utils";
42-
import { cmp, isValidUUID, parse_hashtags, uuid } from "@cocalc/util/misc";
42+
import { cmp, isValidUUID, uuid } from "@cocalc/util/misc";
4343
import { reuseInFlight } from "@cocalc/util/reuse-in-flight";
4444
import { getSortedDates, getUserName } from "./chat-log";
4545
import { message_to_markdown } from "./message";
@@ -51,7 +51,6 @@ import {
5151
Feedback,
5252
MessageHistory,
5353
} from "./types";
54-
import { getSelectedHashtagsSearch } from "./utils";
5554
import { history_path } from "@cocalc/util/misc";
5655

5756
const MAX_CHATSTREAM = 10;
@@ -302,7 +301,6 @@ export class ChatActions extends Actions<ChatState> {
302301
search: "",
303302
});
304303
}
305-
this.ensureDraftStartsWithHashtags(false);
306304

307305
if (this.store != null) {
308306
const project_id = this.store?.get("project_id");
@@ -621,38 +619,6 @@ export class ChatActions extends Actions<ChatState> {
621619
? selectedHashtags.delete(tag)
622620
: selectedHashtags.set(tag, state);
623621
this.setState({ selectedHashtags });
624-
this.ensureDraftStartsWithHashtags(true);
625-
}
626-
627-
private ensureDraftStartsWithHashtags(commit: boolean = false): void {
628-
if (this.syncdb == null || this.store == null) return;
629-
// set draft input to match selected hashtags, if any.
630-
const hashtags = this.store.get("selectedHashtags");
631-
if (hashtags == null) return;
632-
const { selectedHashtagsSearch } = getSelectedHashtagsSearch(hashtags);
633-
let input = this.store.get("input");
634-
const prefix = selectedHashtagsSearch.trim() + " ";
635-
if (input.startsWith(prefix)) {
636-
return;
637-
}
638-
const v = parse_hashtags(input);
639-
if (v.length > 0) {
640-
input = input.slice(v[v.length - 1][1]);
641-
}
642-
643-
input = prefix + input;
644-
this.setState({ input });
645-
const sender_id = this.redux.getStore("account").get_account_id();
646-
this.syncdb.set({
647-
event: "draft",
648-
active: Date.now(),
649-
sender_id,
650-
input,
651-
date: 0,
652-
});
653-
if (commit) {
654-
this.syncdb.commit();
655-
}
656622
}
657623

658624
public help() {

0 commit comments

Comments
 (0)