feat: add desktop LAN access setting

This commit is contained in:
Bohdan Triapitsyn
2026-04-17 18:05:53 +03:00
parent 304b14b4b1
commit c494d9f8b9
7 changed files with 281 additions and 32 deletions
+16
View File
@@ -50,6 +50,7 @@ export type DesktopSettings = {
homeDirectory?: string;
// Optional absolute path to `opencode` binary.
opencodeBinary?: string;
desktopLanAccessEnabled?: boolean;
projects?: ProjectEntry[];
activeProjectId?: string;
approvedDirectories?: string[];
@@ -479,6 +480,21 @@ export const restartDesktopApp = async (): Promise<boolean> => {
}
};
export const getDesktopLanAddress = async (): Promise<string | null> => {
if (!isTauriShell() || !isDesktopLocalOriginActive()) {
return null;
}
try {
const tauri = (window as unknown as { __TAURI__?: TauriGlobal }).__TAURI__;
const result = await tauri?.core?.invoke?.('desktop_get_lan_address');
return typeof result === 'string' && result.trim().length > 0 ? result.trim() : null;
} catch (error) {
console.warn('Failed to get desktop LAN address (tauri)', error);
return null;
}
};
export const openDesktopPath = async (path: string, app?: string | null): Promise<boolean> => {
if (!isTauriShell() || !isDesktopLocalOriginActive()) {
return false;
+3
View File
@@ -519,6 +519,9 @@ const sanitizeWebSettings = (payload: unknown): DesktopSettings | null => {
const trimmed = candidate.opencodeBinary.trim();
result.opencodeBinary = trimmed.length > 0 ? trimmed : undefined;
}
if (typeof candidate.desktopLanAccessEnabled === 'boolean') {
result.desktopLanAccessEnabled = candidate.desktopLanAccessEnabled;
}
const projects = sanitizeProjects(candidate.projects);
if (projects) {