Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(grok): drop the inert raw-listener call and the dead remote-home clause

eneseeb630217024
diff --git a/src/main/index.ts b/src/main/index.ts
index d23474f01..43c493a21 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1445,12 +1445,13 @@ app.whenReady().then(async () => {
const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])
hookServer.setRawListener((agentId, nodeId, payload) => {
if (agentId === 'grok') {
- // grok's envelope carries no transcript_path — its transcript is DERIVED from (cwd,
- // sessionId), which Tasks 5/10 use. All this branch can do correctly is the association the
- // phone's context ring and the ⌘K session lookup read, plus the activity line (through
- // grokRawFields, so the two dialects are read in exactly one place).
+ // All this branch does is remember the node↔session association that the phone's context
+ // ring and the ⌘K session lookup read. Everything else the claude path does below hangs off
+ // `transcript_path`, and grok's envelope has none — its transcript is DERIVED from (cwd,
+ // sessionId), so the context tail, the subagent tails and the transcript readers arrive in
+ // Tasks 4/5/10. Read through `grokRawFields` so grok's two field dialects (camelCase and the
+ // SDK's snake_case) are decoded in exactly one place.
const g = grokRawFields(payload)
- recordRawToolEvent(nodeId, { tool_name: g.toolName, tool_input: g.toolInput })
if (nodeId && g.sessionId) nodeContextSession.set(nodeId, g.sessionId)
return
}
diff --git a/src/server/agent-status.ts b/src/server/agent-status.ts
index 0608a0484..e19706ddf 100644
--- a/src/server/agent-status.ts
+++ b/src/server/agent-status.ts
@@ -142,12 +142,13 @@ export function wireAgentStatus(
const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])
hooks.setRawListener((agentId, nodeId, payload) => {
if (agentId === 'grok') {
- // grok's envelope carries no transcript_path — its transcript is DERIVED from (cwd,
- // sessionId), which Tasks 5/10 use. All this branch can do correctly is the association the
- // phone's context ring and the ⌘K session lookup read, plus the activity line (through
- // grokRawFields, so the two dialects are read in exactly one place).
+ // All this branch does is remember the node↔session association that the phone's context
+ // ring and the ⌘K session lookup read. Everything else the claude path does below hangs off
+ // `transcript_path`, and grok's envelope has none — its transcript is DERIVED from (cwd,
+ // sessionId), so the context tail, the subagent tails and the transcript readers arrive in
+ // Tasks 4/5/10. Read through `grokRawFields` so grok's two field dialects (camelCase and the
+ // SDK's snake_case) are decoded in exactly one place.
const g = grokRawFields(payload)
- recordRawToolEvent(nodeId, { tool_name: g.toolName, tool_input: g.toolInput })
if (nodeId && g.sessionId) nodeContextSession.set(nodeId, g.sessionId)
return
}
diff --git a/src/shared/agents/grok-paths.test.ts b/src/shared/agents/grok-paths.test.ts
index 1fba8e87c..5e4dfde22 100644
--- a/src/shared/agents/grok-paths.test.ts
+++ b/src/shared/agents/grok-paths.test.ts
@@ -61,6 +61,11 @@ describe('isSafeRemoteGrokHome', () => {
it('accepts an absolute POSIX path from the host', () => {
expect(isSafeRemoteGrokHome('/home/dev/.grok')).toBe(true)
})
+ it('judges the TRIMMED path — a stray newline off an ssh read is not a rejection reason', () => {
+ // The predicate trims to decide, so it must not also pretend to reject what it trimmed: the
+ // earlier `v !== p?.trim()` guard compared the trimmed value with itself and never fired.
+ expect(isSafeRemoteGrokHome(' /home/dev/.grok\n')).toBe(true)
+ })
it('refuses relative paths, backslashes, control characters and absurd lengths', () => {
expect(isSafeRemoteGrokHome('relative/grok')).toBe(false)
expect(isSafeRemoteGrokHome('/bad\\grok')).toBe(false)
diff --git a/src/shared/agents/grok-paths.ts b/src/shared/agents/grok-paths.ts
index 424ffb775..ce7b2679e 100644
--- a/src/shared/agents/grok-paths.ts
+++ b/src/shared/agents/grok-paths.ts
@@ -3,6 +3,12 @@
// copies of a path rule is exactly what made the remote hook installer subscribe gemini to
// claude's event names for months.
//
+// NODE-SIDE shared code: it imports `path`/`os` and uses `Buffer`, so it is for `src/main`,
+// `src/core`, `src/server` and the SSH installer only — it has no renderer consumer today. A
+// renderer surface that needs one of these helpers must first split the pure half out (the
+// encoding/validation functions are pure; `grokHomeDir`/`grokSessionsDir` are not, they read
+// `homedir()`), not import this file into the browser bundle.
+//
// Measured layout (shipped 1.0.0):
// $GROK_HOME/hooks/*.json — hook files, all merged; GROK_HOME defaults to ~/.grok
// $GROK_HOME/sessions/<encoded cwd>/<id>/ — one directory per session, grouped by cwd
@@ -73,7 +79,7 @@ export function grokSessionDir(a: { sessionsDir: string; cwd: string; sessionId:
* character is usable, and the caller falls back to `$HOME/.grok`. */
export function isSafeRemoteGrokHome(p: string | undefined): boolean {
const v = p?.trim()
- if (!v || v !== p?.trim()) return false
+ if (!v) return false
if (!v.startsWith('/') || v.includes('\\') || v.length > REMOTE_HOME_MAX) return false
return !Array.from(v).some((ch) => {
const c = ch.charCodeAt(0)