Skip to content

Commit 16b1efc

Browse files
committed
Remove suggestion simulation harness
1 parent 32788c5 commit 16b1efc

4 files changed

Lines changed: 1 addition & 124 deletions

File tree

apps/code/src/renderer/features/setup/hooks/useSetupDiscovery.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ import { RENDERER_TOKENS } from "@renderer/di/tokens";
55
import { useActiveRepoStore } from "@stores/activeRepoStore";
66
import { useEffect } from "react";
77

8-
const SIMULATE_SUGGESTIONS_STORAGE_KEY = "posthog-code:simulate-suggestions";
9-
10-
function shouldSimulateSuggestions(): boolean {
11-
if (!import.meta.env.DEV) return false;
12-
if (import.meta.env.VITE_SIMULATE_SUGGESTIONS === "1") return true;
13-
return window.localStorage.getItem(SIMULATE_SUGGESTIONS_STORAGE_KEY) === "1";
14-
}
15-
168
export function useSetupDiscovery() {
179
const selectedDirectory = useActiveRepoStore((s) => s.path);
1810

@@ -22,17 +14,8 @@ export function useSetupDiscovery() {
2214
// Enricher runs per repo on every selection (gated on per-repo status
2315
// inside the service).
2416
useEffect(() => {
25-
if (!selectedDirectory) return undefined;
17+
if (!selectedDirectory) return;
2618
const service = get<SetupRunService>(RENDERER_TOKENS.SetupRunService);
27-
if (shouldSimulateSuggestions()) {
28-
service.startSuggestionSimulation(
29-
selectedDirectory,
30-
shouldSimulateSuggestions,
31-
);
32-
return () => service.stopSuggestionSimulation(selectedDirectory);
33-
}
34-
35-
service.stopSuggestionSimulation();
3619
const discoveryEverStarted = Object.values(
3720
useSetupStore.getState().discoveryByRepo,
3821
).some((d) => d.status !== "idle");
@@ -41,6 +24,5 @@ export function useSetupDiscovery() {
4124
} else {
4225
service.startSetup(selectedDirectory);
4326
}
44-
return undefined;
4527
}, [selectedDirectory]);
4628
}

apps/code/src/renderer/features/setup/services/setupRunService.ts

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,6 @@ const log = logger.scope("setup-run-service");
2828

2929
let activityIdCounter = 0;
3030

31-
const SIMULATED_SUGGESTION_CATEGORIES: DiscoveredTask["category"][] = [
32-
"bug",
33-
"performance",
34-
"dead_code",
35-
"duplication",
36-
"event_tracking",
37-
"experiment",
38-
];
39-
40-
const SIMULATED_SUGGESTION_INTERVAL_MS = 2500;
41-
const SIMULATED_SUGGESTION_LIMIT = 12;
42-
43-
function buildSimulatedSuggestion(
44-
repoPath: string,
45-
index: number,
46-
): DiscoveredTask {
47-
const category =
48-
SIMULATED_SUGGESTION_CATEGORIES[
49-
index % SIMULATED_SUGGESTION_CATEGORIES.length
50-
];
51-
52-
return {
53-
id: `simulated-suggestion-${index}`,
54-
source: "agent",
55-
repoPath,
56-
category,
57-
title: `Simulated suggestion ${index + 1}`,
58-
description:
59-
"A generated setup suggestion for exercising empty-state layout stability while new content keeps arriving.",
60-
impact:
61-
"This is dev-only test data for checking whether the composer and suggestion rows stay anchored during incremental updates.",
62-
recommendation:
63-
"Use this simulation to hover and click suggestions while the list keeps changing underneath the same UI surface.",
64-
prompt: `Investigate simulated suggestion ${index + 1}`,
65-
};
66-
}
67-
6831
function extractPathFromRawInput(
6932
tool: string,
7033
rawInput: Record<string, unknown> | undefined,
@@ -273,9 +236,6 @@ export class SetupRunService {
273236
private anyDiscoveryEverLaunched = false;
274237
private discoveryStartingByRepo = new Set<string>();
275238
private enricherSuggestionsRunningByRepo = new Set<string>();
276-
private simulatedSuggestionsRepo: string | null = null;
277-
private simulatedSuggestionsTimer: number | null = null;
278-
private simulatedSuggestionsCount = 0;
279239

280240
startSetup(directory: string): void {
281241
// Defense in depth: never auto-run from a non-idle persisted state.
@@ -296,54 +256,6 @@ export class SetupRunService {
296256
this.injectEnricherSuggestions(directory);
297257
}
298258

299-
startSuggestionSimulation(
300-
directory: string,
301-
shouldContinue: () => boolean = () => true,
302-
): void {
303-
if (!directory) return;
304-
if (this.simulatedSuggestionsRepo === directory) return;
305-
306-
if (this.simulatedSuggestionsTimer !== null) {
307-
window.clearInterval(this.simulatedSuggestionsTimer);
308-
}
309-
310-
this.simulatedSuggestionsRepo = directory;
311-
this.simulatedSuggestionsCount = 0;
312-
313-
const addNextSuggestion = () => {
314-
if (
315-
!shouldContinue() ||
316-
this.simulatedSuggestionsCount >= SIMULATED_SUGGESTION_LIMIT
317-
) {
318-
this.stopSuggestionSimulation(directory);
319-
return;
320-
}
321-
322-
useSetupStore
323-
.getState()
324-
.addDiscoveredTaskIfMissing(
325-
buildSimulatedSuggestion(directory, this.simulatedSuggestionsCount),
326-
);
327-
this.simulatedSuggestionsCount += 1;
328-
};
329-
330-
addNextSuggestion();
331-
this.simulatedSuggestionsTimer = window.setInterval(
332-
addNextSuggestion,
333-
SIMULATED_SUGGESTION_INTERVAL_MS,
334-
);
335-
}
336-
337-
stopSuggestionSimulation(directory?: string): void {
338-
if (directory && this.simulatedSuggestionsRepo !== directory) return;
339-
if (this.simulatedSuggestionsTimer !== null) {
340-
window.clearInterval(this.simulatedSuggestionsTimer);
341-
}
342-
this.simulatedSuggestionsTimer = null;
343-
this.simulatedSuggestionsRepo = null;
344-
this.simulatedSuggestionsCount = 0;
345-
}
346-
347259
startDiscovery(directory: string): void {
348260
if (!directory) return;
349261
if (this.anyDiscoveryEverLaunched) return;

apps/code/src/renderer/features/setup/stores/setupStore.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ interface SetupStoreActions {
6565
completeEnrichment: (repoPath: string) => void;
6666
failEnrichment: (repoPath: string) => void;
6767
removeDiscoveredTask: (taskId: string, repoPath: string | null) => void;
68-
addDiscoveredTaskIfMissing: (task: DiscoveredTask) => void;
6968
addEnricherSuggestionIfMissing: (task: DiscoveredTask) => void;
7069
pushDiscoveryActivity: (repoPath: string, entry: ActivityEntry) => void;
7170
resetSetup: () => void;
@@ -264,21 +263,6 @@ export const useSetupStore = create<SetupStore>()(
264263
}));
265264
},
266265

267-
addDiscoveredTaskIfMissing: (task) => {
268-
set((state) => {
269-
if (
270-
state.discoveredTasks.some(
271-
(t) => t.id === task.id && t.repoPath === task.repoPath,
272-
)
273-
) {
274-
return state;
275-
}
276-
return {
277-
discoveredTasks: [...state.discoveredTasks, task],
278-
};
279-
});
280-
},
281-
282266
// Adds an enricher-source suggestion if there isn't already one with
283267
// the same id+repoPath. Idempotent — safe to call repeatedly on every
284268
// detection run. Dismissed suggestions stay dismissed until `resetSetup`.

apps/code/src/vite-env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ interface ImportMetaEnv {
1111
readonly VITE_POSTHOG_API_KEY?: string;
1212
readonly VITE_POSTHOG_API_HOST?: string;
1313
readonly VITE_POSTHOG_UI_HOST?: string;
14-
readonly VITE_SIMULATE_SUGGESTIONS?: string;
1514
}
1615

1716
interface ImportMeta {

0 commit comments

Comments
 (0)