This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-15 23:27:58 -04:00
1 parent ee000c503c
commit f67252b5e8
3 files changed
+40 -20

No files matched your search

+32 -12
View File
@@ -348,9 +348,14 @@ async def get_note_chat_by_id(
changed = True changed = True
system = ( system = (
f'Note id: {note.id}. ' f'CONTEXT:
'Use view_note before reading or editing. ' Current note id: {note.id}
'Use replace_note_content with content for whole-note updates or operations for selected/range updates.' '
'This chat is attached to the current note.
'
'For edit requests like make this concise, rewrite, enhance, shorten, or update: call view_note then replace_note_content.
'
'Do not say an edit is done unless replace_note_content succeeds.'
) )
if params.get('system') != system: if params.get('system') != system:
params['system'] = system params['system'] = system
@@ -378,9 +383,14 @@ async def get_note_chat_by_id(
'models': [''], 'models': [''],
'params': { 'params': {
'system': ( 'system': (
f'Note id: {note.id}. ' f'CONTEXT:
'Use view_note before reading or editing. ' Current note id: {note.id}
'Use replace_note_content with content for whole-note updates or operations for selected/range updates.' '
'This chat is attached to the current note.
'
'For edit requests like make this concise, rewrite, enhance, shorten, or update: call view_note then replace_note_content.
'
'Do not say an edit is done unless replace_note_content succeeds.'
) )
}, },
'history': {'messages': {}, 'currentId': None}, 'history': {'messages': {}, 'currentId': None},
@@ -441,9 +451,14 @@ async def get_note_chats_by_id(
changed = True changed = True
system = ( system = (
f'Note id: {note.id}. ' f'CONTEXT:
'Use view_note before reading or editing. ' Current note id: {note.id}
'Use replace_note_content with content for whole-note updates or operations for selected/range updates.' '
'This chat is attached to the current note.
'
'For edit requests like make this concise, rewrite, enhance, shorten, or update: call view_note then replace_note_content.
'
'Do not say an edit is done unless replace_note_content succeeds.'
) )
if params.get('system') != system: if params.get('system') != system:
params['system'] = system params['system'] = system
@@ -503,9 +518,14 @@ async def create_note_chat_by_id(
'models': [''], 'models': [''],
'params': { 'params': {
'system': ( 'system': (
f'Note id: {note.id}. ' f'CONTEXT:
'Use view_note before reading or editing. ' Current note id: {note.id}
'Use replace_note_content with content for whole-note updates or operations for selected/range updates.' '
'This chat is attached to the current note.
'
'For edit requests like make this concise, rewrite, enhance, shorten, or update: call view_note then replace_note_content.
'
'Do not say an edit is done unless replace_note_content succeeds.'
) )
}, },
'history': {'messages': {}, 'currentId': None}, 'history': {'messages': {}, 'currentId': None},
+7 -6
View File
@@ -368,9 +368,9 @@
let chatFiles = []; let chatFiles = [];
let files = []; let files = [];
let params = {}; let params = {};
let appliedInitialFilesKey = ''; let attachedFilesKey = '';
let loadedChatIdProp = ''; let loadedChatIdProp = '';
let loadedEmbeddedDraftKey = ''; let currentDraftKey = '';
const mergeFiles = (current, incoming) => { const mergeFiles = (current, incoming) => {
const seen = new Set(); const seen = new Set();
@@ -387,11 +387,11 @@
const key = JSON.stringify( const key = JSON.stringify(
initialFiles.map((file) => `${file?.type ?? ''}:${file?.id ?? file?.url ?? file?.name ?? ''}`) initialFiles.map((file) => `${file?.type ?? ''}:${file?.id ?? file?.url ?? file?.name ?? ''}`)
); );
if (key === appliedInitialFilesKey) return; if (key === attachedFilesKey) return;
files = mergeFiles(files, initialFiles); files = mergeFiles(files, initialFiles);
chatFiles = mergeFiles(chatFiles, initialFiles); chatFiles = mergeFiles(chatFiles, initialFiles);
appliedInitialFilesKey = key; attachedFilesKey = key;
}; };
const withSelectedText = (text: string) => const withSelectedText = (text: string) =>
embedded && selectedText?.trim() embedded && selectedText?.trim()
@@ -419,9 +419,9 @@
navigateHandler(); navigateHandler();
} }
$: if (embedded && embeddedDraftKey && embeddedDraftKey !== loadedEmbeddedDraftKey) { $: if (embedded && embeddedDraftKey && embeddedDraftKey !== currentDraftKey) {
noteChatDebug('embedded draft requested', { embeddedDraftKey }); noteChatDebug('embedded draft requested', { embeddedDraftKey });
loadedEmbeddedDraftKey = embeddedDraftKey; currentDraftKey = embeddedDraftKey;
initEmbeddedDraft(); initEmbeddedDraft();
} }
@@ -2727,6 +2727,7 @@
delete params.note_id; delete params.note_id;
chatFiles = mergeFiles(chatFiles, createdChat?.chat?.files ?? []); chatFiles = mergeFiles(chatFiles, createdChat?.chat?.files ?? []);
applyInitialFiles(); applyInitialFiles();
await onSelectEmbeddedChat?.(_chatId);
} else if ($temporaryChatEnabled) { } else if ($temporaryChatEnabled) {
_chatId = `local:${$socket?.id}`; _chatId = `local:${$socket?.id}`;
await chatId.set(_chatId); await chatId.set(_chatId);
+1 -2
View File
@@ -712,8 +712,6 @@ ${content}
: null; : null;
if (chat?.id) { if (chat?.id) {
noteChatId = chat.id;
noteChatDraftKey = '';
noteChats = chats ?? [chat, ...noteChats.filter((item) => item.id !== chat.id)]; noteChats = chats ?? [chat, ...noteChats.filter((item) => item.id !== chat.id)];
showNoteChat = true; showNoteChat = true;
} }
@@ -1440,6 +1438,7 @@ ${content}
onSelectEmbeddedChat={(chatId) => { onSelectEmbeddedChat={(chatId) => {
if (!chatId || chatId === noteChatId) return; if (!chatId || chatId === noteChatId) return;
noteChatId = chatId; noteChatId = chatId;
noteChatDraftKey = '';
}} }}
onDeleteEmbeddedChat={deleteNoteChat} onDeleteEmbeddedChat={deleteNoteChat}
onEmbeddedChatTitle={(chatId, title) => { onEmbeddedChatTitle={(chatId, title) => {