[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled

This commit is contained in:
2026-09-13 18:24:01 +08:00
commit 3c72efcb7f
3255 changed files with 907009 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
import { localStorageAdapter } from '../persistence/localStorageAdapter';
import { STORAGE_KEY_AI_COMPOSER_MODEL_PREFS } from '../config/storageKeys';
import {
COMPOSER_PINNED_MODEL_LIMIT,
COMPOSER_RECENT_MODEL_LIMIT,
parseComposerModelPrefs,
toggleComposerPinnedPref,
upsertComposerPrefFront,
type ComposerModelPrefEntry,
type ComposerModelPrefs,
} from './composerPicker';
type PrefsByScope = Record<string, ComposerModelPrefs>;
function emptyPrefs(): ComposerModelPrefs {
return { recent: [], pinned: [] };
}
function readAllPrefs(): PrefsByScope {
try {
const raw = localStorageAdapter.read<PrefsByScope>(STORAGE_KEY_AI_COMPOSER_MODEL_PREFS);
if (!raw || typeof raw !== 'object') return {};
const next: PrefsByScope = {};
for (const [scope, value] of Object.entries(raw)) {
next[scope] = parseComposerModelPrefs(value);
}
return next;
} catch {
return {};
}
}
const prefsListeners = new Set<() => void>();
function notifyComposerModelPrefsChanged(): void {
for (const listener of prefsListeners) listener();
}
export function subscribeComposerModelPrefs(listener: () => void): () => void {
prefsListeners.add(listener);
return () => {
prefsListeners.delete(listener);
};
}
function writeAllPrefs(prefs: PrefsByScope): void {
try {
localStorageAdapter.write(STORAGE_KEY_AI_COMPOSER_MODEL_PREFS, prefs);
} catch {
// Tests and SSR have no storage. Recent/pinned stay in-memory only.
}
notifyComposerModelPrefsChanged();
}
export function readComposerModelPrefs(scope: string): ComposerModelPrefs {
return parseComposerModelPrefs(readAllPrefs()[scope] ?? emptyPrefs());
}
export function rememberComposerRecentModel(
scope: string,
entry: ComposerModelPrefEntry,
): ComposerModelPrefs {
const all = readAllPrefs();
const current = parseComposerModelPrefs(all[scope]);
const next: ComposerModelPrefs = {
...current,
recent: upsertComposerPrefFront(current.recent, entry, COMPOSER_RECENT_MODEL_LIMIT),
};
all[scope] = next;
writeAllPrefs(all);
return next;
}
export function toggleComposerPinnedModel(
scope: string,
entry: ComposerModelPrefEntry,
): ComposerModelPrefs {
const all = readAllPrefs();
const current = parseComposerModelPrefs(all[scope]);
const next: ComposerModelPrefs = {
...current,
pinned: toggleComposerPinnedPref(current.pinned, entry, COMPOSER_PINNED_MODEL_LIMIT),
};
all[scope] = next;
writeAllPrefs(all);
return next;
}