Skip to content

Commit 5effa47

Browse files
skulidropekkonardclaude
authored
pr 387 (#399)
* Initial commit with task details Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #383 * fix(api): hide browser-connection MCP helpers from task manager The Rust browser MCP helpers (`browser-connection` / `docker-git-browser-connection`) run on an allocated pty, so `hasInteractiveTty` classified each one as a visible `ssh` terminal. That flooded the container task manager with many identical `browser-connection --project ... --network container:...` rows (issue #383). Classify these helper processes as internal `system` tasks so they are hidden by default (includeDefault=false) and only shown when system processes are explicitly requested. Fixes #383 * docs(api): add structured functional comment and fast-check property test for browser-helper classifier - Replace prose comment above browserConnectionPattern with full CHANGE/WHY/FORMAT THEOREM/PURITY/INVARIANT/COMPLEXITY block per project conventions (CodeRabbit review on PR #399) - Add fast-check property-based test covering bare and absolute-path variants of browser-connection / docker-git-browser-connection: ∀ cmd ∈ helperCommands: hidden when includeDefault=false, kind="system" when includeDefault=true Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: konard <drakonard@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 818af9e commit 5effa47

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

packages/api/src/services/container-tasks-core.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@ const commandSuggestsSsh = (command: string): boolean => command.startsWith("ssh
2727
const commandSuggestsAgent = (command: string): boolean =>
2828
interactiveAgentPattern.test(command) || command.includes("docker-git-agent-")
2929

30-
// Rust browser MCP helpers (`browser-connection`, `docker-git-browser-connection`)
31-
// run on an allocated pty, so without this they would be misclassified as visible
32-
// `ssh` terminals and flood the task manager (issue #383).
30+
// CHANGE: classify browser-connection / docker-git-browser-connection helpers as system
31+
// WHY: these Rust MCP helpers run on allocated ptys (pts/N); without this guard
32+
// hasInteractiveTty classifies each as a visible "ssh" terminal and floods the
33+
// task manager with duplicate rows (issue #383)
34+
// QUOTE(ТЗ): n/a
35+
// REF: https://github.com/ProverCoderAI/docker-git/issues/383
36+
// SOURCE: n/a
37+
// FORMAT THEOREM: ∀ cmd ∈ Commands: commandSuggestsBrowserHelper(cmd) → classifyProcess(cmd) = "system"
38+
// PURITY: CORE
39+
// INVARIANT: browserConnectionPattern matches the binary name at start or after '/'
40+
// with a word boundary — covers bare invocations and full absolute paths
41+
// COMPLEXITY: O(1) time / O(1) space — single constant regex test
3342
const browserConnectionPattern = /(?:^|\/)(?:docker-git-browser-connection|browser-connection)\b/u
3443

3544
const commandSuggestsBrowserHelper = (command: string): boolean => browserConnectionPattern.test(command)

packages/api/tests/container-tasks-core.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fc from "fast-check"
12
import { describe, expect, it } from "vitest"
23

34
import { buildContainerTasks } from "../src/services/container-tasks-core.js"
@@ -55,6 +56,42 @@ describe("container task classification", () => {
5556
expect(withSystem.map((task) => [task.pid, task.kind])).toEqual([[11502, "system"]])
5657
})
5758

59+
it("hides any browser-helper command variant regardless of path prefix or arguments", () => {
60+
const optArgs = fc.option(fc.string({ maxLength: 40 }), { nil: undefined })
61+
62+
const browserCommandArbitrary = fc.oneof(
63+
optArgs.map((args) => (args === undefined ? "browser-connection" : `browser-connection ${args}`)),
64+
optArgs.map((args) =>
65+
args === undefined ? "docker-git-browser-connection" : `docker-git-browser-connection ${args}`
66+
),
67+
optArgs.map((args) =>
68+
args === undefined ? "/usr/local/bin/browser-connection" : `/usr/local/bin/browser-connection ${args}`
69+
),
70+
optArgs.map((args) =>
71+
args === undefined
72+
? "/usr/local/bin/docker-git-browser-connection"
73+
: `/usr/local/bin/docker-git-browser-connection ${args}`
74+
)
75+
)
76+
77+
fc.assert(
78+
fc.property(browserCommandArbitrary, fc.integer({ min: 1, max: 99999 }), (command, pid) => {
79+
const hidden = buildContainerTasks(
80+
[processOf({ command, pid, ppid: 0, tty: "pts/1" })],
81+
[],
82+
false
83+
)
84+
const shown = buildContainerTasks(
85+
[processOf({ command, pid, ppid: 0, tty: "pts/1" })],
86+
[],
87+
true
88+
)
89+
return hidden.length === 0 && shown.every((t) => t.kind === "system")
90+
})
91+
)
92+
})
93+
94+
5895
it("marks descendants of managed agent pid as agent tasks", () => {
5996
const tasks = buildContainerTasks(
6097
[

0 commit comments

Comments
 (0)