feat: add desktop LAN access setting
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user