Skip to content

test(agent): pin the agent container terminal - AgentTerminal (Closes #1692) - #1972

Merged
dmitrii-f-t27 merged 1 commit into
queenfrom
zcode-mbp/tests-1692-agent-terminal
Oct 14, 2026
Merged

dmitrii-f-t27 merged 1 commit into
queenfrom
zcode-mbp/tests-1692-agent-terminal

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Collaborator

Closes #1692

What

The first suite for apps/agent/entrypoints/app/agents/AgentTerminal.tsx (AgentTerminal, the only export), under bun test in the agent group.

  • describe block: AgentTerminalTsxContract (appears nowhere else in the tree).
  • No stubs at all: the entire terminal β€” the xterm instance with its fit and web-links addons, the PTY websocket, the resize and theme observers, the clipboard flow β€” lives inside one mount effect a static render never runs, so the render itself needs nothing mocked; the xterm modules and even their CSS import load cleanly under bun, and the shared container constants plus the agent-server URL helper module stay real.
  • Pin: the first mount answers the terminal title (Container Terminal), the shell line naming the container home through the real shared constant, the shell bar with the home directory and the shell basename, and the copy button in its un-copied state. Everything the effect owns is named in the suite header per User Story 2.
  • FR-004 shown both ways, quoted: broken subject (title relabelled) β†’ 0 pass / 1 fail; restored β†’ 1 pass / 0 fail / 6 expect(). git diff --name-only lists only the new test file.

Local gates

  • Suite: 1 pass / 0 fail (6 expect()); grep -c 'it(' = 1; 1 + 0 blocked = 1. (A first draft asserted the shell basename via .split('/') β€” split( contains it( and the grep would have counted 2; derived with slice/lastIndexOf instead.)
  • Group (apps/agent): 263 pass / 3 fail / 266 tests β€” the 3 = the pre-existing port-helper noise, unchanged from baseline.
  • Biome: 0. Typecheck: 19 = base, 0 mentions of the new file.

No database, no container, no network.

@tri-claw

tri-claw Bot commented Oct 14, 2026

Copy link
Copy Markdown

Summary by t27-bees

This PR adds a contract test for AgentTerminal.tsx that pins the component's initial static render output (before the mount effect runs). The test verifies the terminal title, shell line with container home path, shell bar with home directory and shell basename, and the copy button's initial "Copy" state.

Worth a look

  • AgentTerminal.test.ts:18 β€” process.env.VITE_BROWSEROS_SERVER_PORT ??= '4321' is set at module level before imports. While bun runs test files in isolated processes, this env mutation could leak if the test runner ever changes to reuse processes, and it forces a specific port value that may conflict with other test suites needing different ports.
  • AgentTerminal.test.ts:22-23 β€” The dynamic import import('./AgentTerminal?agent-terminal-suite-real') relies on Vite/bun's query-parameter module reloading to get a fresh instance. If the test runner doesn't honor this query parameter (e.g., different bundler mode), the module cache may not reset, causing state bleed between tests.
  • AgentTerminal.test.ts:23 β€” The type assertion as typeof import('./AgentTerminal') suppresses type errors if the module's exports change. A breaking change to AgentTerminal's export (e.g., renamed or removed) would only surface at runtime.
  • AgentTerminal.test.ts:27-38 β€” The test only asserts on renderToStaticMarkup output, which executes no mount effects. The entire terminal logic (xterm, PTY websocket, observers, clipboard) lives in a useEffect that never runs here. This pins only the static shell, not the actual terminal behavior described in the issue.
  • AgentTerminal.test.ts:34 β€” OPENCLAW_TERMINAL_SHELL.slice(OPENCLAW_TERMINAL_SHELL.lastIndexOf('/') + 1) derives the shell basename. If the constant changes to a path without / (e.g., just "bash"), lastIndexOf returns -1, slice(0) returns the full string, and the test passes silently with a weaker assertion.

Read: 1 files, +72 -0, the whole diff. Head 914a9a2. Model: openai-compatible/nvidia/nemotron-3-ultra-550b-a55b. Commands: @t27-bees review | summary | help | pause | resume. Free for every repository.

@github-actions

Copy link
Copy Markdown

βœ… Tests passed β€” 3638/3708

Suite Passed Failed Skipped
βœ… agent 266/266 0 0
βœ… build 9/9 0 0
βœ… cdp-protocol 5/5 0 0
βœ… eval 93/93 0 0
βœ… server-agent 280/280 0 0
βœ… server-api 2159/2228 0 69
βœ… server-browser 6/6 0 0
βœ… server-integration 10/11 0 1
βœ… server-lib 279/279 0 0
βœ… server-pglive 166/166 0 0
βœ… server-root 68/68 0 0
βœ… server-sim 8/8 0 0
βœ… server-skills 31/31 0 0
βœ… server-tools 244/244 0 0
βœ… shared 14/14 0 0

View workflow run

@dmitrii-f-t27
dmitrii-f-t27 merged commit 95b3932 into queen Oct 14, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant