Skip to content

Commit 1a0b54f

Browse files
committed
unslop(web-hooks): strip AI-slop (comments, dead handlers, over-abstraction, useEffect-derived, zustand selectors, raw MUI)
1 parent 95dd1db commit 1a0b54f

63 files changed

Lines changed: 88 additions & 923 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

web/src/hooks/assets/useAssetDisplay.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import VideoViewer from "../../components/asset_viewer/VideoViewer";
77
import LazyPDFViewer from "../../components/asset_viewer/LazyPDFViewer";
88
import LazyModel3DViewer from "../../components/asset_viewer/LazyModel3DViewer";
99

10-
// Helper to detect 3D model content types
1110
const isModel3D = (type: string, url?: string): boolean => {
12-
// Check MIME types
1311
if (
1412
type.startsWith("model/") ||
1513
type === "application/octet-stream" ||
@@ -18,7 +16,6 @@ const isModel3D = (type: string, url?: string): boolean => {
1816
) {
1917
return true;
2018
}
21-
// Check file extensions
2219
if (url) {
2320
try {
2421
// Extract pathname to handle URLs with query parameters or fragments

web/src/hooks/assets/useAssetSelection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const useAssetSelection = (sortedAssets: Asset[]) => {
3030
(state) => state.setCurrentAudioAsset
3131
);
3232

33-
// Helper function to update both selectedAssetIds and selectedAssets efficiently
3433
const updateSelection = useCallback(
3534
(assetIds: string[]) => {
3635
setSelectedAssetIds(assetIds);

web/src/hooks/browser/useClipboard.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const useClipboard = (): UseClipboardResult => {
2121
[]
2222
);
2323

24-
// Check if Electron API is available
2524
const hasElectronApi = useMemo(
2625
() => typeof window !== "undefined" && !!window.api,
2726
[]
@@ -130,7 +129,6 @@ export const useClipboard = (): UseClipboardResult => {
130129
readClipboard,
131130
writeClipboard,
132131
isClipboardValid,
133-
// Export utility function for asset-based clipboard operations
134132
copyAssetToClipboard
135133
};
136134
};

web/src/hooks/browser/useRealtimeAudioPlayback.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface UseRealtimeAudioPlaybackOptions {
2323
chunksVersion: number;
2424
sampleRate?: number;
2525
channels?: number;
26-
nodeId?: string; // Optional ID for this audio source
26+
nodeId?: string;
2727
/**
2828
* Live-monitoring mode: keep the scheduled lead over the playhead within a
2929
* small bound by dropping stale chunks instead of queueing them. Use for
@@ -386,7 +386,6 @@ export const useRealtimeAudioPlayback = ({
386386
[channels, sampleRate, decodeChunkSamples]
387387
);
388388

389-
// Internal play/stop functions (called by queue)
390389
const internalStart = useCallback(() => {
391390
const ctx = audioContextRef.current;
392391
if (!ctx) {
@@ -568,7 +567,6 @@ export const useRealtimeAudioPlayback = ({
568567
});
569568
}, [nodeId, decodeChunkSamples, noteDelivery]);
570569

571-
// Public start: requests playback via queue
572570
const start = useCallback(() => {
573571
setWantsToPlay(true);
574572
audioQueue.enqueue({
@@ -578,7 +576,6 @@ export const useRealtimeAudioPlayback = ({
578576
});
579577
}, [audioQueue, internalStart, internalStop]);
580578

581-
// Public stop: removes from queue
582579
const stop = useCallback(() => {
583580
setWantsToPlay(false);
584581
internalStop();

web/src/hooks/browser/useVideoRecorder.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ export function useVideoRecorder({ onChange }: VideoRecorderProps): Readonly<Vid
227227

228228
const handleRecord = useCallback(() => {
229229
if (mediaRecorderRef.current && isRecording) {
230-
// Stop recording
231230
mediaRecorderRef.current.stop();
232231
setIsRecording(false);
233232
return;
@@ -305,7 +304,6 @@ export function useVideoRecorder({ onChange }: VideoRecorderProps): Readonly<Vid
305304

306305
return () => {
307306
if (mediaRecorderRef.current) {
308-
// Check if it's currently recording before stopping
309307
if (mediaRecorderRef.current.state === "recording") {
310308
mediaRecorderRef.current.stop();
311309
}

web/src/hooks/editor/useChatIntegration.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ BLOCKED: setTimeout, setInterval, eval, require, import, process, __dirname, __f
213213
[sendMessageFn, buildContext]
214214
);
215215

216-
// Connection is now handled automatically by GlobalWebSocketManager
217-
218216
const improvePendingRef = useRef<{
219217
active: boolean;
220218
baseCount: number;

web/src/hooks/editor/useEditorKeyboardShortcuts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export function useEditorKeyboardShortcuts(options: {
77
}) {
88
const { onToggleFullscreen, onToggleAssistant, onToggleEditorMode } = options;
99

10-
// Register combos; the hook itself is declarative wrappers around useCombo
1110
useCombo(["Control", "shift", "f"], onToggleFullscreen, false);
1211
useCombo(["Meta", "shift", "f"], onToggleFullscreen, false);
1312
useCombo(["Control", "shift", "a"], onToggleAssistant, false);

web/src/hooks/editor/useMonacoEditor.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ async function configureMonacoLoader() {
1313
loaderConfigured = true;
1414
}
1515

16-
/**
17-
* Monaco editor component type definition.
18-
*/
1916
type MonacoComponent = (props: {
2017
value: string;
2118
onChange?: (val?: string) => void;
@@ -27,46 +24,18 @@ type MonacoComponent = (props: {
2724
onMount?: (editor: monaco.editor.IStandaloneCodeEditor, monaco: typeof import("monaco-editor")) => void;
2825
}) => React.JSX.Element;
2926

30-
/**
31-
* Result object containing Monaco editor state and functions.
32-
*/
3327
type MonacoEditorResult = {
34-
/** The lazily-loaded Monaco editor component */
3528
MonacoEditor: MonacoComponent | null;
36-
/** Error message if Monaco failed to load */
3729
monacoLoadError: string | null;
38-
/** True while the Monaco bundle is being fetched */
3930
isMonacoLoading: boolean;
40-
/** Function to load Monaco editor if not already loaded */
4131
loadMonacoIfNeeded: () => Promise<void>;
42-
/** Reference to the Monaco editor instance */
4332
monacoRef: React.MutableRefObject<monaco.editor.IStandaloneCodeEditor | null>;
44-
/** Callback called when Monaco editor mounts */
4533
monacoOnMount: (editor: monaco.editor.IStandaloneCodeEditor) => void;
46-
/** Opens the find panel in the editor */
4734
handleMonacoFind: () => void;
48-
/** Formats the document in the editor */
4935
handleMonacoFormat: () => void;
5036
};
5137

52-
/**
53-
* Hook for lazy-loading and managing Monaco editor instance.
54-
*
55-
* This hook handles dynamic importing of the Monaco editor library,
56-
* providing lazy loading to avoid loading the heavy editor until needed.
57-
*
58-
* @returns Object containing Monaco editor state and control functions
59-
*
60-
* @example
61-
* ```typescript
62-
* const { MonacoEditor, loadMonacoIfNeeded, handleMonacoFormat } = useMonacoEditor();
63-
*
64-
* useEffect(() => { loadMonacoIfNeeded(); }, [loadMonacoIfNeeded]);
65-
*
66-
* if (!MonacoEditor) return <Loading />;
67-
* return <MonacoEditor value={code} language="typescript" />;
68-
* ```
69-
*/
38+
/** Lazy-loads and manages a Monaco editor instance, deferring the heavy bundle until needed. */
7039
export function useMonacoEditor(): MonacoEditorResult {
7140
const [MonacoEditor, setMonacoEditor] = useState<MonacoComponent | null>(
7241
null
@@ -91,7 +60,6 @@ export function useMonacoEditor(): MonacoEditorResult {
9160
isLoadingRef.current = true;
9261
setIsMonacoLoading(true);
9362
try {
94-
// Configure loader to use local monaco-editor instead of CDN
9563
await configureMonacoLoader();
9664
const mod = await import("@monaco-editor/react");
9765
setMonacoEditor(() => mod.default as unknown as MonacoComponent);
@@ -102,7 +70,7 @@ export function useMonacoEditor(): MonacoEditorResult {
10270
isLoadingRef.current = false;
10371
setIsMonacoLoading(false);
10472
}
105-
}, []); // No dependencies - callback is now stable
73+
}, []);
10674

10775
const handleMonacoFind = useCallback(() => {
10876
try {

web/src/hooks/handlers/addNodeFromAsset.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// create nodes from existing assets
2-
31
import { useCallback } from "react";
42
import { XYPosition } from "@xyflow/react";
53
import { Asset, NodeMetadata } from "../../stores/ApiTypes";

web/src/hooks/handlers/useClipboardContentPaste.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ export const useClipboardContentPaste = () => {
183183
}
184184
}
185185

186-
// Legacy Electron API
187-
if (window.api?.clipboard?.readText) {
188-
const text = await window.api.clipboard.readText();
189-
if (text && text.trim()) {
190-
return text;
191-
}
192-
}
193-
194186
// Fallback to web API
195187
if (navigator.clipboard && navigator.clipboard.readText) {
196188
const text = await navigator.clipboard.readText();

0 commit comments

Comments
 (0)