Skip to content

Real-time network monitor + outbound firewall — see & block every connection. Privacy-first, local-first, Rust fleet agent, SIEM exports, 8 languages. / Moniteur réseau temps réel + pare-feu sortant, agent de flotte Rust, exports SIEM. 100 % local.

feat(apps): add Lucide icons to the per-process table (#27)

wufangyong97391897ac88d08
diff --git a/frontend/src/components/AppsView.jsx b/frontend/src/components/AppsView.jsx
index a2a3d18..6bd0020 100644
--- a/frontend/src/components/AppsView.jsx
+++ b/frontend/src/components/AppsView.jsx
@@ -11,6 +11,7 @@
import { useState, useEffect, useMemo, Fragment } from 'react'
import { useT } from '../i18n'
import { apiBase, authHeaders } from '../api'
+import { processIcon } from './processIcons'
function fmtBytes(b) {
if (b >= 1e9) return (b / 1e9).toFixed(1) + ' GB'
@@ -83,7 +84,17 @@ export default function AppsView({ nodes }) {
onClick={() => setExpanded(expanded === app.name ? null : app.name)}
style={{ cursor: 'pointer', borderTop: '1px solid #0f0f0f' }}
>
- <td style={{ padding: '8px', color: '#e2e8f0', fontFamily: 'monospace' }}>{app.name}</td>
+ <td style={{ padding: '8px', color: '#e2e8f0', fontFamily: 'monospace' }}>
+ {(() => {
+ const Icon = processIcon(app.name)
+ return (
+ <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
+ <Icon size={14} style={{ color: '#3b82f6', flexShrink: 0 }} />
+ {app.name}
+ </span>
+ )
+ })()}
+ </td>
<td style={{ padding: '8px', textAlign: 'right', color: '#94a3b8' }}>{app.destinations.length}</td>
<td style={{ padding: '8px', textAlign: 'right', color: '#94a3b8' }}>{app.packets}</td>
<td style={{ padding: '8px' }}>
diff --git a/frontend/src/components/processIcons.js b/frontend/src/components/processIcons.js
new file mode 100644
index 0000000..cf0bdc6
--- /dev/null
+++ b/frontend/src/components/processIcons.js
@@ -0,0 +1,89 @@
+/**
+ * Snitch — per-process icon picker.
+ *
+ * EN: The apps table (AppsView) shows the raw process name in a monospace cell.
+ * Unknown processes used to render with no visual affordance at all.
+ * This module maps well-known process names to a Lucide icon so a glance
+ * at the table already tells you "that's a browser" vs "that's a container
+ * runtime" without reading the name.
+ *
+ * The matcher is deliberately keyword-based and case-insensitive: process
+ * names come from the OS in wildly different forms (`code`, `Code`,
+ * `Visual Studio Code`, `slack.exe`, ...). A process that matches nothing
+ * falls back to `AppWindow`, the same generic icon the sidebar already
+ * uses for the whole "Apps" view.
+ *
+ * FR: Le tableau des applications (AppsView) affiche le nom brut du processus
+ * dans une cellule monospace. Les processus inconnus ne donnaient aucun
+ * indice visuel. Ce module associe les noms de processus bien connus à une
+ * icône Lucide afin d'identifier au premier coup d'œil « c'est un
+ * navigateur » vs « c'est un runtime conteneur ». Le matcheur est volontairement
+ * fondé sur des mots-clés et insensible à la casse ; un processus qui ne
+ * correspond à rien retombe sur `AppWindow`, la même icône générique que
+ * la barre latérale utilise pour la vue « Applications ».
+ */
+import {
+ AppWindow,
+ Bot,
+ Boxes,
+ Box,
+ Cpu,
+ Gamepad,
+ GitBranch,
+ Globe,
+ MessageSquare,
+ MessageSquareText,
+ Music,
+ SquareCode,
+ Terminal,
+ Video,
+} from 'lucide-react'
+
+// EN: Keyword → icon rules, evaluated top to bottom; first hit wins.
+// Keywords are lower-cased substrings matched against the process name.
+// FR: Règles mot-clé → icône, évaluées de haut en bas ; la première correspondance l'emporte.
+const RULES = [
+ // Video / meeting apps
+ [['zoom', 'teams', 'skype', 'facetime', 'meet'], Video],
+ // Game / game-launcher
+ [['steam', 'epic', 'game', 'unity', 'blender'], Gamepad],
+ // Code editors / IDEs
+ [['vscode', 'code', 'code-oss', 'cursor', 'sublime', 'notepad++', 'vim', 'emacs', 'jetbrains', 'intellij', 'pycharm', 'webstorm'], SquareCode],
+ // Browsers
+ [['firefox', 'chrome', 'chromium', 'brave', 'edge', 'safari', 'opera', 'browser'], Globe],
+ // Chats / messaging
+ [['slack', 'discord', 'telegram', 'whatsapp', 'messenger', 'signal', 'teamspeak'], MessageSquareText],
+ // Music / media
+ [['spotify', 'vlc', 'mpv', 'foobar', 'music', 'mediaplayer', 'youtube', 'netflix', 'twitch'], Music],
+ // Containers / dev tooling
+ [['docker', 'container', 'podman', 'kubernetes', 'kubectl'], Boxes],
+ // AI / model runtimes
+ [['ollama', 'llama', 'llm', 'claude', 'gemini', 'openai', 'langchain'], Bot],
+ // Version control
+ [['git', 'github', 'gitlab', 'gh_'], GitBranch],
+ // Shells / terminals
+ [['terminal', 'powershell', 'pwsh', 'cmd', 'bash', 'zsh', 'ssh', 'console', 'cmdline'], Terminal],
+ // Language runtimes / build tools
+ [['node', 'npm', 'yarn', 'pnpm', 'python', 'pip', 'java', 'rust', 'cargo', 'go', 'golang', 'deno', 'bun', 'ruby', 'php'], Cpu],
+ // Office suite
+ [['word', 'excel', 'powerpoint', 'outlook', 'office'], Box],
+ // Messaging fallback (generic chat)
+ [['chat', 'im', 'communicator'], MessageSquare],
+]
+
+/**
+ * EN: Return the Lucide icon component that best represents `name`.
+ * FR: Renvoyer le composant d'icône Lucide qui représente le mieux `name`.
+ *
+ * @param {string} name raw process name from the OS
+ * @returns {LucideIcon} a Lucide icon component (AppWindow when nothing matches)
+ */
+export function processIcon(name) {
+ const n = String(name == null ? '' : name).toLowerCase()
+ for (const [keys, Icon] of RULES) {
+ if (keys.some((k) => n.includes(k))) return Icon
+ }
+ return AppWindow
+}
+
+export default processIcon
diff --git a/frontend/src/components/processIcons.test.js b/frontend/src/components/processIcons.test.js
new file mode 100644
index 0000000..ddf9dcb
--- /dev/null
+++ b/frontend/src/components/processIcons.test.js
@@ -0,0 +1,55 @@
+/**
+ * Tests for processIcons — the process-name → Lucide icon matcher.
+ *
+ * EN: These run in the plain Node vitest environment (no DOM), so the tests
+ * assert on component identity, not on rendered output.
+ * FR: Ces tests tournent dans l'environnement Node (pas de DOM) ; on
+ * vérifie l'identité du composant, pas le rendu.
+ */
+import { describe, it, expect } from 'vitest'
+import {
+ AppWindow,
+ Boxes,
+ Bot,
+ Cpu,
+ Gamepad,
+ Globe,
+ GitBranch,
+ Music,
+ SquareCode,
+ Terminal,
+ Video,
+} from 'lucide-react'
+import { processIcon } from './processIcons'
+
+describe('processIcon', () => {
+ it('matches case-insensitively', () => {
+ expect(processIcon('SLACK')).toBe(processIcon('slack'))
+ expect(processIcon('CODE')).toBe(SquareCode)
+ expect(processIcon('code')).toBe(SquareCode)
+ })
+
+ it('matches on substrings of the raw process name', () => {
+ expect(processIcon('Visual Studio Code')).toBe(SquareCode)
+ expect(processIcon('firefox-esr')).toBe(Globe)
+ expect(processIcon('dockerd')).toBe(Boxes)
+ })
+
+ it('falls back to AppWindow for unknown / empty / null names', () => {
+ expect(processIcon('some-unknown-binary')).toBe(AppWindow)
+ expect(processIcon('')).toBe(AppWindow)
+ expect(processIcon(null)).toBe(AppWindow)
+ })
+
+ it('covers the icon families requested in issue #13', () => {
+ expect(processIcon('steam')).toBe(Gamepad) // Steam / game launchers
+ expect(processIcon('firefox')).toBe(Globe) // browsers
+ expect(processIcon('code')).toBe(SquareCode) // VS Code
+ expect(processIcon('ollama')).toBe(Bot) // AI runtimes
+ expect(processIcon('git')).toBe(GitBranch) // version control
+ expect(processIcon('python')).toBe(Cpu) // language runtimes
+ expect(processIcon('spotify')).toBe(Music) // media
+ expect(processIcon('zoom')).toBe(Video) // meeting apps
+ expect(processIcon('powershell')).toBe(Terminal) // shells
+ })
+})