- Added agents overview documentation outlining the project structure and roles. - Implemented `useSessionState` for managing terminal sessions and workspaces. - Developed `useSettingsState` for handling user settings and theme management. - Created `useVaultState` for managing hosts, SSH keys, snippets, and custom groups. - Introduced domain logic for host normalization and sanitization. - Defined models for Host, SSHKey, Snippet, TerminalSession, and Workspace. - Implemented workspace management functions including creation, insertion, and pruning. - Established local storage adapter for persistent data management. - Integrated Gemini AI service for terminal simulation and command generation. - Developed sync service for backing up and restoring configuration to/from GitHub Gists.
27 lines
629 B
TypeScript
27 lines
629 B
TypeScript
const safeParse = <T>(value: string | null): T | null => {
|
|
if (!value) return null;
|
|
try {
|
|
return JSON.parse(value) as T;
|
|
} catch {
|
|
return null;
|
|
}
|
|
};
|
|
|
|
export const localStorageAdapter = {
|
|
read<T>(key: string): T | null {
|
|
return safeParse<T>(localStorage.getItem(key));
|
|
},
|
|
write<T>(key: string, value: T) {
|
|
localStorage.setItem(key, JSON.stringify(value));
|
|
},
|
|
readString(key: string): string | null {
|
|
return localStorage.getItem(key);
|
|
},
|
|
writeString(key: string, value: string) {
|
|
localStorage.setItem(key, value);
|
|
},
|
|
remove(key: string) {
|
|
localStorage.removeItem(key);
|
|
},
|
|
};
|