Skip to content

The agent that grows with you

refactor(web): move session source config to SessionsPage_sources sibling; satisfy code-health ratchet

Austin Pickettef0c635f33ee
diff --git a/web/src/pages/SessionsPage.tsx b/web/src/pages/SessionsPage.tsx
index c762c2b605a..bb208fdb5c6 100644
--- a/web/src/pages/SessionsPage.tsx
+++ b/web/src/pages/SessionsPage.tsx
@@ -15,14 +15,11 @@ import {
ChevronRight,
Database,
ListFilter,
- MessageSquare,
Search,
Trash2,
Clock,
Terminal,
Globe,
- MessageCircle,
- Hash,
X,
Play,
Eraser,
@@ -48,6 +45,16 @@ import type {
} from "@/lib/api";
import { timeAgo } from "@/lib/utils";
import { Markdown } from "@/components/Markdown";
+import {
+ AUTOMATION_SESSION_SOURCES,
+ NO_MATCHING_SESSION_SOURCE,
+ SOURCE_CONFIG,
+ SessionFilterCategory,
+ SourceSelectionsByCategory,
+ isAutomationSource,
+ sourceBelongsToCategory,
+ sourceLabel,
+} from "./SessionsPage_sources";
import { StructuredReasoning } from "@/components/StructuredReasoning";
import { PlatformsCard } from "@/components/PlatformsCard";
import { shouldRenderStructuredReasoning } from "@/lib/reasoning-markup";
@@ -78,98 +85,6 @@ import { PluginSlot } from "@/plugins";
import { isDashboardEmbeddedChatEnabled } from "@/lib/dashboard-flags";
import { apiErrorFromResponse, errorMessage } from "@/lib/api-error";
-const SOURCE_CONFIG: Record<string, { icon: typeof Terminal; color: string }> =
- {
- cli: { icon: Terminal, color: "text-primary" },
- tui: { icon: Terminal, color: "text-primary" },
- telegram: { icon: MessageCircle, color: "text-[oklch(0.65_0.15_250)]" },
- discord: { icon: Hash, color: "text-[oklch(0.65_0.15_280)]" },
- slack: { icon: MessageSquare, color: "text-[oklch(0.7_0.15_155)]" },
- whatsapp: { icon: Globe, color: "text-success" },
- whatsapp_cloud: { icon: Globe, color: "text-success" },
- signal: { icon: MessageCircle, color: "text-success" },
- matrix: { icon: MessageCircle, color: "text-[oklch(0.65_0.15_250)]" },
- email: { icon: MessageSquare, color: "text-[oklch(0.7_0.15_155)]" },
- sms: { icon: MessageCircle, color: "text-success" },
- cron: { icon: Clock, color: "text-warning" },
- tool: { icon: Play, color: "text-warning" },
- oneshot: { icon: Terminal, color: "text-warning" },
- api_server: { icon: Globe, color: "text-muted-foreground" },
- acp: { icon: Database, color: "text-muted-foreground" },
- hermes_flow: { icon: Play, color: "text-warning" },
- vulcan_delegate: { icon: Play, color: "text-warning" },
- webhook: { icon: Globe, color: "text-warning" },
- };
-
-const AUTOMATION_SESSION_SOURCES = [
- "cron",
- "tool",
- "oneshot",
- "api_server",
- "acp",
- "hermes_flow",
- "vulcan_delegate",
- "webhook",
-];
-const AUTOMATION_SESSION_SOURCE_SET = new Set(AUTOMATION_SESSION_SOURCES);
-const NO_MATCHING_SESSION_SOURCE = "__hermes_dashboard_no_matching_source__";
-
-type SessionFilterCategory = "chats" | "automation" | "all";
-type SourceSelectionsByCategory = Record<SessionFilterCategory, string[] | null>;
-
-function isAutomationSource(source: string): boolean {
- return AUTOMATION_SESSION_SOURCE_SET.has(source);
-}
-
-function sourceBelongsToCategory(
- source: string,
- category: SessionFilterCategory,
-): boolean {
- if (category === "all") return true;
- if (category === "automation") return isAutomationSource(source);
- return !isAutomationSource(source);
-}
-
-function sourceLabel(source: string): string {
- switch (source) {
- case "api_server":
- return "API server";
- case "acp":
- return "ACP";
- case "cli":
- return "CLI";
- case "tui":
- return "TUI";
- case "telegram":
- return "Telegram";
- case "discord":
- return "Discord";
- case "slack":
- return "Slack";
- case "whatsapp":
- return "WhatsApp";
- case "whatsapp_cloud":
- return "WhatsApp Cloud";
- case "sms":
- return "SMS";
- case "cron":
- return "Cron";
- case "tool":
- return "Tool";
- case "hermes_flow":
- return "Hermes Flow";
- case "vulcan_delegate":
- return "Vulcan delegate";
- case "webhook":
- return "Webhook";
- default:
- return source
- .split("_")
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(" ");
- }
-}
/** Render an FTS5 snippet with highlighted matches.
* The backend wraps matches in >>> and <<< delimiters. */
diff --git a/web/src/pages/SessionsPage_sources.tsx b/web/src/pages/SessionsPage_sources.tsx
new file mode 100644
index 00000000000..bca9578e941
--- /dev/null
+++ b/web/src/pages/SessionsPage_sources.tsx
@@ -0,0 +1,103 @@
+import {
+ Clock,
+ Database,
+ Globe,
+ Hash,
+ MessageCircle,
+ MessageSquare,
+ Play,
+ Terminal,
+} from "lucide-react";
+
+export const SOURCE_CONFIG: Record<string, { icon: typeof Terminal; color: string }> =
+ {
+ cli: { icon: Terminal, color: "text-primary" },
+ tui: { icon: Terminal, color: "text-primary" },
+ telegram: { icon: MessageCircle, color: "text-[oklch(0.65_0.15_250)]" },
+ discord: { icon: Hash, color: "text-[oklch(0.65_0.15_280)]" },
+ slack: { icon: MessageSquare, color: "text-[oklch(0.7_0.15_155)]" },
+ whatsapp: { icon: Globe, color: "text-success" },
+ whatsapp_cloud: { icon: Globe, color: "text-success" },
+ signal: { icon: MessageCircle, color: "text-success" },
+ matrix: { icon: MessageCircle, color: "text-[oklch(0.65_0.15_250)]" },
+ email: { icon: MessageSquare, color: "text-[oklch(0.7_0.15_155)]" },
+ sms: { icon: MessageCircle, color: "text-success" },
+ cron: { icon: Clock, color: "text-warning" },
+ tool: { icon: Play, color: "text-warning" },
+ oneshot: { icon: Terminal, color: "text-warning" },
+ api_server: { icon: Globe, color: "text-muted-foreground" },
+ acp: { icon: Database, color: "text-muted-foreground" },
+ hermes_flow: { icon: Play, color: "text-warning" },
+ vulcan_delegate: { icon: Play, color: "text-warning" },
+ webhook: { icon: Globe, color: "text-warning" },
+ };
+
+export const AUTOMATION_SESSION_SOURCES = [
+ "cron",
+ "tool",
+ "oneshot",
+ "api_server",
+ "acp",
+ "hermes_flow",
+ "vulcan_delegate",
+ "webhook",
+];
+const AUTOMATION_SESSION_SOURCE_SET = new Set(AUTOMATION_SESSION_SOURCES);
+export const NO_MATCHING_SESSION_SOURCE = "__hermes_dashboard_no_matching_source__";
+
+export type SessionFilterCategory = "chats" | "automation" | "all";
+export type SourceSelectionsByCategory = Record<SessionFilterCategory, string[] | null>;
+
+export function isAutomationSource(source: string): boolean {
+ return AUTOMATION_SESSION_SOURCE_SET.has(source);
+}
+
+export function sourceBelongsToCategory(
+ source: string,
+ category: SessionFilterCategory,
+): boolean {
+ if (category === "all") return true;
+ if (category === "automation") return isAutomationSource(source);
+ return !isAutomationSource(source);
+}
+
+export function sourceLabel(source: string): string {
+ switch (source) {
+ case "api_server":
+ return "API server";
+ case "acp":
+ return "ACP";
+ case "cli":
+ return "CLI";
+ case "tui":
+ return "TUI";
+ case "telegram":
+ return "Telegram";
+ case "discord":
+ return "Discord";
+ case "slack":
+ return "Slack";
+ case "whatsapp":
+ return "WhatsApp";
+ case "whatsapp_cloud":
+ return "WhatsApp Cloud";
+ case "sms":
+ return "SMS";
+ case "cron":
+ return "Cron";
+ case "tool":
+ return "Tool";
+ case "hermes_flow":
+ return "Hermes Flow";
+ case "vulcan_delegate":
+ return "Vulcan delegate";
+ case "webhook":
+ return "Webhook";
+ default:
+ return source
+ .split("_")
+ .filter(Boolean)
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
+ .join(" ");
+ }
+}