Skip to content

Commit d87df8e

Browse files
authored
'Почему-то запущено много сесий с контейнером браузера' (#387)
* 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
1 parent fbc50eb commit d87df8e

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ 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).
33+
const browserConnectionPattern = /(?:^|\/)(?:docker-git-browser-connection|browser-connection)\b/u
34+
35+
const commandSuggestsBrowserHelper = (command: string): boolean => browserConnectionPattern.test(command)
36+
3037
const resolveAncestorManagedId = (
3138
process: RawContainerProcess,
3239
pidToProcess: ReadonlyMap<number, RawContainerProcess>,
@@ -49,6 +56,9 @@ const classifyProcess = (
4956
process: RawContainerProcess,
5057
managedId: string | undefined
5158
): ContainerTaskKind => {
59+
if (commandSuggestsBrowserHelper(process.command)) {
60+
return "system"
61+
}
5262
if (managedId !== undefined || commandSuggestsAgent(process.command)) {
5363
return "agent"
5464
}
@@ -78,7 +88,7 @@ const compareTasks = (left: ContainerTask, right: ContainerTask): number => {
7888
// FORMAT THEOREM: forall p in Processes: classify(p) in ContainerTaskKind
7989
// PURITY: CORE
8090
// EFFECT: none
81-
// INVARIANT: includeDefault=false excludes only baseline system processes
91+
// INVARIANT: includeDefault=false excludes system processes (baseline + browser helpers)
8292
// COMPLEXITY: O(n * h) where h is maximum process ancestry depth
8393
export const buildContainerTasks = (
8494
processes: ReadonlyArray<RawContainerProcess>,

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,30 @@ describe("container task classification", () => {
3131
.toHaveLength(1)
3232
})
3333

34+
it("hides browser-connection MCP helpers as internal system tasks", () => {
35+
const browserCommand =
36+
"browser-connection --project dg-docker-git-issue-376 --network container:dg-docker-git-issue-376"
37+
const visible = buildContainerTasks(
38+
[
39+
processOf({ command: browserCommand, pid: 11502, ppid: 5142, tty: "pts/1" }),
40+
processOf({ command: "/usr/local/bin/docker-git-browser-connection start", pid: 11600, ppid: 5142, tty: "pts/1" }),
41+
processOf({ command: "node server.js", pid: 20, ppid: 1, tty: "pts/2" })
42+
],
43+
[],
44+
false
45+
)
46+
47+
expect(visible.map((task) => task.pid)).toEqual([20])
48+
49+
const withSystem = buildContainerTasks(
50+
[processOf({ command: browserCommand, pid: 11502, ppid: 5142, tty: "pts/1" })],
51+
[],
52+
true
53+
)
54+
55+
expect(withSystem.map((task) => [task.pid, task.kind])).toEqual([[11502, "system"]])
56+
})
57+
3458
it("marks descendants of managed agent pid as agent tasks", () => {
3559
const tasks = buildContainerTasks(
3660
[

0 commit comments

Comments
 (0)