Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions apps/code/src/renderer/features/setup/services/setupRunService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,17 @@ export class SetupRunService {
});

if (installState === "initialized") {
useSetupStore
.getState()
.addEnricherSuggestionIfMissing(buildSdkHealthSuggestion());
useSetupStore.getState().addEnricherSuggestionIfMissing({
...buildSdkHealthSuggestion(),
repoPath: directory,
});
await this.injectStaleFlagSuggestions(directory);
} else {
const suggestion = buildPosthogSetupSuggestion(installState);
useSetupStore.getState().addEnricherSuggestionIfMissing(suggestion);
useSetupStore.getState().addEnricherSuggestionIfMissing({
...suggestion,
repoPath: directory,
});
}
useSetupStore.getState().completeEnrichment();
} catch (err) {
Expand All @@ -297,7 +301,10 @@ export class SetupRunService {
});
const store = useSetupStore.getState();
for (const flag of flags) {
store.addEnricherSuggestionIfMissing(buildStaleFlagSuggestion(flag));
store.addEnricherSuggestionIfMissing({
...buildStaleFlagSuggestion(flag),
repoPath: directory,
});
}
} catch (err) {
log.warn("Failed to find stale flag suggestions", { error: err });
Expand Down Expand Up @@ -423,7 +430,8 @@ export class SetupRunService {
taskCount: tasks.length,
signalSource,
});
useSetupStore.getState().completeDiscovery(tasks);
const tasksWithRepo = tasks.map((t) => ({ ...t, repoPath: directory }));
useSetupStore.getState().completeDiscovery(tasksWithRepo);
track(ANALYTICS_EVENTS.SETUP_DISCOVERY_COMPLETED, {
discovery_task_id: task.id,
discovery_task_run_id: taskRun.id,
Expand Down
6 changes: 6 additions & 0 deletions apps/code/src/renderer/features/setup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export interface DiscoveredTask {
| "posthog_setup"
| "experiment";
source: DiscoveredTaskSource;
// The repo this suggestion was produced for — a local filesystem path for
// local-workspace runs, or "org/repo" for cloud runs. Stamped at the time
// the suggestion is created so the new task page can filter suggestions
// when the selected repo changes. Optional for backward compatibility with
// suggestions persisted before this field existed.
repoPath?: string;
file?: string;
lineHint?: number;
impact?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ const LOG_FEED_PADDING = 16;

interface SuggestedTasksPanelProps {
onSelect: (task: DiscoveredTask) => void;
// The repo currently selected on the new task page. Suggestions are only
// shown if their `repoPath` matches this value. Suggestions persisted
// before the field existed (no `repoPath`) are shown unconditionally so
// existing users don't lose their inbox until the next discovery run.
repoPath?: string | null;
}

export function SuggestedTasksPanel({ onSelect }: SuggestedTasksPanelProps) {
const discoveredTasks = useSetupStore((s) => s.discoveredTasks);
export function SuggestedTasksPanel({
onSelect,
repoPath,
}: SuggestedTasksPanelProps) {
const allDiscoveredTasks = useSetupStore((s) => s.discoveredTasks);
const discoveredTasks = repoPath
? allDiscoveredTasks.filter((t) => !t.repoPath || t.repoPath === repoPath)
: allDiscoveredTasks;
const discoveryStatus = useSetupStore((s) => s.discoveryStatus);
const enricherStatus = useSetupStore((s) => s.enricherStatus);
const discoveryFeed = useSetupStore((s) => s.discoveryFeed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ export function TaskInput({
<CloudGithubMissingNotice />
</div>
)}
<SuggestedTasksPanel onSelect={handleSelectSuggestion} />
<SuggestedTasksPanel
onSelect={handleSelectSuggestion}
repoPath={effectiveRepoPath}
/>
</Flex>
</motion.div>
</LayoutGroup>
Expand Down
Loading