Skip to content

Commit c0974f3

Browse files
committed
refactor(gui): drop dead refs and duplicate Desktop/Debug cache reads
Remove unused SectionTabs stripRef and ClaudeDesktop hasCache, seed Desktop from one cache read, inline ClaudeCode session seed, and reuse debugResourceKey for optimistic writes.
1 parent 898cf79 commit c0974f3

4 files changed

Lines changed: 4 additions & 11 deletions

File tree

gui/src/components/section-tabs.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function SectionTabs({
2828
ariaLabel: string;
2929
}) {
3030
const [active, setActive] = useState(items[0]?.id ?? "");
31-
const stripRef = useRef<HTMLDivElement | null>(null);
3231
/** While set, scroll-spy ignores intermediate sections during smooth scroll-to-click. */
3332
const scrollLockRef = useRef<string | null>(null);
3433
const scrollLockTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -110,7 +109,6 @@ export function SectionTabs({
110109

111110
return (
112111
<div
113-
ref={stripRef}
114112
className="page-tabs section-tabs"
115113
role="tablist"
116114
aria-label={ariaLabel}

gui/src/pages/ClaudeCode.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ export { AutoConnectSetting, SmallFastModelSetting } from "./claude-code-setting
2222

2323
type CachedClaudeCode = { state: ClaudeCodeState; rows: MapRow[] };
2424

25-
function seedClaudeCode(cacheKey: string): CachedClaudeCode | null {
26-
return readSessionListCache<CachedClaudeCode>(cacheKey);
27-
}
28-
2925
export default function ClaudeCode({ apiBase, active = true }: { apiBase: string; active?: boolean }) {
3026
const t = useT();
3127
const { locale } = useI18n();
3228
const localeTag = LOCALES.find(l => l.code === locale)?.htmlLang ?? "en";
3329
const cacheKey = `ocx.claude-code.v1:${apiBase}`;
3430
const resourceKey = `claude-code:${apiBase}`;
35-
const cached = useMemo(() => seedClaudeCode(cacheKey), [cacheKey]);
31+
const cached = useMemo(() => readSessionListCache<CachedClaudeCode>(cacheKey), [cacheKey]);
3632
const [draftState, setState] = useState<ClaudeCodeState | null>(() => cached?.state ?? null);
3733
const [draftRows, setRows] = useState<MapRow[]>(() => cached?.rows ?? []);
3834
const [hasDraftRows, setHasDraftRows] = useState(Boolean(cached));

gui/src/pages/ClaudeDesktop.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function readDesktopCache(cacheKey: string): CachedDesktop | null {
131131
function seedDesktop(cacheKey: string) {
132132
const cached = readDesktopCache(cacheKey);
133133
return {
134+
held: cached,
134135
data: cached?.data ?? null,
135136
profile: cached?.profile ?? null,
136137
savedProfile: cached?.profile ? cloneProfile(cached.profile) : null,
@@ -139,7 +140,6 @@ function seedDesktop(cacheKey: string) {
139140
cached.data.models.map(model => [model.route, cached.profile.assignments[model.route]?.family ?? "opus"]),
140141
)
141142
: {} as Record<string, Family>,
142-
hasCache: Boolean(cached?.data),
143143
};
144144
}
145145

@@ -158,7 +158,6 @@ export default function ClaudeDesktop({
158158
const cacheKey = `ocx.claude-desktop.v1:${apiBase}`;
159159
const resourceKey = `claude-desktop:${apiBase}`;
160160
const cached = useMemo(() => seedDesktop(cacheKey), [cacheKey]);
161-
const heldDesktop = useMemo(() => readDesktopCache(cacheKey), [cacheKey]);
162161
const [draftProfile, setProfile] = useState<DesktopProfile | null>(() => cached.profile);
163162
const [savedDraftProfile, setSavedProfile] = useState<DesktopProfile | null>(() => cached.savedProfile);
164163
const [draftDestinations, setDestinations] = useState<Record<string, Family>>(() => cached.destinations);
@@ -212,7 +211,7 @@ export default function ClaudeDesktop({
212211
resourceKey,
213212
[apiBase],
214213
fetchDesktop,
215-
{ isEmpty: () => false, enabled: active, initialData: heldDesktop ?? undefined },
214+
{ isEmpty: () => false, enabled: active, initialData: cached.held ?? undefined },
216215
);
217216
const loadState = desktopResource.state;
218217
const resourceData = loadState.data ?? (cached.data && cached.profile ? { data: cached.data, profile: cached.profile } : null);

gui/src/pages/Debug.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default function Debug({ apiBase, embedded, active = true }: { apiBase: s
179179
const next = await res.json() as DebugSettings;
180180
if (generation !== mutationGenerationRef.current) return;
181181
writeSessionListCache(settingsCacheKey, next);
182-
setClientResourceData(debugSettingsKey(apiBase), next);
182+
setClientResourceData(debugResourceKey, next);
183183
} catch { /* ignore */ }
184184
};
185185
const previous = mutationQueueRef.current ?? Promise.resolve();

0 commit comments

Comments
 (0)