Add automatic folder creation for file operations and improve chat session handling
Implement `ensureFolderExists` in `ToolExecutor` to create parent directories when creating, moving, or renaming notes. Update `ChatView` to properly persist agent mode and derive session titles from the first user message. Fix error handling in tool execution to return structured failures instead of null, and include failure details in follow-up messages.
This commit is contained in:
@@ -234,6 +234,18 @@ describe('ChatView', () => {
|
||||
const messages = view.contentEl.querySelectorAll('.ollama-message');
|
||||
expect(messages.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should update the system prompt when mode selector changes', async () => {
|
||||
await view.render();
|
||||
const selector = view.contentEl.querySelector('.ollama-mode-selector') as HTMLSelectElement;
|
||||
selector.appendChild(new Option('Edit', 'edit'));
|
||||
selector.value = 'edit';
|
||||
selector.dispatchEvent(new Event('change'));
|
||||
|
||||
const systemPrompt = view['conversationStateManager'].getLongTermContext()[0].content;
|
||||
expect(view.getAgentMode()).toBe('edit');
|
||||
expect(systemPrompt).toContain('helps edit and manage notes');
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleUserInput', () => {
|
||||
@@ -600,6 +612,8 @@ describe('ChatView', () => {
|
||||
messages: [],
|
||||
tools: [],
|
||||
assistantMessageId,
|
||||
allToolCalls: [],
|
||||
assistantText: 'test',
|
||||
};
|
||||
|
||||
const followUpSpy = jest
|
||||
@@ -653,6 +667,8 @@ describe('ChatView', () => {
|
||||
messages: [],
|
||||
tools: [],
|
||||
assistantMessageId,
|
||||
allToolCalls: [],
|
||||
assistantText: 'Proposed actions...',
|
||||
};
|
||||
|
||||
view.cancelPendingActions();
|
||||
|
||||
Reference in New Issue
Block a user