Studio: fix tsc errors in Phase 4 frontend

Two errors surfaced by the frontend build (`tsc -b`) after the Phase 4
commit c74fc13eb landed:

  src/features/chat/chat-settings-sheet.tsx(449,9): TS2451 — cannot
  redeclare block-scoped 'activeThreadId'.
  src/features/rag/stores/rag-store.ts(326,9): TS2774 — condition will
  always return true since this function is always defined.

Fixes
- chat-settings-sheet.tsx: an `activeThreadId` declaration already
  existed near the code-exec section (line 636). Phase 2B's RAG
  retrieval-section block introduced a second declaration at line 449.
  The earlier one is needed for the Retrieval block; drop the later
  redeclaration — downstream code still resolves it via lexical scope.
- rag-store.ts subscribeJob: `get().jobUnsubscribers[jobId]` indexes a
  `Record<string, () => void>`. Without `noUncheckedIndexedAccess` TS
  infers the result as the function type (never undefined), so
  `if (existing)` is always-truthy. Replace with `if (jobId in
  get().jobUnsubscribers) return;` — same semantics, satisfies TS.
This commit is contained in:
Roland Tannous 2026-05-24 13:47:34 +04:00
commit a3ad6015bc
2 changed files with 6 additions and 3 deletions

View file

@ -633,7 +633,8 @@ export function ChatSettingsPanel({
activeExternalProvider.baseUrl,
) &&
activeExternalProvider.providerType === "openai";
const activeThreadId = useChatRuntimeStore((s) => s.activeThreadId);
// (activeThreadId is declared earlier in this component — see the
// RAG retrieval-section block above.)
const openAiApiKeyForSection = activeExternalProvider
? getExternalProviderApiKey(activeExternalProvider.id) || null
: null;

View file

@ -322,8 +322,10 @@ export const useRagStore = create<RagStoreState>((set, get) => ({
},
subscribeJob(jobId, onComplete) {
const existing = get().jobUnsubscribers[jobId];
if (existing) return;
// Object indexing in TS returns V (not V|undefined) without
// noUncheckedIndexedAccess, so we test membership explicitly to
// avoid the "always-truthy function reference" lint.
if (jobId in get().jobUnsubscribers) return;
const unsubscribe = subscribeToJobEvents(jobId, {
onEvent: (event) => {
set((state) => ({ jobs: { ...state.jobs, [jobId]: event } }));