Skip to content

feat(sidebar): 에이전트 목록 우클릭으로 탭 닫기 - #672

Closed
WOULDU-pres wants to merge 1 commit into
devswha:mainfrom
WOULDU-pres:feat/sidebar-tab-close-menu
Closed

WOULDU-pres wants to merge 1 commit into
devswha:mainfrom
WOULDU-pres:feat/sidebar-tab-close-menu

Conversation

@WOULDU-pres

@WOULDU-pres WOULDU-pres commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Change

사이드바 Agents 목록의 에이전트 행을 우클릭하면 메뉴가 열리고, 탭 닫기(Close tab) 를 고르면 그 에이전트가 실행 중인 herdr 탭을 닫습니다. 지금까지는 탭을 닫으려면 그 에이전트를 열고 위쪽 탭 줄로 가야 했고, 탭이 하나뿐인 워크스페이스에서는 탭 줄이 보이지 않아 워크스페이스 메뉴를 거쳐야 했습니다.

설계 규칙 변경: DESIGN.md에는 "PC headers and agent rows have no menu, so they keep the browser's"라고 적혀 있었습니다. 이 PR은 이 규칙 중 에이전트 행 부분을 의도적으로 바꾸고, 문서도 함께 고쳤습니다. 방향이 맞지 않으면 말씀해 주세요.

무엇을 닫는지

  • 행이 가리키는 pane이 속한 herdr 탭을 닫습니다(POST /api/tab/close, 기존 엔드포인트). 새 서버 계약은 없습니다.
  • 탭이 분할되어 있으면 그 옆의 pane도 함께 닫힙니다. 에이전트 행은 pane 하나만 보여 주므로, 이 경우에는 먼저 묻습니다(아래 참고).

언제 묻고, 언제 바로 닫는지

닫기 규칙을 src/lib/tabClose.ts의 tabCloseCost로 빼서 TabStrip과 에이전트 행이 함께 씁니다. TabStrip의 동작은 그대로입니다.

상황 TabStrip 에이전트 행
워크스페이스의 마지막 탭 (워크스페이스도 닫힘) 확인 확인
탭 안의 에이전트가 working / blocked 확인 확인
탭에 pane이 둘 이상 (split) 바로 닫음 확인 (It holds {n} panes, and they all close with it.)
그 밖 바로 닫음 바로 닫음
  • 확인 대화상자의 제목은 이름이 붙은 탭이면 그 이름으로, herdr가 자리 번호로 부르는 탭이면 행의 제목으로 부릅니다. "Tab 1 탭을 닫을까요?" 같은 제목은 나오지 않습니다.
  • 닫은 뒤에는 행이 사라지므로, 워크스페이스 행을 닫을 때와 같이 헤더의 워크스페이스 목록 토글로 포커스를 옮깁니다. 거절되면 대화상자 안에, 바로 닫는 경우에는 에이전트 목록 아래 role="alert" 줄로 6초 동안 보여 줍니다.

여러 PC

Agents 목록은 모든 PC의 에이전트를 함께 보여 줍니다. 메뉴와 대화상자는 그 행이 속한 PC의 MachineContext.Provider 안에서 그려지고, 요청은 useMachineApi().closeTab으로 그 PC에 갑니다. 열린 메뉴는 PC id와 pane/tab id만 들고 있고, 실행할 때 그 PC의 최신 스냅샷을 다시 읽습니다. 다른 곳에서 pane이나 탭이 닫히거나 PC 연결이 끊기면 메뉴와 대화상자도 함께 닫힙니다.

입력 방법

  • 우클릭, 메뉴 키, Shift+F10(포커스된 행)으로 엽니다. 에이전트 행은 드래그하지 않으므로, 브라우저가 길게 누르기를 contextmenu로 보내는 기기에서는 길게 눌러도 열립니다(폰 폭에서는 기존 바텀 시트).
  • 연결되지 않은 PC의 행과 탭 정보가 없는 행은 브라우저 기본 메뉴를 그대로 둡니다.

바뀐 파일

  • src/components/AgentSidebar.tsx, AgentSidebar.css: 행 메뉴, 확인 대화상자, 오류 줄
  • src/lib/tabClose.ts(+ 테스트): 닫기 규칙
  • src/components/TabStrip.tsx: 같은 규칙 사용(동작 변화 없음)
  • src/lib/i18n.{ko,ja,zh}.ts: 새 문자열 1개
  • DESIGN.md, src/AGENTS.md, docs/development.md, CHANGELOG.md(Unreleased → Added)
  • scripts/agent-tab-close-demo-regression.ts: 새 데모 회귀 스크립트, scripts/ci-browser.sh에 등록(ci-browser.test.ts의 스크립트 수 19 → 20)

Validation

  • bun run generate:types --check, bun run typecheck, bun run build, bun run test:unit: 통과
  • HERDR_TEST_MODE=unit bun test ./src/lib/tabClose.test.ts: 마지막 탭, busy, split(에이전트 행에서만), 바로 닫는 경우
  • bun scripts/agent-tab-close-demo-regression.ts (데모 transport, herdr 불필요): 통과
    • 우클릭과 Shift+F10으로 메뉴가 열리고(메뉴 이름 = 에이전트 제목, 항목 = Close tab), Escape로 닫히면 포커스가 행으로 돌아옴
    • 같은 워크스페이스에 두 번째 탭을 만들고, 그 에이전트가 idle이 된 뒤 닫으면 묻지 않고 닫히며 워크스페이스는 남음. 포커스는 워크스페이스 목록 토글로 이동
    • 마지막 탭은 확인을 거침. 제목은 Close tab Idempotent payments?, 본문은 last-tab 문구. 취소하면 그대로 남고 포커스가 행으로 돌아옴. 확인하면 에이전트 행과 워크스페이스 행이 함께 사라짐
    • page error 없음
  • bun scripts/sidebar-activity-demo-regression.ts: 통과(기존 Agents 목록 동작 회귀 없음)
  • bun scripts/ui-regression.ts (격리 세션 herdr-web-ui-test, herdr 0.9.3): Safari IME 재생 검사(terminal-safari-ime-regression.ts) 하나를 빼고 92개 PASS
    • TabStrip 리팩터 확인: PASS a tab is renamed by a double-click, F2 and its menu, and closed from its x and Delete, asking first while its agent works
    • Agents 목록 확인: PASS Agents excludes shells, survives PC folds, selects its machine target and disables offline rows
    • terminal-safari-ime-regression.ts는 이 PC(WSL2, lockfile의 Playwright Chromium)에서 이 PR 이전의 origin/main(13ca352)에서도 똑같이 실패합니다('abcㅎ' !== 'abc', provisional Hangul must stay local). 이 PR과는 무관한 실패라 그 검사만 빼고 나머지를 끝까지 돌렸습니다.

검증 범위:

  • 브라우저에서 확인: 메뉴, Escape, Shift+F10, 바로 닫기, 마지막 탭 확인, 닫은 뒤 포커스 이동
  • 단위 테스트로만 확인: 에이전트 행에서 시작한 split과 busy 확인 분기. 데모 transport는 기존 탭을 분할하는 방법이 없고, 데모 workspace는 탭이 하나뿐이라 busy보다 last가 먼저 걸립니다.
  • 확인하지 않음: 지금 열려 있는 pane의 탭을 에이전트 행에서 닫는 경우. 데모의 /api/tab/close는 focus를 갱신하지 않습니다. 이 경우는 선택된 pane이 스냅샷에서 사라질 때 herdr의 focus로 돌아가는 App의 기존 동작에 맡깁니다.

스크린샷(데모 세션, 1280×800 @2x):

우클릭 메뉴 마지막 탭 확인
에이전트 행 우클릭 메뉴 마지막 탭 확인 대화상자
English UI
Right-click menu Last-tab confirm
Agent row right-click menu Last-tab confirm dialog

🤖 Generated with Claude Code

사이드바 Agents 목록의 행을 우클릭(메뉴 키, Shift+F10 포함)하면 "탭 닫기"
메뉴가 열리고, 그 에이전트가 실행 중인 herdr 탭을 닫는다.

- 닫기 규칙을 lib/tabClose.ts(tabCloseCost)로 빼서 TabStrip과 함께 쓴다.
  워크스페이스의 마지막 탭이거나 작업 중인 에이전트가 있으면 먼저 묻고,
  에이전트 행에서는 탭에 다른 패널이 함께 있을 때도 묻는다.
- 요청은 그 행이 속한 PC의 MachineContext 안에서 useMachineApi로 보낸다.
- 연결되지 않은 PC의 행은 브라우저 기본 메뉴를 그대로 둔다.
- 데모 회귀 스크립트(agent-tab-close-demo-regression.ts)를 추가하고
  CI 브라우저 레인에 등록했다.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b1665f5c-6ed3-4165-944b-d88516bc3d4e

📥 Commits

Reviewing files that changed from the base of the PR and between 13ca352 and a8be65d.


📒 Files selected for processing (15)
  • CHANGELOG.md
  • DESIGN.md
  • docs/development.md
  • scripts/agent-tab-close-demo-regression.ts
  • scripts/ci-browser.sh
  • scripts/ci-browser.test.ts
  • src/AGENTS.md
  • src/components/AgentSidebar.css
  • src/components/AgentSidebar.tsx
  • src/components/TabStrip.tsx
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/tabClose.test.ts
  • src/lib/tabClose.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Summary

Summary by CodeRabbit

  • New Features
    • Open an agent’s context menu with a right-click, the menu key, Shift+F10, or a supported long-press, then choose Close tab.
    • Tabs close immediately when safe. A confirmation appears when closing would remove the workspace’s last tab, affect a working or blocked agent, or close multiple panes.
    • Close failures appear beneath the agent row and clear after six seconds.
  • Bug Fixes
    • Tab-close confirmations now account for the same conditions across agent menus and the tab strip.

Walkthrough

Agent rows now provide a menu to close their tab. A shared helper determines when closing needs confirmation, and the tab strip uses the same rules. A browser regression script checks menu access, immediate closure, and last-tab confirmation.

Changes

Agent Tab Close

Layer / File(s) Summary
Shared tab-close rules
src/lib/tabClose.ts, src/components/TabStrip.tsx, src/lib/tabClose.test.ts
Adds tabCloseCost for last tabs, busy agents, and split panes. The tab strip uses this helper, and tests cover the returned costs.
Agent-row menu and close action
src/components/AgentSidebar.tsx, src/components/AgentSidebar.css, src/lib/i18n.*.ts, src/AGENTS.md, DESIGN.md, CHANGELOG.md
Adds agent-row context-menu access and a Close tab action. The action uses the target machine’s roster, prompts when tabCloseCost returns a cost or panes share the tab, and reports errors for six seconds. Documentation and translations describe the behavior.
Browser regression coverage
scripts/agent-tab-close-demo-regression.ts, scripts/ci-browser.sh, scripts/ci-browser.test.ts, docs/development.md
Adds browser checks for menu access, immediate closure of an idle second tab, and confirmation before closing the last tab. Adds the script to the browser CI lane and documents the command.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: devswha, phirschybar


Merge Risk

Merge Risk: ⚪ Minimal · up to a8be6

The agent-row close flow is mergeable after normal checks; the reported focus jump does not occur on ordinary menu dismissal.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a8be6

The new action preserves the selected row’s machine and tab identity and uses the existing access controls. No expanded close authority was established. Concurrent changes and interrupted close requests still have recovery limitations, so the assessment is not risk-free.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A single row action targets one tab on its originating machine, potentially stopping every pane in that tab and removing its workspace if it is the last tab. The inspected flow does not fan out to other machines or accept an arbitrary destination URL.

Trust Boundaries and Controls

  • observed — The existing server gates API access by identity, rejects watch-device mutations and disallowed origins, and checks the machine-request header for remote mutations. Remote forwarding uses the configured endpoint credential rather than forwarding browser cookies or browser Authorization. The PR leaves these controls unchanged.

Resilience and Maintainability Implications

  • observed — Confirmation retains its initial cost category while the target remains alive, so concurrent changes can alter the consequences before execution. The base tab strip already had snapshot-derived confirmation without an execution precondition. Available code delegates execution to external herdr and does not establish lost-response or idempotent-retry semantics; these are limitations, not verified new security failures.

Hardening Proposals

  • proposed — If confirmation is intended to guarantee a specific destructive scope under concurrent changes, consider a shared consequence-revalidation policy and a backend precondition. Document repeated-close and interrupted-response semantics before relying on retries as recovery.



🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 10 files. (5 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the primary change: closing tabs by right-clicking an agent in the sidebar Agents list.
Description check Passed The description includes the required Change and Validation sections. It explains the behavior, close rules, affected files, test results, known validation limits, and UI screenshots.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 10 files. (5 skipped: 5 unsupported.)



  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thanks for this. The problem it set out to solve, that a workspace with one tab had no tab strip to close it from, is fixed on main by #747: the strip is always shown, and the pane canvas has Close pane in each pane's menu. #747 also settled that Agents rows stay selection-only, so a close action there goes against the current design. Closing for those reasons.

@devswha devswha closed this Oct 11, 2026
@WOULDU-pres
WOULDU-pres deleted the feat/sidebar-tab-close-menu branch October 11, 2026 07:34
devswha added a commit that referenced this pull request Oct 11, 2026
## Change

사이드바 **Agents** 목록에서 같은 워크스페이스의 에이전트를 **테두리 카드** 하나로 묶습니다. 지금도
Workspaces 순서에서는 같은 워크스페이스의 에이전트가 붙어 있지만, 경계가 보이지 않습니다. 그래서 행마다 두 번째 줄에
워크스페이스 이름이 반복되고, 어디까지가 한 워크스페이스인지 이름을 읽어야만 알 수 있었습니다.

### 모습

- 카드는 `--hairline` `--border` 테두리, `--radius-lg`, 안쪽 여백 `--space-1`, 카드
사이 `--space-2`이고 **채움은 없습니다**. 그래서 행의 hover와 선택 채움이 카드 밖에서와 똑같이 보입니다.
- 카드에 채움을 깔면 hover 채움(bg-hover 50%)과 세기가 비슷해져서 안에서 hover가 흐려지기 때문에, 테두리만
썼습니다.
- 카드 머리글은 `--space-6` 높이의 한 줄입니다. 앞 칸에 `--space-4` 폴더, 그 옆에 워크스페이스 이름을
`--text-dim` `--fs-xs`로 씁니다. PC가 2대 이상이면 `PC · 워크스페이스`로 씁니다(지금 두 번째 줄의
규칙과 같습니다).
- 머리글은 이름일 뿐 **컨트롤이 아닙니다**. 행은 pane을 열고, 워크스페이스는 위쪽 목록이 엽니다.
- 에이전트가 하나뿐인 워크스페이스도 카드로 묶습니다. 모양을 일관되게 하려는 것입니다.

### 두 번째 줄

- 카드 안의 행은 두 번째 줄에서 PC와 워크스페이스를 뺍니다. 예: `claude · checkout-api · Tab 1`
→ `claude · Tab 1`
- 위치 정보는 사라지지 않습니다. 툴팁에는 그대로 남고, 스크린리더에서는 카드의 목록이 머리글을 이름으로 갖습니다(`<ul
aria-labelledby>`).
- 규칙은 `agentContext`의 `grouped` 옵션입니다. 탭 이름이 워크스페이스 이름과 같으면 지금처럼 생략합니다.

### Activity 순서

**Activity** 순서는 워크스페이스를 섞어 놓으므로 카드를 그리지 않습니다. 지금처럼 평평한 목록이고, 행마다 자기 위치를
씁니다. 묶음을 유지하면서 묶음 순서를 바꾸는 방법도 검토했습니다. 하지만 그러면 "가장 최근 것이 위"라는 Activity의
의미가 깨져서 하지 않았습니다.

### 바뀐 파일

- `src/lib/sidebarAgents.ts`(+ 테스트): `groupRows`(키별로 묶되 첫 행의 자리를 지킴),
`agentContext`의 `grouped`
- `src/components/AgentSidebar.tsx`, `AgentSidebar.css`: 카드와 머리글. 행 그리기를
`agentItem`으로 뺐습니다(행 DOM, `data-machine`/`data-pane`, 클래스는 그대로입니다).
- `scripts/sidebar-activity-demo-regression.ts`: 카드 확인을 추가했습니다(아래
Validation).
- `DESIGN.md`, `src/AGENTS.md`, `CHANGELOG.md`(Unreleased → Changed)

새 `t()` 문자열, 서버 계약, 설정 항목은 없습니다.

### #672와의 관계

#672(에이전트 행 우클릭으로 탭 닫기)도 `AgentSidebar.tsx`를 크게 고칩니다. 먼저 머지되는 쪽에 맞춰 나머지를
rebase하겠습니다. 합칠 때는 #672의 행 메뉴 부제목(`RowMenu subtitle`)이 줄어든 `context`가
아니라 전체 위치(`place`)를 써야 합니다. 그래야 카드 안 행의 메뉴에도 워크스페이스 이름이 나옵니다.

## Validation

- `bun run check fast`: 통과(workflow syntax, generated types, typecheck,
build, unit tests 2012 pass / 0 fail)
- `HERDR_TEST_MODE=unit bun test ./src/lib/sidebarAgents.test.ts`: 17
pass
- `groupRows`: herdr가 pane을 어떤 순서로 주든 워크스페이스마다 묶음이 하나이고 herdr의 순서를 지킴. 첫
행의 자리와 묶음 안 순서를 지킴
  - `agentContext` `grouped`: PC와 워크스페이스를 빼고, 탭이 워크스페이스와 같으면 여전히 생략
- `bun scripts/sidebar-activity-demo-regression.ts`(데모 transport, herdr
불필요): 통과
- 기본(Workspaces) 순서: 카드 이름이 `checkout-api, web-dashboard, infra,
docs-site, cli-tools`. 카드 안 행의 두 번째 줄에는 워크스페이스가 없고, 툴팁에는 있음. 카드의 목록이
머리글로 레이블됨
  - Activity 순서: 카드 0개, 행의 두 번째 줄에 워크스페이스가 있음
  - 기존 순서와 DONE 검사 그대로 통과
- `bun run check run bun scripts/ui-regression.ts`(격리 herdr 세션): 93개 모두
PASS
- Agents 목록 확인: `PASS Agents excludes shells, survives PC folds, selects
its machine target and disables offline rows`(카드 안 행의 선택, PC 대상, 오프라인
비활성)

검증 범위:

- **브라우저에서 확인:** PC 1대일 때의 카드, 머리글, 두 번째 줄, aria-labelledby. Activity에서
카드가 없는 것. 다크와 라이트 테마. 한국어 UI
- **단위 테스트로만 확인:** 묶음 로직과 두 번째 줄 규칙
- **확인하지 않음:** PC 2대일 때의 `PC · 워크스페이스` 머리글을 브라우저로 보지 않았습니다. 데모는 PC가
1대뿐입니다.

스크린샷(데모 세션, 1280×1000 @2x, checkout-api에 탭 두 개와 에이전트 두 개를 더 띄운 상태):

| Workspaces 순서 (다크) | Workspaces 순서 (라이트) | Activity 순서 (카드 없음) |
| --- | --- | --- |
| <img width="320" alt="Agents 목록: checkout-api 카드에 에이전트 셋, 나머지 워크스페이스는
하나씩"
src="https://github.com/user-attachments/assets/df722183-810a-42d5-a567-102502b00b4e"
/> | <img width="320" alt="라이트 테마의 같은 화면"
src="https://github.com/user-attachments/assets/d00cc2fd-727e-422b-8058-b67c6196d56e"
/> | <img width="320" alt="Activity 순서: 카드 없이 평평한 목록, 행마다 워크스페이스를 씀"
src="https://github.com/user-attachments/assets/91e8e373-3cc0-4729-bdfc-1b364dc668e0"
/> |

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Hako <[email protected]>
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.

2 participants