Default to read currently open file when chat with Khoj from Obsidian

Vault is already indexed, this should ease engaging with current
context more easily.
This commit is contained in:
Debanjum
2025-06-01 16:56:19 -07:00
parent 3fb8f77cd5
commit 759ffc46b0

View File

@@ -78,7 +78,7 @@ export class KhojChatView extends KhojPaneView {
chatMessageState: ChatMessageState; chatMessageState: ChatMessageState;
private agents: Agent[] = []; private agents: Agent[] = [];
private currentAgent: string | null = null; private currentAgent: string | null = null;
private fileAccessMode: 'none' | 'read' | 'write' = 'none'; // Track the current file access mode private fileAccessMode: 'none' | 'read' | 'write' = 'read'; // Track the current file access mode
// TODO: Only show modes available on server and to current agent // TODO: Only show modes available on server and to current agent
private chatModes: ChatMode[] = [ private chatModes: ChatMode[] = [
{ value: "default", label: "Default", iconName: "target", command: "/default" }, { value: "default", label: "Default", iconName: "target", command: "/default" },
@@ -272,10 +272,10 @@ export class KhojChatView extends KhojPaneView {
text: "File Access", text: "File Access",
attr: { attr: {
class: "khoj-input-row-button clickable-icon", class: "khoj-input-row-button clickable-icon",
title: "Toggle file access mode (No Access)", title: "Toggle file access mode (Read Only)",
}, },
}); });
setIcon(fileAccessButton, "file-x"); setIcon(fileAccessButton, "file-search");
fileAccessButton.addEventListener('click', () => { fileAccessButton.addEventListener('click', () => {
// Cycle through modes: none -> read -> write -> none // Cycle through modes: none -> read -> write -> none
switch (this.fileAccessMode) { switch (this.fileAccessMode) {