mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
feat(miyo): add remote vault folder path override for remote servers (#2334)
When using a Miyo remote server, the vault may be mounted at a different path on the remote machine. This adds an optional "Remote Vault Folder" setting that overrides the folder path sent to Miyo when a custom server URL is configured. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
47e61259d2
commit
81fd4e5157
5 changed files with 27 additions and 7 deletions
|
|
@ -36,12 +36,21 @@ export function shouldUseMiyo(settings: CopilotSettings): boolean {
|
|||
}
|
||||
|
||||
/**
|
||||
* Resolve the current vault folder path sent to Miyo as `folder_path`.
|
||||
* Resolve the folder path sent to Miyo as `folder_path`.
|
||||
*
|
||||
* When a remote server URL is configured and the user has set a remote vault folder,
|
||||
* that override is used — the remote machine's folder path may differ from the local
|
||||
* vault path. Falls back to the local vault filesystem path, then vault name.
|
||||
*
|
||||
* @param app - Obsidian application instance.
|
||||
* @returns Current vault filesystem path when available, otherwise vault name.
|
||||
* @param settings - Current Copilot settings.
|
||||
* @returns Remote vault folder override when applicable, otherwise local vault path.
|
||||
*/
|
||||
export function getMiyoFolderPath(app: App): string {
|
||||
export function getMiyoFolderPath(app: App, settings: CopilotSettings): string {
|
||||
const remoteVaultFolder = (settings.miyoRemoteVaultPath || "").trim();
|
||||
if (remoteVaultFolder && getMiyoCustomUrl(settings)) {
|
||||
return remoteVaultFolder;
|
||||
}
|
||||
const vaultPath = getVaultBasePath(app);
|
||||
if (vaultPath) {
|
||||
return vaultPath;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ async function calculateSimilarityScoreFromMiyo(filePath: string): Promise<Map<s
|
|||
const settings = getSettings();
|
||||
const miyoClient = new MiyoClient();
|
||||
const baseUrl = await miyoClient.resolveBaseUrl(getMiyoCustomUrl(settings));
|
||||
const folderPath = getMiyoFolderPath(app);
|
||||
const folderPath = getMiyoFolderPath(app, settings);
|
||||
const response = await miyoClient.searchRelated(baseUrl, getMiyoAbsolutePath(app, filePath), {
|
||||
folderPath,
|
||||
limit: MAX_K,
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ export class MiyoIndexBackend implements SemanticIndexBackend {
|
|||
* @returns Folder path string.
|
||||
*/
|
||||
private getFolderPath(): string {
|
||||
return getMiyoFolderPath(this.app);
|
||||
return getMiyoFolderPath(this.app, getSettings());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ export class MiyoSemanticRetriever extends BaseRetriever {
|
|||
}
|
||||
const response = await this.client.search(
|
||||
baseUrl,
|
||||
getMiyoFolderPath(this.app),
|
||||
getMiyoFolderPath(this.app, getSettings()),
|
||||
query,
|
||||
limit,
|
||||
filters
|
||||
|
|
|
|||
|
|
@ -227,6 +227,17 @@ export const CopilotPlusSettings: React.FC = () => {
|
|||
onChange={(value) => updateSetting("miyoServerUrl", value)}
|
||||
/>
|
||||
|
||||
{(settings.miyoServerUrl || "").trim() && (
|
||||
<SettingItem
|
||||
type="text"
|
||||
title="Remote Vault Folder (Optional)"
|
||||
description="The folder path on the remote machine that Miyo should search. Leave blank to use the local vault path (only works if the remote vault is mounted at the same path)."
|
||||
value={settings.miyoRemoteVaultPath || ""}
|
||||
onChange={(value) => updateSetting("miyoRemoteVaultPath", value)}
|
||||
placeholder="e.g. /Users/you/Documents/vault"
|
||||
/>
|
||||
)}
|
||||
|
||||
<SettingItem
|
||||
type="switch"
|
||||
title="Enable Miyo"
|
||||
|
|
@ -240,7 +251,7 @@ export const CopilotPlusSettings: React.FC = () => {
|
|||
<div className="tw-text-xs tw-text-muted">
|
||||
Folder path sent to Miyo:{" "}
|
||||
<span className="tw-font-medium tw-text-normal">
|
||||
{getMiyoFolderPath(app)}
|
||||
{getMiyoFolderPath(app, settings)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in a new issue