fix(ai): lisibilite des modeles + contexte @ en mode General (BUG-010, BUG-011)
BUG-011: popover des modeles aligne a droite (right:0), largeur 340px bornee, noms sur plusieurs lignes + title. BUG-010: la selection @ capture le vault renvoye par tree-search et _contextVault() le propage aux requetes /context et /chat, corrigeant le contexte ad-hoc en mode General.
This commit is contained in:
+26
-13
@@ -321,6 +321,18 @@ class BooksLM {
|
||||
return state.currentVault || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vault used for context/chat requests. Falls back to the vault of the first
|
||||
* ad-hoc `@` entry: in General mode there is no base vault, but the selected
|
||||
* files/directories still belong to a vault that must be sent to the server.
|
||||
*/
|
||||
_contextVault() {
|
||||
if (this._vault) return this._vault;
|
||||
const entry = this._adhocFiles[0] || this._adhocDirs[0] || this._images[0];
|
||||
if (entry && entry.vault) return entry.vault;
|
||||
return this._resolveVault();
|
||||
}
|
||||
|
||||
/** Open a file mentioned in an assistant answer in the main viewer. */
|
||||
async _openFileLink(path) {
|
||||
const vault = this._resolveVault();
|
||||
@@ -378,7 +390,7 @@ class BooksLM {
|
||||
|
||||
const payload = {
|
||||
mode: this._mode,
|
||||
vault: this._vault || this._resolveVault(),
|
||||
vault: this._contextVault(),
|
||||
directory: this._directory,
|
||||
context_files: this._mode === MODE.DOCUMENTS ? this._documents.map((d) => d.path) : [],
|
||||
extra_files: this._adhocFiles.map((f) => f.path),
|
||||
@@ -667,17 +679,17 @@ class BooksLM {
|
||||
return chip;
|
||||
}
|
||||
|
||||
_addAdhocFile(path) {
|
||||
_addAdhocFile(path, vault) {
|
||||
if (!path || this._adhocFiles.some((f) => f.path === path)) return;
|
||||
this._adhocFiles.push({ path });
|
||||
this._adhocFiles.push({ path, vault: vault || null });
|
||||
this._renderAttachments();
|
||||
this._loadContext();
|
||||
}
|
||||
|
||||
_addAdhocDir(path) {
|
||||
_addAdhocDir(path, vault) {
|
||||
const clean = path.replace(/\/+$/, '');
|
||||
if (!clean || this._adhocDirs.some((d) => d.path === clean)) return;
|
||||
this._adhocDirs.push({ path: clean });
|
||||
this._adhocDirs.push({ path: clean, vault: vault || null });
|
||||
this._renderAttachments();
|
||||
this._loadContext();
|
||||
}
|
||||
@@ -808,7 +820,7 @@ class BooksLM {
|
||||
async _showMentionMenu(query) {
|
||||
if (!this._panel) return;
|
||||
const seq = ++this._menuSeq;
|
||||
const vault = this._resolveVault();
|
||||
const vault = this._contextVault();
|
||||
if (!vault && !query) {
|
||||
// Nothing to list without a vault; a typed query can still search all.
|
||||
this._hideMenus();
|
||||
@@ -833,7 +845,7 @@ class BooksLM {
|
||||
const path = r.path || r;
|
||||
const rawType = r.type || (this._classifyPath(path) === 'dir' ? 'dir' : 'file');
|
||||
const type = rawType === 'directory' ? 'dir' : rawType;
|
||||
return { id: path, label: path, type };
|
||||
return { id: path, label: path, type, vault: r.vault || null };
|
||||
});
|
||||
this._renderMenu('mention', items, (item) => this._selectMention(item));
|
||||
} catch (e) {
|
||||
@@ -851,18 +863,19 @@ class BooksLM {
|
||||
textarea.focus();
|
||||
}
|
||||
const path = item.id;
|
||||
const vault = item.vault || this._resolveVault();
|
||||
if (IMAGE_EXT_RE.test(path)) {
|
||||
this._addImagePath(path);
|
||||
this._addImagePath(path, vault);
|
||||
} else if (item.type === 'dir' || this._classifyPath(path) === 'dir') {
|
||||
this._addAdhocDir(path);
|
||||
this._addAdhocDir(path, vault);
|
||||
} else {
|
||||
this._addAdhocFile(path);
|
||||
this._addAdhocFile(path, vault);
|
||||
}
|
||||
}
|
||||
|
||||
_addImagePath(path) {
|
||||
_addImagePath(path, vault) {
|
||||
if (!path || this._images.some((img) => img.path === path)) return;
|
||||
this._images.push({ path, name: path.split('/').pop() });
|
||||
this._images.push({ path, name: path.split('/').pop(), vault: vault || null });
|
||||
this._renderAttachments();
|
||||
}
|
||||
|
||||
@@ -1593,7 +1606,7 @@ class BooksLM {
|
||||
|
||||
const payload = {
|
||||
mode: this._mode,
|
||||
vault: this._vault || this._resolveVault(),
|
||||
vault: this._contextVault(),
|
||||
directory: this._directory,
|
||||
context_files: this._mode === MODE.DOCUMENTS ? this._documents.map((d) => d.path) : [],
|
||||
extra_files: this._adhocFiles.map((f) => f.path),
|
||||
|
||||
Reference in New Issue
Block a user