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
30 changes: 2 additions & 28 deletions src/engines/SessionCore/core/atoms/actions.simulatorPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* the authoritative Rust snapshot arrives. Extracted from actions.ts.
*/
import { isLiveRuntimeResourceEvent } from "../runningEventGate";
import { getFallbackSimulatorEventFilterCategory } from "../simulatorEventFilterCategory";
import type { SessionEvent, SimulatorEventPreview } from "../types";

/**
Expand Down Expand Up @@ -34,33 +35,6 @@ export function isSimulatorVisibleApprox(event: SessionEvent): boolean {
);
}

function getSimulatorFilterCategory(
event: SessionEvent
): SimulatorEventPreview["filterCategory"] {
if (event.source === "user") return "key_interactions";
if (
event.uiCanonical === "edit_file" ||
event.uiCanonical === "delete_file"
) {
return "file_changes";
}
if (event.command || event.uiCanonical === "run_shell") {
return "terminal_events";
}
if (
event.uiCanonical === "read_file" ||
event.uiCanonical === "list_dir" ||
event.uiCanonical === "code_search" ||
event.uiCanonical === "glob" ||
event.uiCanonical === "find_files" ||
event.uiCanonical === "search"
) {
return "explore";
}
if (event.filePath) return "file_changes";
return "other";
}

function buildSimulatorPreview(event: SessionEvent): SimulatorEventPreview {
return {
id: event.id,
Expand All @@ -74,7 +48,7 @@ function buildSimulatorPreview(event: SessionEvent): SimulatorEventPreview {
displayStatus: event.displayStatus,
displayVariant: event.displayVariant,
activityStatus: event.activityStatus,
filterCategory: getSimulatorFilterCategory(event),
filterCategory: getFallbackSimulatorEventFilterCategory(event),
threadId: event.threadId,
processId: event.processId,
callId: event.callId,
Expand Down
42 changes: 42 additions & 0 deletions src/engines/SessionCore/core/simulatorEventFilterCategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { SessionEvent, SimulatorEventFilterValue } from "./types";

export const SIMULATOR_EVENT_FILTER_VALUES = [
"key_interactions",
"file_changes",
"terminal_events",
"explore",
"other",
] as const satisfies readonly SimulatorEventFilterValue[];

/**
* Canonical fallback category used by every local simulator preview path.
* The backend-projected category remains authoritative once its snapshot
* arrives; this function keeps optimistic and materialized local previews in
* lockstep until then.
*/
export function getFallbackSimulatorEventFilterCategory(
event: SessionEvent
): SimulatorEventFilterValue {
if (event.source === "user") return "key_interactions";
if (
event.uiCanonical === "edit_file" ||
event.uiCanonical === "delete_file"
) {
return "file_changes";
}
if (event.command || event.uiCanonical === "run_shell") {
return "terminal_events";
}
if (
event.uiCanonical === "read_file" ||
event.uiCanonical === "list_dir" ||
event.uiCanonical === "code_search" ||
event.uiCanonical === "glob" ||
event.uiCanonical === "find_files" ||
event.uiCanonical === "search"
) {
return "explore";
}
if (event.filePath) return "file_changes";
return "other";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,10 @@
* objects are cached by event object identity so events untouched by a
* delta reuse their preview across materializations.
*/
import type {
SessionEvent,
SimulatorEventFilterValue,
SimulatorEventPreview,
} from "../types";
import { getFallbackSimulatorEventFilterCategory } from "../simulatorEventFilterCategory";
import type { SessionEvent, SimulatorEventPreview } from "../types";
import type { NormalizedSnapshotCache } from "./EventStoreProxyTypes";

function getFallbackFilterCategory(
event: SessionEvent
): SimulatorEventFilterValue {
if (event.source === "user") return "key_interactions";
if (
event.uiCanonical === "edit_file" ||
event.uiCanonical === "delete_file"
) {
return "file_changes";
}
if (event.command || event.uiCanonical === "run_shell") {
return "terminal_events";
}
if (
event.uiCanonical === "read_file" ||
event.uiCanonical === "list_dir" ||
event.uiCanonical === "code_search" ||
event.uiCanonical === "glob" ||
event.uiCanonical === "find_files" ||
event.uiCanonical === "search"
) {
return "explore";
}
if (event.filePath) return "file_changes";
return "other";
}

function buildSimulatorEventPreview(
event: SessionEvent
): SimulatorEventPreview {
Expand All @@ -56,7 +26,7 @@ function buildSimulatorEventPreview(
displayStatus: event.displayStatus,
displayVariant: event.displayVariant,
activityStatus: event.activityStatus,
filterCategory: getFallbackFilterCategory(event),
filterCategory: getFallbackSimulatorEventFilterCategory(event),
threadId: event.threadId,
processId: event.processId,
callId: event.callId,
Expand Down
39 changes: 4 additions & 35 deletions src/engines/SessionCore/derived/simulatorEventFilters.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
import type {
SessionEvent,
SimulatorEventFilterValue,
SimulatorEventPreview,
} from "../core/types";

export const SIMULATOR_EVENT_FILTER_VALUES = [
"key_interactions",
"file_changes",
"terminal_events",
"explore",
"other",
] as const satisfies readonly SimulatorEventFilterValue[];
export {
SIMULATOR_EVENT_FILTER_VALUES,
getFallbackSimulatorEventFilterCategory,
} from "../core/simulatorEventFilterCategory";

export type { SimulatorEventFilterValue };

export function getFallbackSimulatorEventFilterCategory(
event: SessionEvent
): SimulatorEventFilterValue {
if (event.source === "user") return "key_interactions";
if (
event.uiCanonical === "edit_file" ||
event.uiCanonical === "delete_file"
) {
return "file_changes";
}
if (event.command || event.uiCanonical === "run_shell") {
return "terminal_events";
}
if (
event.uiCanonical === "read_file" ||
event.uiCanonical === "list_dir" ||
event.uiCanonical === "code_search" ||
event.uiCanonical === "glob" ||
event.uiCanonical === "find_files" ||
event.uiCanonical === "search"
) {
return "explore";
}
if (event.filePath) return "file_changes";
return "other";
}

export function isSimulatorEventVisibleForFilters(
preview: SimulatorEventPreview,
selectedFilters: readonly SimulatorEventFilterValue[]
Expand Down
Loading