c8bc4a95a9
Workspace groups: named, foldable, ordered sidebar sections kept per account (agenthub.workspace.groups); a workspace joins one from its menu, a drop on the header, a drag under a row, or Alt+Up/Down past a group's edge; headers drag to reorder; a folded header shows its most urgent state; New workspace in this group; fold/unfold all. Inner repos: GET /api/lanes/:id/repos + ?repo= on git/fs routes; the Changes panel shows a parent folder's repos only when Settings -> Git -> Changes panel turns it on (agenthub.changes.innerRepos, off by default). Cost: the hook writer adds a session's sub-agent transcripts to its tokens and hours (server/lib/subagent-usage.js) — a sub-agent on the session's own model was never counted live (~8% of a week here); an imported session is re-raised on every pass, so a claude -p run first seen with an empty transcript no longer stays at $0 (~10%). A one-time raise-only catch-up (user_version 5) re-reads ~/.claude/projects. Also: omp install script may redirect to its exact install.redirect URL (#85, repo-links test exempts it), native paste in the terminal.
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
/**
|
|
* @file innerReposPref — whether the Changes panel lists the git repositories
|
|
* INSIDE a workspace folder (a parent folder of several repos, one section
|
|
* each via `GET /api/lanes/:id/repos`) or only the folder's own git. Off by
|
|
* default ("own"): the panel neither walks the folder nor shows them until
|
|
* the account turns it on in Settings → Git → Changes panel. One account
|
|
* preference, `agenthub.changes.innerRepos` (`lib/userPrefs.ts`,
|
|
* `server/routes/me.js`), read through `useSyncExternalStore` and re-read
|
|
* when the account's preferences load (`PREFS_EVENT`) or another tab writes.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
import { useSyncExternalStore } from "react";
|
|
import { PREFS_EVENT } from "./workspaceGroups";
|
|
|
|
export const INNER_REPOS_KEY = "agenthub.changes.innerRepos";
|
|
export type InnerReposMode = "all" | "own";
|
|
|
|
const listeners = new Set<() => void>();
|
|
|
|
export function readInnerReposMode(): InnerReposMode {
|
|
try {
|
|
return localStorage.getItem(INNER_REPOS_KEY) === "all" ? "all" : "own";
|
|
} catch {
|
|
return "own";
|
|
}
|
|
}
|
|
|
|
export function writeInnerReposMode(mode: InnerReposMode): void {
|
|
try {
|
|
// The default is stored as no value, so an account that never chose keeps following it.
|
|
if (mode === "all") localStorage.setItem(INNER_REPOS_KEY, "all");
|
|
else localStorage.removeItem(INNER_REPOS_KEY);
|
|
} catch {
|
|
/* disabled storage: nothing to remember */
|
|
}
|
|
listeners.forEach((l) => l());
|
|
}
|
|
|
|
function subscribe(l: () => void) {
|
|
listeners.add(l);
|
|
const onStorage = (e: StorageEvent) => {
|
|
if (e.key === INNER_REPOS_KEY || e.key === null) l();
|
|
};
|
|
window.addEventListener("storage", onStorage);
|
|
window.addEventListener(PREFS_EVENT, l);
|
|
return () => {
|
|
listeners.delete(l);
|
|
window.removeEventListener("storage", onStorage);
|
|
window.removeEventListener(PREFS_EVENT, l);
|
|
};
|
|
}
|
|
|
|
export function useInnerReposMode(): InnerReposMode {
|
|
return useSyncExternalStore(subscribe, readInnerReposMode);
|
|
}
|