Compare commits
2 Commits
feature/sp
...
hotfix/pro
| Author | SHA1 | Date | |
|---|---|---|---|
| 41edaec62e | |||
| 09162ee42d |
@@ -1,86 +1,45 @@
|
|||||||
# 하나랑 대시보드 — 실행 개요
|
# 하나랑 대시보드 — 프로젝트 개요
|
||||||
|
|
||||||
## 프로젝트 목표
|
## 목표
|
||||||
- 4자매 운영 상태를 실제 source-of-truth 기준으로 보여준다
|
4자매 멀티에이전트 파이프라인 관제 대시보드.
|
||||||
- 프로젝트, Sprint, Hotfix, QA, Deploy 흐름을 한 운영 정보 구조로 연결한다
|
자기야가 한눈에 전체 현황을 파악하고 관리할 수 있는 화면.
|
||||||
- `main`이 항상 배포 가능 상태라는 원칙을 UI와 운영 문서에 같이 반영한다
|
|
||||||
- `/office`, `/`, `/projects/[id]`, `/org`가 서로 다른 역할을 가지되 같은 상태 계약을 공유하게 만든다
|
|
||||||
|
|
||||||
## 저장소 / Git 기준
|
## 기술 스택
|
||||||
- Repo: `hanarang-dashboard`
|
|
||||||
- Git URL: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- 기본 브랜치: `main`
|
|
||||||
- 현재 구현 기준 경로:
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- `frontend/app/org/page.tsx`
|
|
||||||
- `backend/src/sisters/sisters.service.ts`
|
|
||||||
- `backend/src/sisters/sister-detail.service.ts`
|
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
|
||||||
|
|
||||||
## 현재 상태
|
| 레이어 | 기술 | 비고 |
|
||||||
- **SPRINT-016**: `/office` 기본 화면과 핵심 컴포넌트가 `main`에 반영됨
|
|--------|------|------|
|
||||||
- **SPRINT-017**: `/office` 모바일 IA와 direct chat 중심 재배치 범위를 문서로 잠금
|
| Frontend | Next.js + styled-components | styled-components는 return 아래에 적재 |
|
||||||
- **HOTFIX-006**: 메인 대시보드 문구 절제와 source/freshness 정합성 보정 범위를 잠금
|
| Backend | Nest.js + Prisma | REST API |
|
||||||
- **다음 활성 작업**: **SPRINT-018** 대시보드 truth redesign
|
| DB | MariaDB | Docker LXC 103 (10.10.10.146:33006) |
|
||||||
|
| 도메인 (FE) | `hanarang.nabomhalang.co.kr` | Nginx LXC 101에서 프록시 |
|
||||||
|
| 도메인 (BE) | `hanarang-api.nabomhalang.co.kr` | Nginx LXC 101에서 프록시 |
|
||||||
|
|
||||||
## SPRINT-018 active scope
|
## 아키텍처
|
||||||
이번 Sprint는 단순 모바일 정리가 아니라, `/office`, `/`, `/projects/[id]`, `/org`를 **같은 운영 사실 계약**으로 다시 잠그는 작업이야.
|
|
||||||
|
|
||||||
### 이번에 반드시 해결할 것
|
```
|
||||||
1. 페이지 역할을 고정한다.
|
[사용자] → hanarang.nabomhalang.co.kr → [Nginx LXC 101] → [Next.js FE :3004]
|
||||||
- `/office`: live operations workspace
|
↓ API 호출
|
||||||
- `/`: executive snapshot
|
[사용자] → hanarang-api.nabomhalang.co.kr → [Nginx LXC 101] → [Nest.js BE :3005]
|
||||||
- `/projects/[id]`: delivery detail
|
↓ SSH
|
||||||
- `/org`: company org map
|
[4자매 LXC 서버]
|
||||||
2. 공통 용어를 고정한다.
|
↓ API
|
||||||
- `connection`, `activity`, `working`, `owner`, `participant`, `assignee`, `freshness`, `source`
|
[Gitea API]
|
||||||
3. `working`, `owner`, `participant`를 추정치와 확정치를 섞지 않게 다시 정의한다.
|
↓
|
||||||
4. `fallback`, `snapshot`, `live`가 같은 사실처럼 보이지 않게 규칙을 문서화한다.
|
[MariaDB LXC 103]
|
||||||
5. `360px`, `390px` 기준으로 긴 문장, 긴 badge, 카드 overflow, horizontal scroll을 금지한다.
|
```
|
||||||
6. `/office`는 기존 office group mental model 장점을 살리되, 4개 긴 박스 분해형이 아니라 group/scene/context 중심으로 재배치한다.
|
|
||||||
7. `/projects/[id]`의 `ASSIGNED NODES`를 truthful participant model로 교체한다.
|
|
||||||
8. `/org`는 자매 트리 데모가 아니라 실제 회사형 조직도 + independent agents 구조로 재설계한다.
|
|
||||||
|
|
||||||
### 이번에 하지 않을 것
|
## 자매 서버 정보
|
||||||
- ACP harness 자체 구조 변경
|
| 이름 | IP | 사용자 | LXC |
|
||||||
- WebSocket 프로토콜 재설계
|
|------|-----|--------|-----|
|
||||||
- 별도 모바일 앱 설계
|
| 하랑이 | 10.10.10.112 | harang | 104 |
|
||||||
- 실제 배포 자동화 플로우 재작성
|
| 나랑이 | 10.10.10.216 | narang | 105 |
|
||||||
- 조직도용 신규 비주얼 엔진 도입
|
| 다랑이 | 10.10.10.136 | darang | 106 |
|
||||||
|
| 이랑이 | 10.10.10.163 | erang | 107 |
|
||||||
|
|
||||||
## truth redesign 원칙
|
## 디자인 방향
|
||||||
- `360px`, `390px`에서 카드와 badge는 줄바꿈되어야 하고 horizontal scroll이 없어야 한다
|
- 다크 테마 관제 화면
|
||||||
- websocket 연결 여부와 데이터 최신성은 같은 뜻으로 쓰지 않는다
|
- 카드 기반 레이아웃
|
||||||
- `working`은 단순 `thinking/tool_calling/speaking + gatewayConnected`의 프론트 추정치로 고정하지 않는다
|
- 상태 색상: 온라인=초록(#00E676), 오프라인=빨강(#FF1744), 작업중=파랑(#2979FF)
|
||||||
- `owner`, `participant`, `assignee`는 같은 사람 목록으로 재사용하지 않는다
|
- glassmorphism 포인트
|
||||||
- fallback seed는 확정 owner, working, participant를 주입하지 않는다
|
- 미니멀 아이콘
|
||||||
- null/empty 상태도 사실대로 보여준다
|
- 정보 밀도 높은 UI
|
||||||
|
|
||||||
## breakpoint 기준
|
|
||||||
- **Mobile compact:** `360px`
|
|
||||||
- **Mobile default:** `390px`
|
|
||||||
- **Tablet:** `768px`
|
|
||||||
- **Desktop:** `1280px+`
|
|
||||||
|
|
||||||
## 문서 맵
|
|
||||||
- 구조 기준: `../ARCHITECTURE.md`
|
|
||||||
- 제품 PRD: `../docs/product-specs/openclaw-office-dashboard-prd.md`
|
|
||||||
- Sprint 017: `./sprints/SPRINT-017.md`
|
|
||||||
- Sprint 018: `./sprints/SPRINT-018.md`
|
|
||||||
- HOTFIX-006: `./hotfix/HOTFIX-006.md`
|
|
||||||
- API / truth contract: `./design/api-design.md`
|
|
||||||
- `/office` UI: `./design/ui/office-dashboard-design.md`
|
|
||||||
- `/office` chat 기준: `./design/ui/office-chat-design.md`
|
|
||||||
- `/` UI: `./design/ui/dashboard-design.md`
|
|
||||||
- `/projects/[id]` UI: `./design/ui/project-detail-design.md`
|
|
||||||
- `/org` UI: `./design/ui/org-design.md`
|
|
||||||
- QA draft: `./qa/SPRINT-018-review-1.md`
|
|
||||||
|
|
||||||
## 교차 참조 규칙
|
|
||||||
- Sprint 문서는 관련 design, QA, hotfix 문서를 반드시 링크한다
|
|
||||||
- design 문서는 실제 구현 파일 경로와 breakpoint를 함께 적는다
|
|
||||||
- API, UI, QA 문서에서 `working / owner / participant / source / freshness` 의미를 동일하게 쓴다
|
|
||||||
- `live / mirrored event / snapshot / doc-derived / fallback` source 라벨은 페이지 간 동일하게 쓴다
|
|
||||||
- 여기까지가 SPRINT-018 기준 scope야.
|
|
||||||
|
|||||||
@@ -20,13 +20,10 @@
|
|||||||
|
|
||||||
## PM2 설정
|
## PM2 설정
|
||||||
```
|
```
|
||||||
backend: pm2 start backend/dist/src/main.js --name hanarang-api --cwd /path/to/hanarang-dashboard --env production
|
backend: pm2 start dist/main.js --name hanarang-api --env production
|
||||||
frontend: pm2 start npm --name hanarang-web --cwd /path/to/hanarang-dashboard/frontend -- start -- -p 3004
|
frontend: pm2 start npm --name hanarang-web -- start -- -p 3004
|
||||||
```
|
```
|
||||||
|
|
||||||
- backend 엔트리포인트는 실제 Nest 빌드 산출물 기준 `backend/dist/src/main.js`를 사용해.
|
|
||||||
- repo 루트에서 실행하면 `--cwd`를 명시해서 PM2가 올바른 작업 디렉터리를 잡도록 해.
|
|
||||||
|
|
||||||
## SSH 키 배포
|
## SSH 키 배포
|
||||||
- Dev 서버(10.10.10.169)에서 4자매 서버로 SSH 접속할 수 있도록 키 배포 필요
|
- Dev 서버(10.10.10.169)에서 4자매 서버로 SSH 접속할 수 있도록 키 배포 필요
|
||||||
- 이랑이가 SSH 키 생성 + 각 자매 서버에 authorized_keys 추가
|
- 이랑이가 SSH 키 생성 + 각 자매 서버에 authorized_keys 추가
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
# Main Release Flow
|
|
||||||
|
|
||||||
## 원칙
|
|
||||||
- `main` = 배포 가능 상태
|
|
||||||
- 다랑 QA가 끝나기 전에는 `main` merge 금지
|
|
||||||
- 이랑은 feature branch를 배포하지 않고, QA 통과 후 merge된 최신 `main`만 배포
|
|
||||||
|
|
||||||
## 역할별 절차
|
|
||||||
### 1. 하랑
|
|
||||||
- 문서 작성 및 선 push
|
|
||||||
- 나랑/다랑/이랑 핸드오프 관리
|
|
||||||
- QA 결과 확인
|
|
||||||
- `main` merge 최종 판단
|
|
||||||
|
|
||||||
### 2. 나랑
|
|
||||||
- feature/hotfix branch에서 구현
|
|
||||||
- 구현 후 원격 branch push
|
|
||||||
- 다랑에게 QA 요청
|
|
||||||
|
|
||||||
### 3. 다랑
|
|
||||||
- 나랑 branch pull
|
|
||||||
- QA 수행
|
|
||||||
- `.plans/qa/`에 결과 md 작성
|
|
||||||
- `passed/failed + errors[]`를 하랑에게 전달
|
|
||||||
|
|
||||||
### 4. 하랑
|
|
||||||
- `passed = true` 확인 후 `main` merge
|
|
||||||
- merge 완료 시점부터 `main`은 배포 상태
|
|
||||||
- 이랑에게 재배포 요청
|
|
||||||
|
|
||||||
### 5. 이랑
|
|
||||||
- 서버에서 최신 `main` pull
|
|
||||||
- install/build/restart 등 재배포만 수행
|
|
||||||
- 추가 수정 없이 운영 반영
|
|
||||||
|
|
||||||
## 금지
|
|
||||||
- QA 전 `main` merge
|
|
||||||
- 이랑이 feature branch 직접 배포
|
|
||||||
- QA 결과 없는 배포
|
|
||||||
- 문서 없이 긴급 hotfix 진행
|
|
||||||
@@ -1,280 +1,71 @@
|
|||||||
# API 설계 — SPRINT-018 truth contract
|
# API 설계
|
||||||
|
|
||||||
## 목적
|
|
||||||
SPRINT-018 기준 API 문서는 `/office`, `/`, `/projects/[id]`, `/org`가 같은 운영 사실 계약을 공유하도록 잠그는 문서야. 기존 SPRINT-017의 `REST snapshot + WebSocket push` 모델은 유지하지만, 이번에는 `connection`, `activity`, `working`, `freshness`, `source`를 분리해서 정의한다.
|
|
||||||
|
|
||||||
## 참고 문서
|
|
||||||
- 실행 개요: `../OVERVIEW.md`
|
|
||||||
- Sprint: `../sprints/SPRINT-018.md`
|
|
||||||
- HOTFIX-006: `../hotfix/HOTFIX-006.md`
|
|
||||||
- UI 문서:
|
|
||||||
- `./ui/office-dashboard-design.md`
|
|
||||||
- `./ui/dashboard-design.md`
|
|
||||||
- `./ui/project-detail-design.md`
|
|
||||||
- `./ui/org-design.md`
|
|
||||||
|
|
||||||
## 공통 규칙
|
## 공통 규칙
|
||||||
- Base URL: `https://hanarang-api.nabomhalang.co.kr`
|
- Base URL: `https://hanarang-api.nabomhalang.co.kr`
|
||||||
- 응답 형식: JSON
|
- 응답 형식: JSON
|
||||||
- WS Namespace: `/ws`
|
- 인증: MVP에서는 인증 없음 (내부망 전용). 추후 JWT 추가 가능.
|
||||||
- 기본 에러 형식: `{ "statusCode": 400, "message": "...", "error": "Bad Request" }`
|
- 에러 형식: `{ "statusCode": 400, "message": "...", "error": "Bad Request" }`
|
||||||
- 읽기 API와 쓰기 API 권한은 분리해서 다룬다
|
|
||||||
|
|
||||||
## source taxonomy
|
## Sisters (자매 상태)
|
||||||
| source | 의미 | UI 규칙 |
|
|
||||||
|---|---|---|
|
|
||||||
| `live` | runtime 또는 websocket 기준 최신 상태 | 가장 강한 source |
|
|
||||||
| `mirrored_event` | event stream을 dashboard용으로 미러링한 상태 | live처럼 과장하지 않음 |
|
|
||||||
| `snapshot` | polling / REST 스냅샷 | 최신 시각과 같이 표시 |
|
|
||||||
| `doc_derived` | QA/HOTFIX/문서에서 파생한 값 | 운영 기록으로 표시 |
|
|
||||||
| `fallback` | 원본 없음, seed/default/보정 데이터 | 추정치임을 숨기지 않음 |
|
|
||||||
|
|
||||||
## 용어 계약
|
| Method | Endpoint | 설명 |
|
||||||
| 필드 | 의미 | 비고 |
|
|--------|----------|------|
|
||||||
|---|---|---|
|
| GET | `/api/sisters` | 4자매 상태 목록 (SSH로 실시간 조회) |
|
||||||
| `connection` | 연결 상태 | socket/gateway/runtime 가능 여부 |
|
| GET | `/api/sisters/:name` | 자매 상세 (설정 + 상태) |
|
||||||
| `activity` | 최근 활동 상태 | event/session/task evidence |
|
| GET | `/api/sisters/:name/config` | openclaw.json 내용 |
|
||||||
| `working` | 명시적 운영 상태 | 추정치와 확정치를 분리 |
|
| GET | `/api/sisters/:name/sessions` | 최근 세션 목록 |
|
||||||
| `freshness` | 생성/동기화 시각 | source와 별도 필드 |
|
| GET | `/api/sisters/:name/subagents` | 서브에이전트 사용 현황 |
|
||||||
| `source` | 값의 출처 | field-level 또는 section-level |
|
| POST | `/api/sisters/:name/restart` | Gateway 재시작 (관리자) |
|
||||||
|
| POST | `/api/sisters/:name/reset` | 세션 리셋 (관리자) |
|
||||||
## 공통 view-model 규칙
|
|
||||||
### 1. 연결과 활동을 분리한다
|
|
||||||
- `connection.connected=true`여도 `activity.state='idle'`일 수 있다
|
|
||||||
- `connection.connected=false`여도 마지막 `snapshot`은 남아 있을 수 있다
|
|
||||||
|
|
||||||
### 2. `working`은 별도 필드다
|
|
||||||
`working`은 단순히 `thinking/tool_calling/speaking + gatewayConnected` 조합으로 확정하지 않는다.
|
|
||||||
|
|
||||||
권장 형태:
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"working": {
|
|
||||||
"state": "active",
|
|
||||||
"confidence": "confirmed",
|
|
||||||
"reason": "active_session",
|
|
||||||
"label": "PR review in progress"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. fallback은 확정 owner/participant를 주입하지 않는다
|
|
||||||
- fallback은 `owner: null`, `participants: []`를 허용한다
|
|
||||||
- UI는 empty 상태를 그대로 렌더링해야 한다
|
|
||||||
|
|
||||||
### 4. freshness는 최소 2종 이상 준다
|
|
||||||
- `generatedAt`
|
|
||||||
- `lastActiveAt` 또는 `latestEventAt`
|
|
||||||
- 필요 시 `lastSnapshotAt`, `lastDocAt`
|
|
||||||
|
|
||||||
## Sisters / Office contract
|
|
||||||
|
|
||||||
### GET `/api/sisters`
|
### GET `/api/sisters`
|
||||||
`/office`와 `/`가 함께 쓰는 snapshot source다.
|
|
||||||
|
|
||||||
권장 응답 shape:
|
|
||||||
```json
|
```json
|
||||||
|
// Response 200
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "harang",
|
"name": "harang",
|
||||||
"role": "Orchestrator",
|
"displayName": "하랑이",
|
||||||
"connection": {
|
"ip": "10.10.10.112",
|
||||||
"gateway": "connected",
|
"status": "online",
|
||||||
"runtime": "connected"
|
"lastSeen": "2026-04-04T01:45:00Z",
|
||||||
},
|
"role": "Orchestrator"
|
||||||
"activity": {
|
|
||||||
"state": "idle",
|
|
||||||
"label": "No recent operator event",
|
|
||||||
"lastActiveAt": "2026-04-09T01:20:00.000Z"
|
|
||||||
},
|
|
||||||
"working": {
|
|
||||||
"state": "idle",
|
|
||||||
"confidence": "confirmed",
|
|
||||||
"reason": null,
|
|
||||||
"label": null
|
|
||||||
},
|
|
||||||
"source": "snapshot",
|
|
||||||
"freshness": {
|
|
||||||
"lastSnapshotAt": "2026-04-09T01:20:10.000Z"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
### GET `/api/sisters/runtime`
|
## Projects (프로젝트)
|
||||||
runtime 세부 source다.
|
|
||||||
|
|
||||||
최소 필드:
|
| Method | Endpoint | 설명 |
|
||||||
- `gatewayConnected`
|
|--------|----------|------|
|
||||||
- `mainState`
|
| GET | `/api/projects` | 프로젝트 목록 (Gitea API 연동) |
|
||||||
- `currentTask`
|
| GET | `/api/projects/:id` | 프로젝트 상세 + Sprint + Task |
|
||||||
- `activeSessionLabel`
|
| GET | `/api/projects/:id/tasks` | Task Ledger |
|
||||||
- `activeSessionUpdatedAt`
|
| GET | `/api/projects/:id/activity` | 활동 로그 |
|
||||||
- `recentMessages`
|
|
||||||
- `subagents`
|
|
||||||
- `source`
|
|
||||||
- `freshness`
|
|
||||||
|
|
||||||
### sister state mapping 규칙
|
## Activity (활동 피드)
|
||||||
| UI 상태 | API 판단 기준 |
|
|
||||||
|---|---|
|
|
||||||
| `connected idle` | `connection.connected=true` + `working.state='idle'` |
|
|
||||||
| `active working` | `working.state='active'` + reason 존재 |
|
|
||||||
| `snapshot only` | `source='snapshot'` + live connection 없음 |
|
|
||||||
| `fallback only` | `source='fallback'` |
|
|
||||||
| `offline` | `connection.runtime='disconnected'` + snapshot도 stale |
|
|
||||||
|
|
||||||
## Dashboard ops contract
|
| Method | Endpoint | 설명 |
|
||||||
|
|--------|----------|------|
|
||||||
|
| GET | `/api/activity` | 전체 최근 활동 피드 (limit, offset) |
|
||||||
|
|
||||||
### GET `/api/dashboard/ops`
|
## Org (조직도)
|
||||||
`/`와 `/office` 상단 summary가 같이 보는 executive contract다.
|
|
||||||
|
|
||||||
최소 필드:
|
| Method | Endpoint | 설명 |
|
||||||
```json
|
|--------|----------|------|
|
||||||
{
|
| GET | `/api/org` | 조직도 데이터 (자매 + 서브에이전트 트리) |
|
||||||
"focusProject": {
|
|
||||||
"name": "hanarang-dashboard",
|
|
||||||
"phase": "IMPLEMENT",
|
|
||||||
"progress": 62,
|
|
||||||
"deployStatus": "READY FOR DEPLOY",
|
|
||||||
"owner": {
|
|
||||||
"name": null,
|
|
||||||
"source": "snapshot",
|
|
||||||
"whyVisible": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pipeline": {
|
|
||||||
"activeTask": "SPRINT-018",
|
|
||||||
"focus": "dashboard truth redesign",
|
|
||||||
"nodes": [],
|
|
||||||
"source": "mirrored_event",
|
|
||||||
"freshness": {
|
|
||||||
"generatedAt": "2026-04-09T01:20:10.000Z",
|
|
||||||
"latestEventAt": "2026-04-09T01:18:00.000Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"board": [],
|
|
||||||
"freshness": {
|
|
||||||
"generatedAt": "2026-04-09T01:20:10.000Z",
|
|
||||||
"activityLatestAt": "2026-04-09T01:18:00.000Z",
|
|
||||||
"sistersLatestAt": "2026-04-09T01:20:00.000Z",
|
|
||||||
"qaDocLatestAt": "2026-04-09T00:55:00.000Z"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### dashboard 계약 규칙
|
## Admin (관리자)
|
||||||
- `socket on/off`는 connection badge로만 쓴다
|
|
||||||
- `freshness` badge는 별도로 보여준다
|
|
||||||
- `owner`가 없으면 `null` 유지, fallback sister 고정 노출 금지
|
|
||||||
- `focus`가 recent activity 기반 추정이면 `source='mirrored_event'` 또는 `snapshot`으로 표기한다
|
|
||||||
|
|
||||||
## Project detail contract
|
| Method | Endpoint | 설명 |
|
||||||
|
|--------|----------|------|
|
||||||
|
| GET | `/api/admin/harness/:sister/:file` | 하네스 파일 읽기 (AGENTS.md 등) |
|
||||||
|
| PUT | `/api/admin/harness/:sister/:file` | 하네스 파일 수정 + SSOT push |
|
||||||
|
| GET | `/api/admin/repos` | Gitea repo 목록 |
|
||||||
|
| GET | `/api/admin/logs/:sister` | 세션 로그 |
|
||||||
|
| GET | `/api/admin/costs` | 토큰 사용량/비용 |
|
||||||
|
|
||||||
### GET `/api/projects/:id`
|
## Health
|
||||||
프로젝트 상세 응답은 participant와 assignee를 분리한다.
|
|
||||||
|
|
||||||
권장 shape:
|
| Method | Endpoint | 설명 |
|
||||||
```json
|
|--------|----------|------|
|
||||||
{
|
| GET | `/health` | 서버 상태 확인 |
|
||||||
"id": 18,
|
|
||||||
"name": "hanarang-dashboard",
|
|
||||||
"phase": "QA",
|
|
||||||
"participantSummary": {
|
|
||||||
"currentOwners": [],
|
|
||||||
"participants": [
|
|
||||||
{
|
|
||||||
"name": "darang",
|
|
||||||
"whyVisible": ["reviewer", "latest_qa_author"],
|
|
||||||
"source": "snapshot",
|
|
||||||
"freshness": { "lastActiveAt": "2026-04-09T01:10:00.000Z" }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"emptyState": "NO CONFIRMED ACTIVE PARTICIPANT"
|
|
||||||
},
|
|
||||||
"taskAssigneeAggregate": {
|
|
||||||
"uniqueAssignees": ["narang", "darang"],
|
|
||||||
"taskCountByAssignee": {
|
|
||||||
"narang": 4,
|
|
||||||
"darang": 1
|
|
||||||
},
|
|
||||||
"source": "snapshot"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### project participant 규칙
|
|
||||||
- `participants`는 why-visible 없는 항목을 허용하지 않는다
|
|
||||||
- `currentOwners`와 `taskAssigneeAggregate`는 별도 섹션으로 쓴다
|
|
||||||
- 참여자 없음은 정상 상태다. `null`/empty를 숨기지 않는다
|
|
||||||
|
|
||||||
## Org contract
|
|
||||||
|
|
||||||
### GET `/api/org`
|
|
||||||
단순 sister tree 대신 회사형 데이터 구조를 준다.
|
|
||||||
|
|
||||||
권장 shape:
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"orgUnits": [
|
|
||||||
{
|
|
||||||
"id": "hq",
|
|
||||||
"name": "하나랑 HQ",
|
|
||||||
"kind": "hq",
|
|
||||||
"lead": "harang",
|
|
||||||
"memberIds": ["harang"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "delivery",
|
|
||||||
"name": "Delivery",
|
|
||||||
"kind": "functional_team",
|
|
||||||
"lead": "narang",
|
|
||||||
"memberIds": ["narang", "darang"]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"id": "harang",
|
|
||||||
"type": "sister",
|
|
||||||
"role": "Orchestrator",
|
|
||||||
"status": { "connection": "connected", "working": "idle" },
|
|
||||||
"source": "snapshot",
|
|
||||||
"freshness": { "lastSnapshotAt": "2026-04-09T01:20:00.000Z" }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"reportingLines": [
|
|
||||||
{ "from": "hq", "to": "delivery", "kind": "manages" }
|
|
||||||
],
|
|
||||||
"independentAgents": [
|
|
||||||
{
|
|
||||||
"id": "security-auditor",
|
|
||||||
"name": "security-auditor",
|
|
||||||
"ownerSister": null,
|
|
||||||
"source": "snapshot"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### org 계약 규칙
|
|
||||||
- `independentAgents`와 `sisterOwnedAgents`를 구분한다
|
|
||||||
- 특정 자매를 항상 root로 하드코딩하지 않는다
|
|
||||||
- org 화면에서도 `status / source / freshness` 필드를 재사용한다
|
|
||||||
|
|
||||||
## 인증 규칙
|
|
||||||
- 읽기 API는 현재 공개 조회와 관리자 조회가 섞여 있으므로 endpoint별로 명시한다
|
|
||||||
- direct chat (`POST /api/sisters/:name/chat`) 은 JWT 필수
|
|
||||||
- WebSocket 연결은 JWT 필수
|
|
||||||
- JWT 없음 상태는 프론트에서 `send disabled reason`까지 표시해야 한다
|
|
||||||
|
|
||||||
## QA 체크 포인트
|
|
||||||
- `working`이 fallback seed에서 주입되지 않는지
|
|
||||||
- `socket`과 `freshness`가 같은 label로 뭉치지 않는지
|
|
||||||
- `owner`, `participant`, `assignee`가 서로 다른 필드로 내려오는지
|
|
||||||
- `/api/org`가 independent agents를 누락하지 않는지
|
|
||||||
- `360px`, `390px` UI에서 긴 source 문구가 줄바꿈되는지
|
|
||||||
|
|
||||||
## out-of-scope
|
|
||||||
- 실제 DTO 구현 상세
|
|
||||||
- activity evidence 저장소 개선
|
|
||||||
- org 편집 API
|
|
||||||
|
|||||||
@@ -44,5 +44,5 @@ Backend가 SSH로 각 자매 서버에서 수집:
|
|||||||
## 배포
|
## 배포
|
||||||
- **Dev 서버:** 10.10.10.169
|
- **Dev 서버:** 10.10.10.169
|
||||||
- **프로세스 관리:** PM2
|
- **프로세스 관리:** PM2
|
||||||
- **FE:** `pm2 start npm --name hanarang-web --cwd /path/to/hanarang-dashboard/frontend -- start -- -p 3004`
|
- **FE:** pm2 start npm --name hanarang-web -- start (포트 3004)
|
||||||
- **BE:** `pm2 start backend/dist/src/main.js --name hanarang-api --cwd /path/to/hanarang-dashboard` (포트 3005)
|
- **BE:** pm2 start dist/main.js --name hanarang-api (포트 3005)
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
# 디자인 문서 인덱스
|
|
||||||
|
|
||||||
## 시스템
|
|
||||||
- `DESIGN-SYSTEM.md`
|
|
||||||
- `architecture.md`
|
|
||||||
- `api-design.md`
|
|
||||||
- `db-schema.md`
|
|
||||||
|
|
||||||
## 페이지별 UI
|
|
||||||
- `ui/dashboard-design.md`
|
|
||||||
- `ui/office-dashboard-design.md`
|
|
||||||
- `ui/office-chat-design.md`
|
|
||||||
- `ui/projects-page-design.md`
|
|
||||||
- `ui/project-detail-design.md`
|
|
||||||
- `ui/sister-detail-design.md`
|
|
||||||
- `ui/activity-log-design.md`
|
|
||||||
- `ui/org-design.md`
|
|
||||||
- `ui/settings-design.md`
|
|
||||||
- `ui/admin-design.md`
|
|
||||||
|
|
||||||
## 레퍼런스
|
|
||||||
- `references/07-master-dashboard-v3-reference.md`
|
|
||||||
|
|
||||||
## 현재 우선 문서
|
|
||||||
- Sprint 실행 기준: `../sprints/SPRINT-017.md`
|
|
||||||
- 제품 비전: `../../docs/product-specs/openclaw-office-dashboard-prd.md`
|
|
||||||
- 실행 개요: `../OVERVIEW.md`
|
|
||||||
|
|
||||||
## SPRINT-017에서 반드시 잠글 것
|
|
||||||
- 오피스 메인: Desktop / Tablet / Mobile 정보 우선순위
|
|
||||||
- 오피스 채팅: JWT 필요, 전송 실패, empty state 처리
|
|
||||||
- 운영 패널: active workflow / sprint / review loop / deploy gate / server health 상태 톤 통일
|
|
||||||
- 실시간 모델: `live / snapshot / fallback` 판정 규칙
|
|
||||||
- WS + polling reconciliation: stale / reconnect / downgrade 기준
|
|
||||||
|
|
||||||
## Git 기준 확인 경로
|
|
||||||
- `/office` entry: `frontend/app/office/page.tsx`
|
|
||||||
- scene: `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- chat: `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- ws gateway: `backend/src/events/events.gateway.ts`
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# Master Dashboard v3 Reference Notes
|
|
||||||
|
|
||||||
## 출처
|
|
||||||
자기야가 2026-04-06에 공유한 레퍼런스 시안.
|
|
||||||
|
|
||||||
## 핵심 인상
|
|
||||||
- 짙은 다크 배경 위에 운영 패널을 촘촘하게 배치
|
|
||||||
- 상단 global status bar + 중앙 sprint progress + 우측 runtime connection 구조
|
|
||||||
- 4자매 상태 카드를 1행에서 동시에 노출
|
|
||||||
- `ACTIVE PIPELINE`을 중심으로 4자매 협업 흐름을 시각화
|
|
||||||
- `ACTIVITY FEED` / `SPRINT METRICS` / `INFRASTRUCTURE OVERVIEW` / `MISTAKE LOG & HARNESS`를 한 화면에서 모두 판단 가능
|
|
||||||
|
|
||||||
## 채택 결정
|
|
||||||
- **채택:** 정보 구조, 섹션 구성, 운영 화면다운 밀도, Active Pipeline 개념
|
|
||||||
- **부분 채택:** 색 강조, pulse/flow 애니메이션, 상단 진행률 표현
|
|
||||||
- **비채택:** 과한 glow, glassmorphism 회귀, 장식 위주의 다이어그램화
|
|
||||||
|
|
||||||
## 제품 적용 원칙
|
|
||||||
- 하나랑 대시보드는 현행 미니멀 터미널 UI 톤을 유지
|
|
||||||
- 레퍼런스는 `레이아웃/정보 위계/흐름 표현` 위주로 번역 적용
|
|
||||||
- 비주얼 차용 비율은 대략 70% 이내로 제한
|
|
||||||
- 실데이터 기반 운영 화면으로 느껴져야 하며 mock showcase처럼 보이면 안 됨
|
|
||||||
|
|
||||||
## 특히 강한 섹션
|
|
||||||
1. Sister Status Cards
|
|
||||||
2. Active Pipeline
|
|
||||||
3. Activity Feed + Metrics 병렬 비교
|
|
||||||
4. Infra + Mistake Log 하단 운영 패널
|
|
||||||
|
|
||||||
## 구현 시 주의
|
|
||||||
- 실제 데이터 밀도에 비해 컴포넌트가 과장되면 안 됨
|
|
||||||
- 첫 스크롤 안에 가장 중요한 판단 정보가 모여야 함
|
|
||||||
- 모바일에서는 같은 구조를 억지로 축소하지 말고 세로 흐름으로 재배열
|
|
||||||
@@ -1,122 +1,58 @@
|
|||||||
# `/` UI 기준 — SPRINT-018 executive snapshot
|
# 대시보드 메인 (`/`) — 디자인 v2
|
||||||
|
|
||||||
## 문서 목적
|
> 참조: DESIGN-SYSTEM.md | 원본: 자기야 디자인 파일 #1
|
||||||
메인 대시보드(`/`)를 가장 중요한 운영 변화만 짧게 읽는 **executive snapshot**으로 다시 잠근다. HOTFIX-006의 문구 절제와 source 정합성 보정을 포함하고, 이번 Sprint에서는 `socket`, `freshness`, `owner`, `source`를 오해 없이 분리한다.
|
|
||||||
|
|
||||||
## 참고 문서
|
## 레이아웃
|
||||||
- 실행 개요: `.plans/OVERVIEW.md`
|
|
||||||
- Sprint: `.plans/sprints/SPRINT-018.md`
|
|
||||||
- HOTFIX-006: `.plans/hotfix/HOTFIX-006.md`
|
|
||||||
- API 설계: `.plans/design/api-design.md`
|
|
||||||
|
|
||||||
## 기준 구현 파일
|
```
|
||||||
- `frontend/app/page.tsx`
|
┌──────────┬─────────────────────────────────────────────┐
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
│ │ 하나랑 대시보드 │
|
||||||
- `backend/src/sisters/sisters.service.ts`
|
│ ●◗ │ │
|
||||||
|
│ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
|
||||||
|
│ [대시] │ │SYS: │ │SYS: │ │SYS: │ │SYS: │ │
|
||||||
|
│ 활동 │ │하랑 │ │나랑 │ │다랑 │ │이랑 │ │
|
||||||
|
│ 프로 │ │[ON] │ │[84] │ │[--] │ │[12] │ │
|
||||||
|
│ 자매 │ │▬▬▬▬▬ │ │▬▬▬▬░ │ │░░░░░ │ │▬░░░░ │ │
|
||||||
|
│ 조직 │ └──────┘ └──────┘ └──────┘ └──────┘ │
|
||||||
|
│ 설정 │ │
|
||||||
|
│ 관리 │ ONGOING PROJECTS ACTIVITY FEED │
|
||||||
|
│ │ ───────────────── ────────────── │
|
||||||
|
│ │ ● 데이터 파이프라인 PHASE 2 │ 14:02:45 │
|
||||||
|
│ │ ● 새로운 자매 노드 INIT │ System... │
|
||||||
|
│ │ ● 관리자 권한 체계 REVIEW │ 11:30:12 │
|
||||||
|
│ │ │ Security... │
|
||||||
|
└──────────┴─────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
## 페이지 역할
|
## 상태 카드 (Status Grid)
|
||||||
`/`는 live intervention 화면이 아니야. 여기서는 운영자가 아래를 빠르게 판단해야 한다.
|
- `grid-template-columns: repeat(4, 1fr)` / gap: 24px
|
||||||
- 지금 focus가 어디 있나
|
- 각 카드: `card` 컴포넌트 (DESIGN-SYSTEM.md 참조)
|
||||||
- 최근 event는 언제 있었나
|
- 구조:
|
||||||
- active owner가 있나 없나
|
- header: `label-meta` — `SYS:` (secondary) + 이름 (primary)
|
||||||
- 어떤 섹션이 live / mirrored event / snapshot / doc-derived / fallback 인가
|
- body: `bracket-value` — `[ON]`, `[84]`, `[--]`, `[12]`
|
||||||
|
- sub-label: Active Node / Capacity % / Standby / Sync Queue
|
||||||
|
- tech-bar: 2px 진행 바 (100% / 84% / 0% / 12%)
|
||||||
|
- standby 카드: bracket-value `color: var(--text-secondary)`
|
||||||
|
|
||||||
## 핵심 문제
|
## 하단 2열 (Data Columns)
|
||||||
현재 구현에서 바로 고쳐야 하는 점:
|
- `grid-template-columns: 1.5fr 1fr` / gap: 64px
|
||||||
- `socket off`가 전체 오류처럼 읽힌다
|
|
||||||
- snapshot freshness와 socket 연결 여부가 같은 줄에서 섞인다
|
|
||||||
- owner가 없을 때 fallback sister가 고정 노출된다
|
|
||||||
- focus summary와 panel copy가 길고 설명형이다
|
|
||||||
|
|
||||||
## top bar 규칙
|
### 좌: ONGOING PROJECTS
|
||||||
### 좌측
|
- section-title: `ONGOING PROJECTS` + `VOL: 04`
|
||||||
- `MASTER DASHBOARD` 또는 동급 짧은 label
|
- project-row: `grid-template-columns: 40px 1fr auto`
|
||||||
- focus headline 1개
|
- 아바타: 32px 원형, grayscale, SVG placeholder
|
||||||
|
- 프로젝트명: 15px 500
|
||||||
|
- 설명: 13px secondary
|
||||||
|
- 상태 라벨: label-meta (PHASE 2 / INIT / REVIEW)
|
||||||
|
|
||||||
### 중앙
|
### 우: ACTIVITY FEED
|
||||||
- current project / current sprint / deploy state
|
- section-title: `ACTIVITY FEED` + `LIVE`
|
||||||
|
- timeline 컴포넌트 (세로선 + 도트 + 타임스탬프 + 내용)
|
||||||
|
- 타임스탬프: mono 11px, `14:02:45 GMT+9`
|
||||||
|
- 내용: 13px, bold로 시스템명 강조
|
||||||
|
|
||||||
### 우측
|
## 모바일 반응형
|
||||||
- connection badge
|
- 상태 카드: `repeat(2, 1fr)` → `1fr`
|
||||||
- freshness badge
|
- data-columns: 1열 수직 스택 (프로젝트 먼저, 활동 아래)
|
||||||
- active owner 또는 `NO ACTIVE OWNER`
|
- bracket-value: 24px
|
||||||
|
- 패딩 축소
|
||||||
## connection / freshness 분리 규칙
|
|
||||||
| badge | 의미 | 예시 |
|
|
||||||
|---|---|---|
|
|
||||||
| connection | websocket/event stream 연결 상태 | `EVENT STREAM ON`, `EVENT STREAM OFF` |
|
|
||||||
| freshness | 데이터 최신성 | `SYNC 18s AGO`, `SNAPSHOT 2m AGO` |
|
|
||||||
| source | 값의 출처 | `MIRRORED EVENT`, `SNAPSHOT`, `DOC-DERIVED`, `FALLBACK` |
|
|
||||||
|
|
||||||
### 금지
|
|
||||||
- `socket off` 하나만 보고 오류처럼 보이게 만들기
|
|
||||||
- connection badge를 source badge 대신 쓰기
|
|
||||||
- freshness 없는 `LIVE` 라벨 단독 사용
|
|
||||||
|
|
||||||
## owner 표현 규칙
|
|
||||||
- active owner는 source와 why-visible이 있을 때만 강하게 노출
|
|
||||||
- owner가 없으면 `NO ACTIVE OWNER` 또는 `UNASSIGNED`로 표시
|
|
||||||
- fallback sister를 기본 owner로 고정 노출하지 않는다
|
|
||||||
- snapshot owner면 `SNAPSHOT OWNER`를 badge로 분리한다
|
|
||||||
|
|
||||||
## information architecture
|
|
||||||
### 1. top snapshot bar
|
|
||||||
- focus headline
|
|
||||||
- connection / freshness / source badges
|
|
||||||
- active owner
|
|
||||||
|
|
||||||
### 2. sister status row
|
|
||||||
카드는 짧고 운영형으로 유지한다.
|
|
||||||
|
|
||||||
각 카드 최소 정보:
|
|
||||||
- name
|
|
||||||
- role
|
|
||||||
- truthful state (`active working`, `connected idle`, `snapshot only`, `offline`)
|
|
||||||
- short summary 1줄
|
|
||||||
- source/freshness meta
|
|
||||||
|
|
||||||
### 3. active pipeline
|
|
||||||
- 실제 event mirrored인지, snapshot inference인지 표시
|
|
||||||
- `NO ACTIVE HANDOFF`, `NO CONFIRMED REVIEW LOOP` 같은 neutral empty state 허용
|
|
||||||
- 추정치 문장을 확정 사실처럼 쓰지 않는다
|
|
||||||
|
|
||||||
### 4. activity feed / metrics
|
|
||||||
- activity feed는 근거
|
|
||||||
- metrics는 요약
|
|
||||||
- source가 다른 값은 같은 카드 안에서 섞지 않는다
|
|
||||||
|
|
||||||
### 5. infra / board
|
|
||||||
- infra: runtime/snapshot 상태
|
|
||||||
- board: harness/qa 같은 doc-derived 또는 activity-derived 기록
|
|
||||||
- 각 카드에 source badge를 유지한다
|
|
||||||
|
|
||||||
## copy rules
|
|
||||||
- 짧은 운영형 문장 우선
|
|
||||||
- 설명문, 감상문, 구현 메타 문장 금지
|
|
||||||
- `~정리했어`, `~보여준다` 같은 자기설명 금지
|
|
||||||
- owner/focus/fallback 문구는 neutral tone 사용
|
|
||||||
|
|
||||||
권장 예시:
|
|
||||||
- `EVENT STREAM OFF`
|
|
||||||
- `SNAPSHOT 58s AGO`
|
|
||||||
- `NO ACTIVE OWNER`
|
|
||||||
- `DOC-DERIVED`
|
|
||||||
- `NO RECENT QA`
|
|
||||||
- `MIRRORED EVENT`
|
|
||||||
|
|
||||||
## mobile 360 / 390 rules
|
|
||||||
- top bar chip은 wrap 허용
|
|
||||||
- owner 영역은 avatar + label 고정폭 금지
|
|
||||||
- focus summary는 1~2문장 대신 짧은 label + short detail 사용
|
|
||||||
- sister card, pipeline card, board card, git/meta row에서 horizontal scroll 금지
|
|
||||||
|
|
||||||
## acceptance
|
|
||||||
- socket 연결 여부와 freshness가 별도 라벨로 보인다
|
|
||||||
- `socket off`가 오류처럼 읽히지 않는다
|
|
||||||
- owner가 없을 때 fallback owner 고정 노출이 사라진다
|
|
||||||
- 카드 문구가 짧은 운영형 문장으로 정리된다
|
|
||||||
- 주요 섹션이 `live / mirrored event / snapshot / doc-derived / fallback` 중 무엇인지 일관되게 보인다
|
|
||||||
|
|
||||||
## rollout note
|
|
||||||
- HOTFIX-006에서 잠근 source/freshness 원칙을 홈 전체 IA에 확대 적용한다
|
|
||||||
- `/office`와 달리 `/`는 intervention CTA보다 snapshot readability를 우선한다
|
|
||||||
|
|||||||
@@ -1,150 +0,0 @@
|
|||||||
# 오피스 direct chat UI 기준 — SPRINT-017 모바일 개편
|
|
||||||
|
|
||||||
## 문서 목적
|
|
||||||
`ChatWorkspace.tsx`를 모바일 direct chat 기준으로 다시 정리하기 위한 문서야. 기준 Sprint는 `.plans/sprints/SPRINT-017.md`이고, 메인 IA와 first viewport 원칙은 `.plans/design/ui/office-dashboard-design.md`를 따른다.
|
|
||||||
|
|
||||||
## 기준 구현 파일
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- 연관 문서: `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
|
|
||||||
## breakpoint 기준
|
|
||||||
- `360px`: minimum mobile compact
|
|
||||||
- `390px`: primary mobile baseline
|
|
||||||
- `768px`: tablet transition
|
|
||||||
- `1280px+`: desktop baseline
|
|
||||||
|
|
||||||
## 현재 main 구현에서 확인된 문제
|
|
||||||
- `page.tsx`에서 chat은 `ChatArea` 고정 높이(`520px`, 모바일 `460px`) 안에 들어가 세로 흐름을 끊는다.
|
|
||||||
- `ChatWorkspace.tsx`는 모바일에서도 데스크톱 구조의 흔적이 강하다.
|
|
||||||
- 자매 탭, 메시지, 보조 컨텍스트가 분리되어 있다.
|
|
||||||
- `SisterContext`는 `1199px` 미만에서 숨겨져 모바일 보조 정보가 사라진다.
|
|
||||||
- `SendBtn`은 토큰이 없으면 disabled라서, `JWT 없음` 이유를 화면에서 놓치기 쉽다.
|
|
||||||
- empty 상태 문구는 있지만, `JWT 없음 / error / runtime 확인 중`이 같은 강도로 정리되어 있지 않다.
|
|
||||||
|
|
||||||
## 모바일 direct chat 원칙
|
|
||||||
1. **한 컬럼 흐름**
|
|
||||||
- mobile(` <768`)에서는 탭 → 상태 → 타임라인 → composer → 보조 정보 순서로 한 컬럼으로 간다.
|
|
||||||
2. **전송 가능 여부를 숨기지 않기**
|
|
||||||
- `JWT 없음`이면 입력 근처에서 바로 이유를 보여준다.
|
|
||||||
3. **상태는 상단에 짧게**
|
|
||||||
- runtime/source 상태는 header 또는 composer 상단에서 한 번에 읽히게 한다.
|
|
||||||
4. **메시지가 우선**
|
|
||||||
- 보조 컨텍스트보다 타임라인과 입력창이 우선이다.
|
|
||||||
5. **고정 높이 최소화**
|
|
||||||
- 460px 박스 안에 억지로 채우지 않는다.
|
|
||||||
|
|
||||||
## mobile layout
|
|
||||||
모바일 기본 순서는 아래야.
|
|
||||||
|
|
||||||
### 1. sister switcher
|
|
||||||
- 4자매 전환을 상단 compact tab 또는 segmented control로 둔다
|
|
||||||
- 이름과 active 상태만 짧게 보여준다
|
|
||||||
- role 전체 문구는 모바일에서 숨기거나 축약한다
|
|
||||||
|
|
||||||
### 2. runtime / source badge row
|
|
||||||
상단 배지 영역에서 아래를 보여준다.
|
|
||||||
- runtime 상태: `연결됨`, `확인 중`, `stale`, `error`
|
|
||||||
- source badge: `live`, `snapshot`, `fallback`
|
|
||||||
- 필요 시 현재 자매 상태(`thinking`, `tool_calling`, `speaking`, `idle`)
|
|
||||||
|
|
||||||
### 3. timeline
|
|
||||||
- 메시지 타임라인은 화면에서 가장 큰 비중을 차지한다
|
|
||||||
- `user / assistant / tool` 구분은 유지한다
|
|
||||||
- tool 메시지는 mono 또는 강조 배경 유지
|
|
||||||
- 버블 최대 폭은 모바일에서 너무 좁아지지 않게 조정한다
|
|
||||||
|
|
||||||
### 4. composer
|
|
||||||
- 입력창과 전송 버튼은 타임라인 바로 아래
|
|
||||||
- `Enter = 전송`, `Shift+Enter = 줄바꿈` 힌트는 짧게 유지
|
|
||||||
- 전송 불가 상태면 버튼만 막지 말고 이유를 붙인다
|
|
||||||
|
|
||||||
### 5. support state block
|
|
||||||
모바일에서는 숨기지 말고 composer 아래 또는 접이식 블록으로 둔다.
|
|
||||||
- current task
|
|
||||||
- active session label
|
|
||||||
- data source 설명 한 줄
|
|
||||||
|
|
||||||
## 상태 배지 규칙
|
|
||||||
### source badge
|
|
||||||
- `live`: runtime 연결 또는 최신 상태 반영 중
|
|
||||||
- `snapshot`: 마지막 조회 스냅샷 표시 중
|
|
||||||
- `fallback`: 기본값 또는 보조 데이터 기준
|
|
||||||
|
|
||||||
### runtime badge
|
|
||||||
- `연결됨`: gatewayConnected = true
|
|
||||||
- `확인 중`: 아직 runtime snapshot 수신 전
|
|
||||||
- `stale`: 최근 업데이트가 늦음
|
|
||||||
- `오류`: 전송 또는 조회 실패
|
|
||||||
|
|
||||||
### 배지 위치
|
|
||||||
- header 오른쪽 또는 바로 아래 1줄
|
|
||||||
- 모바일에서는 긴 설명 대신 짧은 라벨 + 보조 문구 1개만 둔다
|
|
||||||
|
|
||||||
## empty / error / JWT 없음 UX
|
|
||||||
### empty
|
|
||||||
조건:
|
|
||||||
- 메시지 없음
|
|
||||||
- 최근 runtime 메시지도 없음
|
|
||||||
|
|
||||||
표현:
|
|
||||||
- "아직 대화가 없어"
|
|
||||||
- 바로 보낼 수 있는 예시 액션 1개 또는 placeholder
|
|
||||||
- runtime 상태 보조 문구
|
|
||||||
|
|
||||||
### JWT 없음
|
|
||||||
조건:
|
|
||||||
- `localStorage` 토큰 없음
|
|
||||||
- 또는 인증이 풀려 전송 불가
|
|
||||||
|
|
||||||
표현:
|
|
||||||
- 입력 근처에 즉시 보이는 경고 문구
|
|
||||||
- 예: `로그인이 풀려서 지금은 전송할 수 없어. 다시 로그인해.`
|
|
||||||
- 전송 버튼 disabled만 두고 끝내지 않는다
|
|
||||||
|
|
||||||
### 전송 실패
|
|
||||||
조건:
|
|
||||||
- `/api/sisters/:name/chat` 실패
|
|
||||||
|
|
||||||
표현:
|
|
||||||
- 타임라인 내 실패 메시지 유지
|
|
||||||
- composer 근처에 `다시 시도` 또는 실패 이유 보조 문구
|
|
||||||
- 실패와 empty를 같은 문구로 합치지 않는다
|
|
||||||
|
|
||||||
### runtime 확인 중
|
|
||||||
조건:
|
|
||||||
- runtime snapshot 미수신 또는 gateway 미연결
|
|
||||||
|
|
||||||
표현:
|
|
||||||
- header 배지 또는 상태 줄에 표시
|
|
||||||
- 메시지 전송 가능 여부와 별개인지 함께 설명
|
|
||||||
|
|
||||||
## 메시지 규칙
|
|
||||||
- `user`: 우측 또는 구분되는 배경
|
|
||||||
- `assistant`: 기본 응답 버블
|
|
||||||
- `tool`: mono 스타일과 별도 톤 유지
|
|
||||||
- timestamp는 보조 정보로만 노출
|
|
||||||
- 모바일에서 버블 폭이 지나치게 좁아 읽기 어렵지 않게 한다
|
|
||||||
|
|
||||||
## mobile에서 숨기면 안 되는 정보
|
|
||||||
- active sister
|
|
||||||
- runtime/source 상태
|
|
||||||
- current task 또는 active session 중 하나
|
|
||||||
- JWT 없음 / 전송 실패 이유
|
|
||||||
|
|
||||||
## desktop / tablet 유지 규칙
|
|
||||||
### desktop (`1280px+`)
|
|
||||||
- 현재 3열 느낌을 유지해도 돼
|
|
||||||
- 다만 source/runtime 라벨과 상태 문구는 모바일 기준과 통일해
|
|
||||||
|
|
||||||
### tablet (`768px`)
|
|
||||||
- 좌측 자매 전환 + 중앙 타임라인 구조 유지 가능
|
|
||||||
- 우측 보조 패널이 사라져도 핵심 상태는 상단에서 읽혀야 해
|
|
||||||
|
|
||||||
## QA 체크 포인트
|
|
||||||
- `360px`, `390px`에서 탭, 타임라인, 입력창이 겹치지 않는지
|
|
||||||
- 입력창이 키보드 노출 시 잘리지 않는지
|
|
||||||
- `JWT 없음` 상태가 버튼 disabled 외에 문구로도 보이는지
|
|
||||||
- `empty`, `runtime 확인 중`, `전송 실패`가 서로 다른 문구로 보이는지
|
|
||||||
- `user / assistant / tool` 구분이 모바일에서도 유지되는지
|
|
||||||
- source badge와 runtime badge가 다른 의미로 명확히 읽히는지
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
# `/office` UI 기준 — SPRINT-018 live operations workspace
|
|
||||||
|
|
||||||
## 문서 목적
|
|
||||||
`/office`를 4개 긴 박스 조합이 아니라 **group mental model 중심 live operations workspace**로 다시 잠그는 문서야. SPRINT-017의 mobile-first IA를 유지하되, 이번 Sprint에서는 `working`, `source`, `freshness`, `default context` 의미를 더 엄격하게 정의한다.
|
|
||||||
|
|
||||||
## 참고 문서
|
|
||||||
- 실행 개요: `.plans/OVERVIEW.md`
|
|
||||||
- Sprint: `.plans/sprints/SPRINT-018.md`
|
|
||||||
- API 설계: `.plans/design/api-design.md`
|
|
||||||
- 관련 chat 문서: `.plans/design/ui/office-chat-design.md`
|
|
||||||
|
|
||||||
## 기준 구현 파일
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `frontend/components/office/ContextPanel.tsx`
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `frontend/components/office/ServerHealthPanel.tsx`
|
|
||||||
|
|
||||||
## 페이지 역할
|
|
||||||
`/office`는 executive summary가 아니라 **바로 개입하는 운영 화면**이야.
|
|
||||||
|
|
||||||
핵심 질문:
|
|
||||||
1. 누가 연결돼 있나
|
|
||||||
2. 누가 실제로 working 중인가
|
|
||||||
3. 어떤 group이 막혀 있나
|
|
||||||
4. 지금 어디에 말 걸면 되나
|
|
||||||
|
|
||||||
## 정보 구조 원칙
|
|
||||||
1. **group mental model 유지**
|
|
||||||
- 자매를 개별 카드 나열로만 보지 않고 `planning / delivery / review / deploy` group 흐름으로 묶는다
|
|
||||||
2. **scene은 운영 지도여야 함**
|
|
||||||
- 데스크톱 scene은 decorative office가 아니라 group 상태와 선택을 보여주는 요약 지도여야 한다
|
|
||||||
3. **빈 context 금지**
|
|
||||||
- 첫 진입 시 `선택하세요` 대신 기본 운영 summary를 보여준다
|
|
||||||
4. **truthful status**
|
|
||||||
- `connected idle`, `active working`, `snapshot only`, `fallback`, `offline`을 구분한다
|
|
||||||
5. **mobile overflow 금지**
|
|
||||||
- `360px`, `390px` 기준 긴 badge, 긴 detail, 긴 source 문구는 wrap되고 horizontal scroll이 없어야 한다
|
|
||||||
|
|
||||||
## source / status 라벨
|
|
||||||
| 라벨 | 의미 | 금지 |
|
|
||||||
|---|---|---|
|
|
||||||
| `live` | runtime 또는 ws 기반 최신 상태 | snapshot과 같은 톤으로 보이게 하기 |
|
|
||||||
| `snapshot` | polling 기준 마지막 스냅샷 | live처럼 pulse 주기 |
|
|
||||||
| `fallback` | 보정 데이터 | working으로 읽히는 색 주기 |
|
|
||||||
| `connected idle` | 연결됨, 최근 작업 없음 | working 색 재사용 |
|
|
||||||
| `active working` | 명시적 작업 중 | 단순 task string 존재만으로 확정하기 |
|
|
||||||
| `offline` | 연결 불가 | stale snapshot과 같은 카드 처리 |
|
|
||||||
|
|
||||||
## desktop IA (`1280px+`)
|
|
||||||
### 레이아웃
|
|
||||||
`summary rail + group scene + context rail + bottom detail panels`
|
|
||||||
|
|
||||||
### 1. summary rail
|
|
||||||
- 현재 focus
|
|
||||||
- connection summary
|
|
||||||
- active working count
|
|
||||||
- source/freshness badges
|
|
||||||
|
|
||||||
### 2. group scene
|
|
||||||
기존 4개 긴 박스 분해형 대신 아래 group block을 scene 안에 배치한다.
|
|
||||||
- Planning group: 하랑이 + planner/prd-writer
|
|
||||||
- Delivery group: 나랑이 + implementation subagents
|
|
||||||
- Review group: 다랑이 + reviewer/qa/security
|
|
||||||
- Deploy group: 이랑이 + infra/deploy agents
|
|
||||||
|
|
||||||
각 group 최소 정보:
|
|
||||||
- group label
|
|
||||||
- connected count / working count
|
|
||||||
- primary blocker 또는 `all clear`
|
|
||||||
- 대표 source badge
|
|
||||||
|
|
||||||
### 3. context rail
|
|
||||||
선택 상태와 무관하게 기본 summary가 먼저 보인다.
|
|
||||||
|
|
||||||
기본 summary 우선순위:
|
|
||||||
1. current focus
|
|
||||||
2. current blocker
|
|
||||||
3. active working group
|
|
||||||
4. quick actions
|
|
||||||
|
|
||||||
선택 후 context는 아래로 바뀐다.
|
|
||||||
- selected sister summary
|
|
||||||
- recent session / task evidence
|
|
||||||
- why this looks active
|
|
||||||
- open chat CTA
|
|
||||||
|
|
||||||
### 4. bottom detail panels
|
|
||||||
순서:
|
|
||||||
1. chat
|
|
||||||
2. pipeline
|
|
||||||
3. server health
|
|
||||||
|
|
||||||
패널 역할:
|
|
||||||
- chat: intervention
|
|
||||||
- pipeline: delivery flow evidence
|
|
||||||
- health: infra/runtime evidence
|
|
||||||
|
|
||||||
## mobile IA (`<768`)
|
|
||||||
### 고정 순서
|
|
||||||
`summary → group blocks → detail flow`
|
|
||||||
|
|
||||||
### 1. summary
|
|
||||||
첫 viewport 안에 아래가 모두 들어와야 한다.
|
|
||||||
- current focus
|
|
||||||
- connection summary
|
|
||||||
- active working summary
|
|
||||||
- quick action
|
|
||||||
|
|
||||||
### 2. group blocks
|
|
||||||
- 4자매 individual card보다 group block 우선
|
|
||||||
- 각 block 안에서 대표 sister와 상태를 요약
|
|
||||||
- 선택 시 inline expand 또는 accordion으로 detail 표시
|
|
||||||
|
|
||||||
### 3. detail flow
|
|
||||||
모바일에서는 `800x460` scene 축소판을 사용하지 않는다.
|
|
||||||
세부 흐름 순서:
|
|
||||||
1. chat
|
|
||||||
2. pipeline
|
|
||||||
3. health
|
|
||||||
4. context detail
|
|
||||||
|
|
||||||
## default context 규칙
|
|
||||||
선택 전 기본 카드 예시:
|
|
||||||
- `현재 focus`: active task / no active focus
|
|
||||||
- `현재 가장 바쁜 그룹`: delivery / review / none
|
|
||||||
- `개입 권장`: direct chat target 또는 `no direct target`
|
|
||||||
- `data note`: live/snapshot/fallback 구분
|
|
||||||
|
|
||||||
## ChatWorkspace 반영 규칙
|
|
||||||
- JWT 없음, runtime 확인 중, empty, error, send disabled reason을 상단 또는 입력부 근처에 즉시 노출
|
|
||||||
- chat이 열리지 않은 기본 상태에서도 요약 CTA는 보여야 한다
|
|
||||||
- mobile에서 고정 높이 중심 설계 금지
|
|
||||||
|
|
||||||
## PipelinePanel 반영 규칙
|
|
||||||
- 가로 카드열 금지
|
|
||||||
- 세로 단계 흐름 또는 responsive stack 사용
|
|
||||||
- `focus`, `review loop`, `deploy state`, `source/freshness`를 상단 요약으로 먼저 보여준다
|
|
||||||
|
|
||||||
## ServerHealthPanel 반영 규칙
|
|
||||||
- 상단에는 health summary만 먼저 노출
|
|
||||||
- 긴 detail/source 문구는 wrap되어야 한다
|
|
||||||
- `connected idle`, `snapshot only`, `fallback`, `offline`을 다른 상태로 읽히게 한다
|
|
||||||
|
|
||||||
## 상태 표현 규칙
|
|
||||||
| 상태 | 문구 예시 |
|
|
||||||
|---|---|
|
|
||||||
| loading | `데이터 확인 중` |
|
|
||||||
| empty | `표시할 운영 항목 없음` |
|
|
||||||
| error | `가져오지 못함` |
|
|
||||||
| stale | `마지막 확인값 표시 중` |
|
|
||||||
| jwt_missing | `JWT 없음, 전송 불가` |
|
|
||||||
|
|
||||||
`empty`와 `error`는 절대 같은 문구를 쓰지 않는다.
|
|
||||||
|
|
||||||
## 360 / 390 responsive rules
|
|
||||||
- 카드 title, badge, meta는 2줄까지 wrap 허용
|
|
||||||
- source label은 short token 우선 (`live`, `snapshot`, `fallback`)
|
|
||||||
- `generated 10:31:02` 같은 긴 freshness 문구는 한 줄 고정 금지
|
|
||||||
- 전체 페이지와 하위 패널에서 horizontal scroll 금지
|
|
||||||
|
|
||||||
## acceptance
|
|
||||||
- `/office` desktop이 4개 긴 박스 분해형이 아니라 group/scene 중심으로 재구성된다
|
|
||||||
- mobile에서 scene 축소판이 사라지고 `summary → group blocks → detail flow`가 된다
|
|
||||||
- 첫 진입 시 빈 context가 아니라 기본 운영 summary가 보인다
|
|
||||||
- selected / unselected 상태 모두 `360px`, `390px`에서 overflow 없이 읽힌다
|
|
||||||
- `working`은 source-of-truth 기준으로만 강조된다
|
|
||||||
|
|
||||||
## rollout note
|
|
||||||
- SPRINT-017의 모바일 정보 순서는 유지한다
|
|
||||||
- 이번 Sprint에서 바꾸는 건 scene semantics, default context, truthful state labels다
|
|
||||||
@@ -1,121 +1,97 @@
|
|||||||
# `/org` UI 기준 — SPRINT-018 company org map
|
# 조직도 (`/org`) — 디자인 v2
|
||||||
|
|
||||||
## 문서 목적
|
> 참조: DESIGN-SYSTEM.md | 원본: 자기야 디자인 파일 #6
|
||||||
`/org`를 자매 트리 데모가 아니라 **회사형 조직도 + independent agents map**으로 전면 재설계한다. 이번 문서는 하드코딩된 root tree 대신, 실제 데이터 계약으로 렌더링 가능한 org 화면 기준을 잠근다.
|
|
||||||
|
|
||||||
## 참고 문서
|
## 레이아웃
|
||||||
- 실행 개요: `.plans/OVERVIEW.md`
|
|
||||||
- Sprint: `.plans/sprints/SPRINT-018.md`
|
|
||||||
- API 설계: `.plans/design/api-design.md`
|
|
||||||
|
|
||||||
## 기준 구현 파일
|
```
|
||||||
- `frontend/app/org/page.tsx`
|
┌─────┬──────────────────────────────────────────────────────┐
|
||||||
- `backend/src/sisters/sister-detail.service.ts`
|
│ 64px│ SYS_TYPE: CORE_ROOT_01 2023.10.27_14:42 │
|
||||||
|
│ │ ────────────────────────────────────────────────── │
|
||||||
|
│ │ │
|
||||||
|
│ DASH│ ┌─────────────────┐ │
|
||||||
|
│ PROJ│ │ [HQ] 하나랑 글로벌 │ │
|
||||||
|
│◗ORG │ │ MEM:142 S_ADMIN │ │
|
||||||
|
│ CONF│ └────────┬────────┘ │
|
||||||
|
│ │ ┌───────────┼───────────┐ │
|
||||||
|
│ │ ┌──────┴──────┐ ┌─┴────┐ ┌───┴───┐ │
|
||||||
|
│ │ │[R&D] 기술연구│ │[OPS] │ │[EXT] │ │
|
||||||
|
│ │ │ MEM:48 LEAD │ │운영팀 │ │외부협력│ │
|
||||||
|
│ │ └──────┬──────┘ └──┬───┘ └───┬───┘ │
|
||||||
|
│ │ ┌─────┼─────┐ │ │ │
|
||||||
|
│ │ ┌──┴──┐ ┌┴─────┐ ┌──┴───┐ ┌───┴────┐ │
|
||||||
|
│ │ │Core │ │Infra │ │Monitor│ │Security│ │
|
||||||
|
│ │ │Eng. │ │struct│ │ing │ │Audit │ │
|
||||||
|
│ │ └─────┘ └──────┘ └──────┘ └────────┘ │
|
||||||
|
│ │ │
|
||||||
|
│ │ TOTAL_NODES: 07 STATUS: SYNC_COMPLETE │
|
||||||
|
└─────┴──────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
## 현재 문제
|
## 사이드바 (조직도 전용)
|
||||||
- 현재 화면은 하랑이 root 고정형 terminal tree다
|
- **64px 너비** (다른 페이지의 240px과 다름)
|
||||||
- 자매 외 조직 단위가 없다
|
- 세로 텍스트: `writing-mode: vertical-rl`
|
||||||
- independent agents가 표현되지 않는다
|
- 아이콘 모드: DASH / PROJ / ORG_TREE / CONF
|
||||||
- mobile에서는 tree 한 벌이 사실상 읽기 어렵다
|
- 로고: 세로 배치 (circle-full 위, circle-half 아래)
|
||||||
- source / freshness / status가 다른 페이지와 같은 의미로 보이지 않는다
|
|
||||||
|
|
||||||
## 페이지 역할
|
## 메인 뷰포트
|
||||||
핵심 질문:
|
- 배경: dot grid pattern — `radial-gradient(circle, #1a1a1a 1px, transparent 1px)` / 30px 30px
|
||||||
1. 회사 조직 단위는 어떻게 나뉘어 있나
|
- `overflow: auto` (스크롤 가능)
|
||||||
2. 각 unit lead와 member는 누구인가
|
- padding: 40px, 중앙 정렬
|
||||||
3. independent agents는 어느 영역에 속하지 않는가
|
|
||||||
4. 현재 status / source / freshness는 무엇인가
|
|
||||||
|
|
||||||
## 정보 구조
|
## 헤더
|
||||||
### 1. org summary header
|
- 좌: `SYS_TYPE: CORE_ROOT_01` (mono, 값은 흰색)
|
||||||
- org generated time
|
- 우: `TIMESTAMP: 2023.10.27_14:42` (mono secondary)
|
||||||
- source badge
|
- border-bottom 1px
|
||||||
- total units
|
|
||||||
- total members
|
|
||||||
- independent agents count
|
|
||||||
|
|
||||||
### 2. HQ section
|
## 트리 구조
|
||||||
- HQ card
|
|
||||||
- lead
|
|
||||||
- 핵심 responsibility
|
|
||||||
- direct reports summary
|
|
||||||
|
|
||||||
### 3. functional teams
|
### Terminal Card
|
||||||
예시:
|
- 200px 너비, padding 12px
|
||||||
- Planning / Program
|
- `border: 1px solid var(--border-color)`
|
||||||
- Delivery
|
- **border-left: 3px solid** (레벨별 색상)
|
||||||
- QA / Review
|
- high (`#f43f5e`): HQ
|
||||||
- Infra / Deploy
|
- mid (`#3b82f6`): R&D, Core Engine, Infrastructure
|
||||||
|
- low (`#10b981`): OPS, EXT, Monitoring, Security Audit
|
||||||
|
- `box-shadow: 0 10px 30px rgba(0,0,0,0.5)`
|
||||||
|
- node-label: mono 13px 600
|
||||||
|
- 접두사 span: `[HQ]` `[R&D]` `[OPS]` `[EXT]` — secondary 11px
|
||||||
|
- badge-row: flex wrap, gap 6px
|
||||||
|
- badge: mono 9px, `#1a1a1a` bg, border 1px `#262626`
|
||||||
|
- `MEM: 142` (값은 primary)
|
||||||
|
- `S_ADMIN`, `LEAD`, `MGR`, `GUEST` 등
|
||||||
|
- `LV_09`, `LV_07` 등
|
||||||
|
|
||||||
각 team card 최소 정보:
|
### 접기/펼치기 토글
|
||||||
- team name
|
- `−` / `+` 아이콘, 16x16px
|
||||||
- lead
|
- 카드 하단 중앙 absolute 배치
|
||||||
- member chips
|
- bg: card bg, border 1px
|
||||||
- active status summary
|
|
||||||
- source/freshness
|
|
||||||
|
|
||||||
### 4. independent agents
|
### 연결선
|
||||||
조직도 하단 또는 병렬 rail에 별도 배치한다.
|
- 세로선: `width: 1px; background: var(--border-color)`
|
||||||
|
- 가로선 (형제 연결): children `::before` — 상단 -40px
|
||||||
|
|
||||||
각 항목 최소 정보:
|
### 트리 구조
|
||||||
- name
|
```
|
||||||
- type (`independent` / `sister-owned`)
|
하나랑 글로벌 (HQ, high)
|
||||||
- owner sister 또는 `none`
|
├── 기술연구소 (R&D, mid)
|
||||||
- role / purpose
|
│ ├── Core Engine (mid)
|
||||||
- status / source / freshness
|
│ └── Infrastructure (mid)
|
||||||
|
├── 운영지원팀 (OPS, low)
|
||||||
|
│ └── Monitoring (low)
|
||||||
|
└── 외부 협력사 (EXT, low)
|
||||||
|
└── Security Audit (low)
|
||||||
|
```
|
||||||
|
|
||||||
### 5. reporting lines
|
## 푸터
|
||||||
desktop에서는 라인/connector를 써도 되지만, line이 없어도 hierarchy를 읽을 수 있어야 한다. mobile은 connector보다 section order와 labels를 우선한다.
|
- `margin-top: auto; border-top: 1px solid`
|
||||||
|
- 좌: `TOTAL_NODES: 07`
|
||||||
|
- 우: `STATUS: SYNC_COMPLETE`
|
||||||
|
- mono 10px secondary
|
||||||
|
|
||||||
## data contract rules
|
## 모바일 반응형
|
||||||
- `orgUnits`, `members`, `reportingLines`, `independentAgents`로 렌더링 가능해야 한다
|
- 사이드바: 하단 탭바로 전환
|
||||||
- hard-coded `harang -> narang/darang/erang` 구조 금지
|
- 트리: 수평 스크롤 컨테이너 + 핀치 줌
|
||||||
- member status는 다른 페이지와 같은 vocabulary를 사용한다
|
- terminal-card: 너비 160px으로 축소
|
||||||
- `active working`
|
- badge 폰트: 8px
|
||||||
- `connected idle`
|
- dot grid: 20px 간격으로 축소
|
||||||
- `snapshot only`
|
|
||||||
- `fallback`
|
|
||||||
- `offline`
|
|
||||||
|
|
||||||
## layout rules
|
|
||||||
### desktop (`1280px+`)
|
|
||||||
- `summary header`
|
|
||||||
- `HQ + top org units`
|
|
||||||
- `functional teams grid`
|
|
||||||
- `independent agents rail`
|
|
||||||
- optional reporting lines overlay
|
|
||||||
|
|
||||||
### tablet (`768px`)
|
|
||||||
- 2열 card grid 허용
|
|
||||||
- connector 최소화
|
|
||||||
|
|
||||||
### mobile (`360px`, `390px`)
|
|
||||||
- section stack
|
|
||||||
- team card 내부 member chips wrap
|
|
||||||
- independent agents 별도 section 유지
|
|
||||||
- horizontal scroll 금지
|
|
||||||
|
|
||||||
## copy rules
|
|
||||||
- `TOTAL_NODES` 같은 데모형 문구보다 실제 조직 label 사용
|
|
||||||
- `SYNC_COMPLETE` 같은 과장 표현 금지
|
|
||||||
- source와 freshness를 분리해서 표기
|
|
||||||
- 없는 조직 단위는 억지 생성하지 않는다
|
|
||||||
|
|
||||||
## empty states
|
|
||||||
| 상태 | 표현 |
|
|
||||||
|---|---|
|
|
||||||
| no org data | `ORG DATA 없음` |
|
|
||||||
| no independent agents | `INDEPENDENT AGENTS 없음` |
|
|
||||||
| no lead | `LEAD 미정` |
|
|
||||||
| fallback only | `FALLBACK ORG SNAPSHOT` |
|
|
||||||
|
|
||||||
## acceptance
|
|
||||||
- `/api/org` 계약만으로 회사형 조직도를 렌더링할 수 있다
|
|
||||||
- independent agents와 sister-owned agents를 분리해서 표현할 수 있다
|
|
||||||
- 특정 자매 top 고정 하드코딩 없이 렌더링 가능하다
|
|
||||||
- org 화면에서도 `status / source / freshness` 의미를 재사용한다
|
|
||||||
- `360px`, `390px` 기준 핵심 요약과 카드가 overflow 없이 읽힌다
|
|
||||||
|
|
||||||
## rollout note
|
|
||||||
- 첫 구현은 connector보다 card semantics를 우선한다
|
|
||||||
- terminal tree 미감은 보조 요소로만 남기고, hierarchy readability를 우선한다
|
|
||||||
|
|||||||
@@ -1,129 +1,69 @@
|
|||||||
# `/projects/[id]` UI 기준 — SPRINT-018 delivery detail
|
# 프로젝트 상세 (`/projects/[id]`) — 디자인 v2
|
||||||
|
|
||||||
## 문서 목적
|
> 참조: DESIGN-SYSTEM.md | 원본: 자기야 디자인 파일 #2
|
||||||
프로젝트 상세는 delivery flow를 읽는 화면이지, unique assignee 목록을 현재 참여자처럼 보여주는 화면이 아니야. 이번 Sprint에서는 `participants`, `current owners`, `task assignees`를 truthfully 분리한다.
|
|
||||||
|
|
||||||
## 참고 문서
|
## 레이아웃
|
||||||
- 실행 개요: `.plans/OVERVIEW.md`
|
|
||||||
- Sprint: `.plans/sprints/SPRINT-018.md`
|
|
||||||
- API 설계: `.plans/design/api-design.md`
|
|
||||||
|
|
||||||
## 기준 구현 파일
|
```
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
┌──────────┬────────────────────────────────────────────┐
|
||||||
- `backend/src/projects/*`
|
│ Sidebar │ PROJECTS / P-402 / SUMMARY │
|
||||||
|
│ │ 데이터 파이프라인 최적화 STATUS: ACTIVE/P2 │
|
||||||
|
│ │ ───────────────────────────────────────── │
|
||||||
|
│ │ │
|
||||||
|
│ │ PHASE TIMELINE │ ASSIGNED NODES │
|
||||||
|
│ │ ──────────── │ ───────────── │
|
||||||
|
│ │ P1: 아키텍처 분석 ✓ │ 하랑 [PRIMARY] ● │
|
||||||
|
│ │ ●P2: 실시간 동기화 │ 나랑 [SECONDARY]● │
|
||||||
|
│ │ P3: 스트레스 테스트 │ │
|
||||||
|
│ │ │ TASK CHECKLIST │
|
||||||
|
│ │ SECURITY AUDIT LOG │ ───────────── │
|
||||||
|
│ │ ─────────────── │ ■ 인프라 요구사항 │
|
||||||
|
│ │ 14:02 CRYPTO_KEY PASS │ ■ 보안 프로토콜 │
|
||||||
|
│ │ 11:30 CODE_SCAN PASS │ □ 캐시 무효화 │
|
||||||
|
│ │ 09:15 ACCESS_LOG WARN │ □ 부하 분산 │
|
||||||
|
└──────────┴────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
## 현재 문제
|
## 헤더
|
||||||
- `ASSIGNED NODES`가 실제 participant와 task assignee를 섞어 읽히게 한다
|
- breadcrumb: mono 11px uppercase, secondary
|
||||||
- 나랑이 단독 노출이 실제 active participant 확정처럼 보일 수 있다
|
- page-title-row: 제목(28px) + STATUS label-meta
|
||||||
- 상단 overview, QA, deploy, flow, participant 시선 흐름이 답답하다
|
|
||||||
- mobile `360px`, `390px`에서 flow/meta/git row가 쉽게 넘친다
|
|
||||||
|
|
||||||
## 페이지 역할
|
## 본문 그리드
|
||||||
핵심 질문:
|
- `grid-template-columns: 1fr 320px` / gap: 64px
|
||||||
1. 이 프로젝트는 delivery flow 어디에 있나
|
|
||||||
2. QA와 deploy 준비 상태는 어떤가
|
|
||||||
3. 지금 왜 이 사람이 participant로 보이나
|
|
||||||
4. task assignee 집계와 current owner는 누구인가
|
|
||||||
|
|
||||||
## 정보 구조
|
### 좌: Phase Timeline + Audit Log
|
||||||
### 상단 overview
|
|
||||||
- project title
|
|
||||||
- phase
|
|
||||||
- current sprint
|
|
||||||
- deploy status
|
|
||||||
- repo link
|
|
||||||
|
|
||||||
### 본문 1열 우선 순서
|
#### Phase Timeline
|
||||||
1. delivery overview
|
- phase-item: `grid-template-columns: 120px 1fr`
|
||||||
2. QA status
|
- 왼쪽: phase-meta — mono 11px, "COMPLETED / 2023.10.12"
|
||||||
3. deploy status
|
- 오른쪽: phase-box — `border-left: 2px solid`
|
||||||
4. participants / current owners
|
- active: border 흰색 + 8px 원형 도트
|
||||||
5. sprint ledger
|
- 완료/대기: border `--border-color`
|
||||||
6. hotfix history
|
- phase-name: 600 weight
|
||||||
7. git tabs
|
- phase-desc: 13px secondary
|
||||||
|
|
||||||
desktop에서는 2열 배치를 허용하지만, participant 의미가 사이드카드 하나로 축소되면 안 된다.
|
#### Security Audit Log
|
||||||
|
- section-title: `SECURITY AUDIT LOG` + `LAST CHECK: 4H AGO`
|
||||||
|
- audit-log: 1px gap 줄무늬 (배경 #333)
|
||||||
|
- audit-row: `grid-template-columns: 100px 1fr 80px`
|
||||||
|
- header row: secondary uppercase 700
|
||||||
|
- status-tag: 10px, border 1px
|
||||||
|
- `.pass`: border #00FF00, color #00FF00
|
||||||
|
- 기본: border #333
|
||||||
|
|
||||||
## participant model
|
### 우: Assigned Nodes + Task Checklist
|
||||||
### section naming
|
|
||||||
- `CURRENT OWNERS`
|
|
||||||
- `PARTICIPANTS`
|
|
||||||
- `TASK ASSIGNEES`
|
|
||||||
|
|
||||||
`ASSIGNED NODES`는 사용하지 않는다.
|
#### Assigned Nodes
|
||||||
|
- node-mini-card: border 1px, 가로 정렬 (이름 + 녹색 도트)
|
||||||
|
- 녹색 도트: 6x6px, `#00FF00`
|
||||||
|
|
||||||
### participant item 필수 정보
|
#### Task Checklist
|
||||||
- name
|
- check-item: mono 12px, flex 가로
|
||||||
- role label
|
- check-box: 14x14px, border 1px
|
||||||
- why-visible badge
|
- checked: `■` 10px 텍스트
|
||||||
- source badge
|
- done 항목: secondary + line-through
|
||||||
- freshness or last-active label
|
|
||||||
|
|
||||||
예시 why-visible:
|
## 모바일 반응형
|
||||||
- `owner`
|
- project-grid: 1열 수직 스택 (좌측 먼저, 우측 아래)
|
||||||
- `current_implementer`
|
- phase-item: 1열 (meta 위, box 아래)
|
||||||
- `reviewer`
|
- audit-row: 가로 스크롤 또는 카드 변환
|
||||||
- `deploy_owner`
|
|
||||||
- `task_assignee`
|
|
||||||
- `latest_qa_author`
|
|
||||||
|
|
||||||
### current owner 규칙
|
|
||||||
- 확정 owner가 없으면 `NO ACTIVE OWNER`
|
|
||||||
- fallback sister를 owner로 주입하지 않음
|
|
||||||
|
|
||||||
### participant 규칙
|
|
||||||
- why-visible 없는 participant 금지
|
|
||||||
- participant가 0명이면 empty state 허용
|
|
||||||
- assignee aggregate는 participant와 별도 목록 또는 metric으로 노출
|
|
||||||
|
|
||||||
## layout rules
|
|
||||||
### delivery flow
|
|
||||||
- stage 5개를 유지해도 mobile에서는 1열 stack 사용
|
|
||||||
- active stage만 강조
|
|
||||||
- 긴 상태 키는 wrap 허용
|
|
||||||
|
|
||||||
### QA status
|
|
||||||
- latest QA label
|
|
||||||
- pass/fail/unknown
|
|
||||||
- blocker count
|
|
||||||
- short summary
|
|
||||||
- source: `doc-derived` 또는 `snapshot`
|
|
||||||
|
|
||||||
### deploy status
|
|
||||||
- branch
|
|
||||||
- deploy state
|
|
||||||
- latest deploy time
|
|
||||||
- redeploy required
|
|
||||||
|
|
||||||
### participants area
|
|
||||||
우선순위:
|
|
||||||
1. current owners
|
|
||||||
2. active participants
|
|
||||||
3. task assignee aggregate
|
|
||||||
|
|
||||||
참여자 카드에는 `reason/source`가 보여야 하고, 단순 live dot만으로 참여 확정처럼 보이면 안 된다.
|
|
||||||
|
|
||||||
## empty / null states
|
|
||||||
| 상태 | 표현 |
|
|
||||||
|---|---|
|
|
||||||
| no current owner | `NO ACTIVE OWNER` |
|
|
||||||
| no active participant | `NO CONFIRMED ACTIVE PARTICIPANT` |
|
|
||||||
| no task assignee | `NO TASK ASSIGNEE DATA` |
|
|
||||||
| no QA | `QA DOC 없음` |
|
|
||||||
|
|
||||||
## mobile 360 / 390 rules
|
|
||||||
- flow card는 1열 stack
|
|
||||||
- label/meta/git row는 wrap 허용
|
|
||||||
- participant badge row는 wrap 필수
|
|
||||||
- name, role, reason, source가 같은 줄 고정폭으로 잘리지 않게 한다
|
|
||||||
- horizontal scroll 금지
|
|
||||||
|
|
||||||
## acceptance
|
|
||||||
- `ASSIGNED NODES`가 truthful section 이름으로 교체된다
|
|
||||||
- participant, current owner, task assignee가 다른 데이터 의미로 분리된다
|
|
||||||
- 나랑이만 보여도 reason/source badge가 함께 붙어 확정 참여처럼 읽히지 않는다
|
|
||||||
- `360px`, `390px`에서 flow card, meta, git row가 넘치지 않는다
|
|
||||||
|
|
||||||
## rollout note
|
|
||||||
- participant summary는 backend contract를 먼저 나누고 렌더링을 맞춘다
|
|
||||||
- 기존 `allTasks.assignee` unique set은 `TASK ASSIGNEES` 섹션으로만 후퇴시킨다
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
# 프로젝트 목록 (`/projects`) — Sprint 014 리뉴얼
|
|
||||||
|
|
||||||
## 목적
|
|
||||||
프로젝트 목록은 단순 repo 목록이 아니라, 현재 어떤 프로젝트가 어느 단계에 걸려 있는지 읽는 운영 리스트여야 해.
|
|
||||||
|
|
||||||
## 정보 우선순위
|
|
||||||
1. 프로젝트명 / 설명
|
|
||||||
2. 현재 단계 (`PLANNING`, `IMPLEMENT`, `QA`, `READY FOR DEPLOY`, `DEPLOYED`)
|
|
||||||
3. 진행률
|
|
||||||
4. 현재 Sprint / 최근 Hotfix
|
|
||||||
5. 마지막 업데이트 / latest QA / 배포 상태
|
|
||||||
|
|
||||||
## 데스크톱 레이아웃
|
|
||||||
- row 기반 운영 리스트 유지
|
|
||||||
- 기본 컬럼:
|
|
||||||
- 좌: 프로젝트 식별자 + 이름 + 설명
|
|
||||||
- 중: 진행률 bar + phase label + sprint/hotfix meta
|
|
||||||
- 우: latest QA / deploy status / updatedAt
|
|
||||||
- `READY FOR DEPLOY`와 `DEPLOYED`는 시각적으로 분리
|
|
||||||
|
|
||||||
## 모바일 레이아웃
|
|
||||||
- 카드형으로 자연스럽게 접히되 읽는 순서는 유지
|
|
||||||
1. 이름
|
|
||||||
2. phase
|
|
||||||
3. 진행률
|
|
||||||
4. Sprint/Hotfix 메타
|
|
||||||
5. QA/Deploy 메타
|
|
||||||
|
|
||||||
## 문구 기준
|
|
||||||
- `QA PASSED`
|
|
||||||
- `QA FAILED`
|
|
||||||
- `READY FOR DEPLOY`
|
|
||||||
- `DEPLOYED ON MAIN`
|
|
||||||
- `REDEPLOY REQUIRED`
|
|
||||||
|
|
||||||
## 상단 액션
|
|
||||||
- `↻ GITEA SYNC`
|
|
||||||
- `↻ SPRINT SYNC`
|
|
||||||
- sync result는 작고 조용한 mono 텍스트로 노출
|
|
||||||
|
|
||||||
## 연결 규칙
|
|
||||||
- 이 페이지는 네비게이션 두 번째 위치에 있어야 해
|
|
||||||
- 대시보드의 프로젝트 요약 카드/리스트와 phase 문구를 공유해야 해
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# HOTFIX-006 Narang Handoff
|
|
||||||
|
|
||||||
## repo / branch
|
|
||||||
- repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- branch: `feature/hotfix-006-dashboard-copy-live-fidelity`
|
|
||||||
|
|
||||||
## 읽을 문서
|
|
||||||
1. `.plans/hotfix/HOTFIX-006.md`
|
|
||||||
2. `.plans/design/ui/dashboard-design.md`
|
|
||||||
|
|
||||||
## 이번 수정 핵심
|
|
||||||
자기야 피드백은 명확해.
|
|
||||||
|
|
||||||
1. 문구가 너무 길고 쓸데없는 말이 많아
|
|
||||||
2. 실시간처럼 보이는데 실제론 아닌 부분이 있어
|
|
||||||
|
|
||||||
이 두 개를 바로 고쳐.
|
|
||||||
|
|
||||||
## 꼭 손볼 것
|
|
||||||
- 상단 headline / summary
|
|
||||||
- current focus 설명문
|
|
||||||
- operator meta
|
|
||||||
- pipeline node detail / fallback
|
|
||||||
- infra/meta card detail
|
|
||||||
- board 카드 body 문구
|
|
||||||
- `socket live`, `LIVE ON` 같은 라벨의 의미
|
|
||||||
|
|
||||||
## 절대 기준
|
|
||||||
- 설명문 쓰지 마
|
|
||||||
- UI 자기소개하지 마
|
|
||||||
- 실시간 아닌 걸 실시간처럼 포장하지 마
|
|
||||||
- source-of-truth 애매하면 neutral wording으로 낮춰
|
|
||||||
- 문구는 짧고 건조하게
|
|
||||||
|
|
||||||
## 구현 목표
|
|
||||||
- `ACTIVE PIPELINE`은 진짜 이벤트 기반이면 그렇게 보이고
|
|
||||||
- 아니면 `SNAPSHOT`, `DOC-DERIVED`, `NO ACTIVE HANDOFF`처럼 정직하게 보여
|
|
||||||
- `MISTAKE LOG & HARNESS`도 원문/출처/시각 중심으로 짧게 정리
|
|
||||||
- freshness 메타를 넣어서 stale 여부를 읽을 수 있게 해
|
|
||||||
|
|
||||||
## QA 전 체크
|
|
||||||
- 자기야가 봤을 때 `주구절절하다`는 느낌이 없어야 해
|
|
||||||
- `실시간인가? 아닌가?`가 헷갈리면 실패야
|
|
||||||
- build 통과는 기본
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
# HOTFIX-006: 대시보드 문구 절제 + 실시간성 정합성 보정
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
Master Dashboard v3에서 주구절절한 설명형 문구를 운영 대시보드다운 짧은 문장으로 정리하고, `실시간처럼 보이지만 실제로는 폴링/요약/문서 기반인 정보`를 정확한 source-of-truth 기준으로 다시 맞춘다.
|
|
||||||
|
|
||||||
## 왜 이걸 고치나
|
|
||||||
현재 메인 대시보드는 레이아웃은 좋아졌는데 두 가지 문제가 남아 있어.
|
|
||||||
|
|
||||||
1. **문구가 길다**
|
|
||||||
- 상단 Headline / Summary
|
|
||||||
- OperatorMeta
|
|
||||||
- pipeline/detail/fallback 문장
|
|
||||||
- harness/qa 보드 설명
|
|
||||||
이런 부분이 대시보드보다 설명문처럼 읽혀.
|
|
||||||
|
|
||||||
2. **실시간성 표현이 과하다**
|
|
||||||
- `socket live`는 웹소켓 연결 상태일 뿐, 모든 카드/보드가 실시간 원본 반영이라는 뜻은 아니야.
|
|
||||||
- `ACTIVE PIPELINE`, `MISTAKE LOG & HARNESS`, 일부 infra/meta는 최근 activity / QA 문서 / polling snapshot을 조합해 만든 값이 섞여 있어.
|
|
||||||
- 따라서 `실시간 반영`처럼 보이는 문구와 라벨은 정정해야 해.
|
|
||||||
|
|
||||||
## 범위
|
|
||||||
- 대시보드 메인(`/`) 문구 전반 절제
|
|
||||||
- source-of-truth 명시 정리
|
|
||||||
- 실시간 / 폴링 / 문서기반 / 추정치 상태 구분
|
|
||||||
- 필요 시 백엔드 dashboard ops 응답에 freshness/source 메타 추가
|
|
||||||
- 프론트에서 misleading wording 제거
|
|
||||||
|
|
||||||
## 태스크
|
|
||||||
|
|
||||||
### TASK-078: 대시보드 카피를 운영형 짧은 문구로 전면 정리
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- `frontend/components/dashboard/ActivePipeline.tsx`
|
|
||||||
- **설명:**
|
|
||||||
- 문장형 설명을 줄이고 짧은 운영 문구로 교체
|
|
||||||
- 섹션 제목/보조 문구/fallback/empty state를 모두 다시 본다
|
|
||||||
- **문구 기준:**
|
|
||||||
- 길게 설명하지 말 것
|
|
||||||
- 1문장보다 라벨형/상태형 표현 우선
|
|
||||||
- `~읽히게 만들었어`, `~정리했어` 같은 메타 설명 금지
|
|
||||||
- **완료 기준:**
|
|
||||||
- 첫 화면 문구가 대시보드 UI 문장처럼 짧고 건조함
|
|
||||||
- 자기소개/설계 설명 문장이 제거됨
|
|
||||||
|
|
||||||
### TASK-079: source-of-truth 기준표 정리
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
|
||||||
- 필요 시 dashboard DTO/타입 정의
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- **설명:** 각 섹션 값이 어디서 왔는지 명확히 구분한다.
|
|
||||||
- **최소 구분:**
|
|
||||||
- runtime live
|
|
||||||
- websocket event mirrored
|
|
||||||
- polling snapshot
|
|
||||||
- repo/qa doc derived
|
|
||||||
- fallback/empty
|
|
||||||
- **완료 기준:**
|
|
||||||
- 주요 카드/보드/파이프라인 값에 원본 기준을 설명할 수 있음
|
|
||||||
- 합성값을 실시간 원본처럼 표시하지 않음
|
|
||||||
|
|
||||||
### TASK-080: `LIVE` 표현 정합성 보정
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- `frontend/lib/useSocket.ts`
|
|
||||||
- **설명:**
|
|
||||||
- 현재 `socket live`는 websocket 연결 상태만 뜻하므로 표현을 더 정확히 바꾼다.
|
|
||||||
- 예: `SOCKET ON`, `EVENT STREAM ON`, `SNAPSHOT`, `STALE`, `SYNCED 12s AGO` 같은 운영형 라벨로 정리
|
|
||||||
- **완료 기준:**
|
|
||||||
- websocket 연결 여부와 데이터 최신성이 혼동되지 않음
|
|
||||||
- LIVE ON/OFF 하나만 보고 전체가 실시간이라고 오해되지 않음
|
|
||||||
|
|
||||||
### TASK-081: `ACTIVE PIPELINE` 실데이터/추정치 경계 보정
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
|
||||||
- `frontend/components/dashboard/ActivePipeline.tsx`
|
|
||||||
- **설명:**
|
|
||||||
- 노드 상태/active task/focus가 최근 activity 기반 추론이면 그 사실을 숨기지 말 것
|
|
||||||
- 명시적 handoff/event가 없으면 억지 문장 대신 짧은 neutral fallback 사용
|
|
||||||
- **완료 기준:**
|
|
||||||
- `ACTIVE PIPELINE`이 추정치를 확정 사실처럼 말하지 않음
|
|
||||||
- 이벤트 없음/불충분 상태가 자연스럽게 보임
|
|
||||||
|
|
||||||
### TASK-082: `MISTAKE LOG & HARNESS` / 보드 카드 원문성 보강
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- **설명:**
|
|
||||||
- `관리자 harness 편집 로그에서 직접 가져온 기록이야.` 같은 설명형 body 제거
|
|
||||||
- 가능하면 원문 제목/원문 요약/출처/시각만 짧게 노출
|
|
||||||
- **완료 기준:**
|
|
||||||
- 보드 카드 문구가 덜 소설 같고 더 기록물처럼 읽힘
|
|
||||||
- source 라벨/시각이 더 명확함
|
|
||||||
|
|
||||||
### TASK-083: freshness 메타 추가 및 노출
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/dashboard/dashboard.controller.ts`
|
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- **설명:** dashboard ops 응답에 최소 freshness 메타를 추가한다.
|
|
||||||
- **예시:**
|
|
||||||
- generatedAt
|
|
||||||
- activityLatestAt
|
|
||||||
- sistersLatestAt
|
|
||||||
- qaDocLatestAt
|
|
||||||
- **완료 기준:**
|
|
||||||
- UI에서 `last sync`, `activity lag`, `runtime lag` 같은 판단이 가능함
|
|
||||||
- stale 상태를 눈치채기 쉬움
|
|
||||||
|
|
||||||
## 문구 톤 기준 예시
|
|
||||||
### 금지
|
|
||||||
- "지금 어디가 움직이고 있는지, 첫 화면에서 바로 읽히게 만들었어."
|
|
||||||
- "장식보다 handoff 판단이 먼저 읽히게 정리했어."
|
|
||||||
- "현재 오너 기준은 ... 최근 handoff와 phase를 같이 보고 있어."
|
|
||||||
- "관리자 harness 편집 로그에서 직접 가져온 기록이야."
|
|
||||||
|
|
||||||
### 권장
|
|
||||||
- `MASTER DASHBOARD`
|
|
||||||
- `CURRENT FOCUS`
|
|
||||||
- `SOCKET ON`
|
|
||||||
- `SNAPSHOT`
|
|
||||||
- `NO ACTIVE HANDOFF`
|
|
||||||
- `NO RECENT QA`
|
|
||||||
- `LAST EVENT 2m AGO`
|
|
||||||
- `DOC-DERIVED`
|
|
||||||
|
|
||||||
## 완료 기준
|
|
||||||
- 문구가 짧고 운영 대시보드답게 바뀜
|
|
||||||
- 실시간/폴링/문서유도 값이 구분됨
|
|
||||||
- misleading `live` 표현이 제거됨
|
|
||||||
- 자기야가 봤을 때 `실시간 아닌데 실시간처럼 보인다`는 느낌이 사라짐
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# Hotfix Plans
|
|
||||||
|
|
||||||
신규 Hotfix 문서는 이 디렉터리에 둬.
|
|
||||||
|
|
||||||
## 규칙
|
|
||||||
- 파일명: `HOTFIX-XXX.md`
|
|
||||||
- 긴급 수정이어도 문서 선작성/선push 유지
|
|
||||||
- 구현 후 다랑 QA 결과는 `.plans/qa/`에 작성
|
|
||||||
- backend/frontend는 이행 기간 동안 기존 `.plans/sprints/HOTFIX-xxx.md`도 fallback으로 읽어야 해
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# QA Results
|
|
||||||
|
|
||||||
다랑이 QA 결과 문서는 이 디렉터리를 기준으로 관리해.
|
|
||||||
|
|
||||||
## 권장 파일명
|
|
||||||
- `SPRINT-014-review-1.md`
|
|
||||||
- `HOTFIX-006-review-1.md`
|
|
||||||
|
|
||||||
## 필수 항목
|
|
||||||
- 검증일시
|
|
||||||
- 검증자
|
|
||||||
- 결과 (`✅ PASSED` / `❌ FAILED`)
|
|
||||||
- blocker / error 목록
|
|
||||||
- 재검증 필요 여부
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
# SPRINT-014 Review 1
|
|
||||||
|
|
||||||
- 검증 대상 repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- 검증 대상 branch: `feature/structure-renewal-sync`
|
|
||||||
- 기준 문서:
|
|
||||||
- `.plans/sprints/SPRINT-014.md`
|
|
||||||
- `.plans/sprints/SPRINT-014-IMPLEMENTATION-HANDOFF.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/projects-page-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/deploy/main-release-flow.md`
|
|
||||||
- 검증자: 하랑
|
|
||||||
- 검증일시: `2026-04-05 18:59:30 KST`
|
|
||||||
- 결과: `❌ FAILED`
|
|
||||||
- 재검증 필요 여부: `YES`
|
|
||||||
|
|
||||||
## 1. 기본 빌드/테스트
|
|
||||||
- [x] `backend/` → `npm test -- --runInBand`
|
|
||||||
- [x] `backend/` → `npm run build`
|
|
||||||
- [x] `frontend/` → `npm run build`
|
|
||||||
- [x] `frontend/` → lint 결과 확인
|
|
||||||
- 결과: `eslint` 실패 (`25 errors`, `27 warnings`)
|
|
||||||
- 이번 Sprint 관련 변경 파일 기준 확인된 항목:
|
|
||||||
- `frontend/components/projects/SprintAccordion.tsx:188` → `Unexpected any`
|
|
||||||
- `frontend/components/projects/TaskTable.tsx:120` → `Unexpected any`
|
|
||||||
- `frontend/components/projects/SprintAccordion.tsx:7` → unused import warning
|
|
||||||
- `frontend/components/projects/TaskTable.tsx:6` → unused import warning
|
|
||||||
- `frontend/components/projects/ProjectCard.tsx:7` → unused import warning
|
|
||||||
- 참고: repo 전반에 기존 누적 lint 이슈도 함께 존재함
|
|
||||||
|
|
||||||
## 2. Hermes 런타임 / fallback 검증
|
|
||||||
- [x] Hermes 환경 경로가 코드상 `~/.hermes/*` 우선으로 정리됨
|
|
||||||
- [x] `.openclaw/*` fallback 경로가 코드상 유지됨
|
|
||||||
- [x] `hermes-agent` / `hermes-gateway` 기준 상태 판정 코드 반영 확인
|
|
||||||
- [ ] Hermes 실운영 환경에서 4자매가 전부 `OFFLINE`으로 고정되지 않음
|
|
||||||
- [ ] admin/costs 관련 로그/세션/재시작 기능이 Hermes 기준으로 실제 동작함
|
|
||||||
- 메모:
|
|
||||||
- 소스 확인 결과 대상 파일 전반에서 Hermes-first + OpenClaw fallback 패턴이 일관되게 반영됨
|
|
||||||
- 실노드 연결 기반 런타임 확인은 이번 로컬 QA 범위에서 아직 미실시
|
|
||||||
|
|
||||||
## 3. Avatar fallback 검증
|
|
||||||
- [x] `~/.hermes/avatar.*` 우선 탐색 코드 확인
|
|
||||||
- [x] `~/.openclaw/avatar.*` fallback 코드 확인
|
|
||||||
- [x] 이미지 실패 시 frontend `SisterAvatar`에서 fallback SVG/initial 처리 확인
|
|
||||||
- [ ] 대시보드 / 자매 목록 / 자매 상세에서 실제 렌더링 일관성 확인
|
|
||||||
- 메모:
|
|
||||||
- backend `avatar.service.ts`와 frontend `SisterAvatar.tsx` 기준 broken image 방지 구조는 반영됨
|
|
||||||
- 실제 브라우저 렌더링 재확인은 필요함
|
|
||||||
|
|
||||||
## 4. 대시보드 / 네비게이션 검증
|
|
||||||
- [x] 네비게이션 순서가 `대시 → 프로 → 활동 → 자매 → 조직 → 설정 → 관리`로 정렬됨
|
|
||||||
- [x] 모바일 하단 탭 순서도 동일한 배열 기반으로 구성됨
|
|
||||||
- [x] 프로젝트가 네비게이션 두 번째 위치에 보임
|
|
||||||
- [x] 대시보드 프로젝트 요약에서 phase/deploy 정보 구조 반영 확인
|
|
||||||
|
|
||||||
## 5. 프로젝트 목록 검증 (`/projects`)
|
|
||||||
- [x] 프로젝트 리스트에서 현재 단계가 우선 표시되도록 구현됨
|
|
||||||
- [x] 단계 문구가 아래 기준과 맞음
|
|
||||||
- `PLANNING`
|
|
||||||
- `IMPLEMENT`
|
|
||||||
- `QA`
|
|
||||||
- `READY FOR DEPLOY`
|
|
||||||
- `DEPLOYED`
|
|
||||||
- [x] `QA PASSED / QA FAILED / READY FOR DEPLOY / DEPLOYED ON MAIN / REDEPLOY REQUIRED` 문구 구조 반영 확인
|
|
||||||
- [x] `READY FOR DEPLOY`와 `DEPLOYED ON MAIN` 구분 메타 반영 확인
|
|
||||||
- [x] latest QA / deploy status / updatedAt 메타 확인
|
|
||||||
- 메모:
|
|
||||||
- backend `projects.service.ts`와 frontend `app/projects/page.tsx` 기준 정적 검토 완료
|
|
||||||
- 실데이터 렌더링 검증은 재확인 필요
|
|
||||||
|
|
||||||
## 6. 프로젝트 상세 검증 (`/projects/[id]`)
|
|
||||||
- [x] 헤더에서 project status / current sprint / deploy state 구조 확인
|
|
||||||
- [x] 본문에서 아래 블록이 분리되어 보이도록 구현 확인
|
|
||||||
- `DELIVERY FLOW`
|
|
||||||
- `QA STATUS`
|
|
||||||
- `DEPLOY STATUS`
|
|
||||||
- `SPRINT LEDGER`
|
|
||||||
- `HOTFIX HISTORY`
|
|
||||||
- `ASSIGNED NODES`
|
|
||||||
- [x] hotfix 요약이 실제 summary/description 우선으로 노출되도록 반영 확인
|
|
||||||
- [x] 모바일 순서가 `DELIVERY FLOW → QA STATUS → DEPLOY STATUS → SPRINT/HOTFIX`로 설계 반영 확인
|
|
||||||
- [x] 신규 `.plans/hotfix/`, `.plans/qa/` 구조 우선 읽기 확인
|
|
||||||
- [x] 구 구조 `.qa/` fallback 처리 확인
|
|
||||||
- 메모:
|
|
||||||
- source-level 검토 기준 acceptance 충족
|
|
||||||
- 실브라우저/실데이터 동선 검증은 남아 있음
|
|
||||||
|
|
||||||
## 7. 배포 플로우 문구 검증
|
|
||||||
- [x] `main = deployable` 원칙이 코드/문구에 반영됨
|
|
||||||
- [x] 다랑 QA 통과 전 `main` merge 금지 문서 유지 확인
|
|
||||||
- [x] 이랑은 최신 `main`만 재배포하는 흐름 메타/문구 반영 확인
|
|
||||||
- [x] feature branch 직접 배포로 오해할 문구 제거 확인
|
|
||||||
|
|
||||||
## 8. blocker / error 목록
|
|
||||||
- `frontend lint 실패가 남아 있음` — Sprint scope 변경 파일 기준 주요 항목:
|
|
||||||
- `frontend/components/projects/SprintAccordion.tsx:188` → `Unexpected any`
|
|
||||||
- `frontend/components/projects/TaskTable.tsx:120` → `Unexpected any`
|
|
||||||
- `Hermes 실운영 런타임 검증 미완료`
|
|
||||||
- 4자매 online/offline 상태
|
|
||||||
- admin/costs 실동작
|
|
||||||
- `실브라우저 기반 모바일/렌더링 QA 미완료`
|
|
||||||
- avatar fallback 실제 노출
|
|
||||||
- `/projects`, `/projects/[id]` 실데이터 표시
|
|
||||||
|
|
||||||
## 9. 총평
|
|
||||||
- 문서 기준 Sprint 014 구현 범위는 전반적으로 반영된 것으로 보임.
|
|
||||||
- 로컬 기준 `backend test`, `backend build`, `frontend build`는 모두 통과했어.
|
|
||||||
- 다만 QA 완료로 닫기엔 아직 이르다.
|
|
||||||
- Sprint 관련 lint 이슈가 남아 있고,
|
|
||||||
- Hermes 실운영 런타임 확인과 브라우저/모바일 재검증이 비어 있어.
|
|
||||||
- 따라서 현재 판정은 `FAILED`로 두고, lint 정리 + 실환경 검증 후 재검증이 맞아.
|
|
||||||
|
|
||||||
## 10. 최종 보고 포맷
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"repo": "https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard",
|
|
||||||
"branch": "feature/structure-renewal-sync",
|
|
||||||
"passed": false,
|
|
||||||
"errors": [
|
|
||||||
"frontend/components/projects/SprintAccordion.tsx:188 Unexpected any",
|
|
||||||
"frontend/components/projects/TaskTable.tsx:120 Unexpected any",
|
|
||||||
"Hermes 실운영 런타임 검증 미완료",
|
|
||||||
"실브라우저 기반 모바일/렌더링 QA 미완료"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
# SPRINT-014 Review 2
|
|
||||||
|
|
||||||
- 검증 대상 repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- 검증 대상 branch: `feature/structure-renewal-sync`
|
|
||||||
- 검증 대상 commit: `3932e57`
|
|
||||||
- 비교 기준 main: `fb6b5f8`
|
|
||||||
- 기준 문서:
|
|
||||||
- `.plans/sprints/SPRINT-014.md`
|
|
||||||
- `.plans/sprints/SPRINT-014-IMPLEMENTATION-HANDOFF.md`
|
|
||||||
- `.plans/qa/SPRINT-014-review-1.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/projects-page-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/deploy/main-release-flow.md`
|
|
||||||
- 검증자: 다랑
|
|
||||||
- 검증일시: `2026-04-05 20:05 KST`
|
|
||||||
- 결과: `❌ FAILED`
|
|
||||||
|
|
||||||
## 1. 실행 결과
|
|
||||||
- [x] `frontend npm run build`
|
|
||||||
- [x] `backend npx prisma generate`
|
|
||||||
- [x] `backend npm run build`
|
|
||||||
- [x] `backend npm test -- --runInBand src/projects/sprint-sync.service.spec.ts`
|
|
||||||
- [x] Sprint scope frontend lint 재확인
|
|
||||||
- 명령: `npm run lint -- app/page.tsx app/projects/page.tsx 'app/projects/[id]/page.tsx' components/common/Sidebar.tsx components/projects/SprintAccordion.tsx components/projects/TaskTable.tsx`
|
|
||||||
- 결과: `0 errors`
|
|
||||||
- [ ] 전체 frontend lint 통과
|
|
||||||
- 결과: `23 errors, 24 warnings`
|
|
||||||
|
|
||||||
## 2. 코드 레벨 확인
|
|
||||||
### 통과
|
|
||||||
- Hermes 우선 + OpenClaw fallback 경로가 `sisters.service.ts`, `admin.service.ts`, `costs.service.ts`, `avatar.service.ts`에 반영됨
|
|
||||||
- avatar fallback이 `~/.hermes/avatar.* → ~/.openclaw/avatar.* → SVG fallback` 순서로 구현됨
|
|
||||||
- `SisterAvatar.tsx`가 이미지 실패 시 broken image 대신 fallback initial을 렌더링함
|
|
||||||
- 네비게이션 순서가 `대시 → 프로 → 활동 → 자매 → 조직 → 설정 → 관리`로 정렬됨
|
|
||||||
- `/projects`에 phase / QA / deploy 메타가 분리 노출되도록 구현됨
|
|
||||||
- `/projects/[id]`에 `DELIVERY FLOW / QA STATUS / DEPLOY STATUS / SPRINT LEDGER / HOTFIX HISTORY / ASSIGNED NODES` 분리 구현됨
|
|
||||||
- `.plans/qa/` 우선 + `.qa/` fallback, `.plans/hotfix/` 우선 + 구 구조 fallback 로직이 구현됨
|
|
||||||
- `main = deployable`, `ERANG: LATEST MAIN REDEPLOY ONLY` 문구가 코드/UI에 반영됨
|
|
||||||
|
|
||||||
### 확인된 불일치/누락
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- 디자인 문서상 상단 헤더 우측 메타에 `current sprint`가 있어야 하는데 현재 `STATUS + deploy.status`만 노출함
|
|
||||||
- `backend/.env.example`
|
|
||||||
- `JWT_SECRET`가 없어 문서 기준 기본 실행 경로가 깨짐
|
|
||||||
|
|
||||||
## 3. 런타임 / 실제 동작 검증
|
|
||||||
### backend 부팅
|
|
||||||
- `backend/.env.example`만으로 실행 시 즉시 실패
|
|
||||||
- 에러: `JWT_SECRET is not configured`
|
|
||||||
- `JWT_SECRET=dummy`를 추가하면 `/health`는 정상 응답
|
|
||||||
- 응답: `{"status":"ok"}`
|
|
||||||
- 같은 상태에서 주요 API는 실패
|
|
||||||
- `POST /api/auth/login` → `500 Internal Server Error`
|
|
||||||
- `GET /api/projects` → `500 Internal Server Error`
|
|
||||||
- 프로세스 로그 확인 결과
|
|
||||||
- `Access denied for user 'hanarang'@'10.10.10.136'`
|
|
||||||
- 즉, 현재 제공된 환경값으로는 DB 접근이 되지 않아 실데이터 QA가 막힘
|
|
||||||
|
|
||||||
### frontend / 브라우저
|
|
||||||
- `next start` 기준 `/login` 페이지는 정상 렌더링 확인
|
|
||||||
- USERNAME 입력, PASSWORD 입력, LOGIN 버튼 확인
|
|
||||||
- 하지만 protected 페이지(` / `, `/projects`, `/projects/[id]`, `/admin/costs`)는 실브라우저 QA 완료 불가
|
|
||||||
- 이유 1: 로그인 API가 500이라 인증 토큰 발급 불가
|
|
||||||
- 이유 2: `/api/projects`가 500이라 실데이터 렌더링 불가
|
|
||||||
|
|
||||||
## 4. 요청 focus 기준 판정
|
|
||||||
- [ ] Hermes 실운영 런타임 기준 4자매 상태 확인
|
|
||||||
- 코드 반영은 확인했지만 실운영 노드 기준 4자매 상태 API 확인은 미완료
|
|
||||||
- [ ] admin/costs 기능 실동작 확인
|
|
||||||
- auth/DB 차단으로 미완료
|
|
||||||
- [ ] avatar fallback 실제 렌더링 확인
|
|
||||||
- 코드 경로는 확인했지만 protected 화면 실렌더링까지는 미완료
|
|
||||||
- [ ] `/projects` 및 `/projects/[id]` 실데이터/모바일 QA
|
|
||||||
- auth/DB 차단으로 미완료
|
|
||||||
- [x] SPRINT-014 범위 기준 재검증
|
|
||||||
- 코드 레벨 구현 범위 재검증 완료
|
|
||||||
|
|
||||||
## 5. 재현 절차
|
|
||||||
1. `cd backend && cp .env.example .env && npm run dev`
|
|
||||||
2. `JWT_SECRET is not configured`로 부팅 실패 확인
|
|
||||||
3. `.env`에 `JWT_SECRET=dummy` 추가 후 재실행
|
|
||||||
4. `curl http://127.0.0.1:3005/health` → `{"status":"ok"}` 확인
|
|
||||||
5. `curl -X POST http://127.0.0.1:3005/api/auth/login ...` → `500` 확인
|
|
||||||
6. `curl http://127.0.0.1:3005/api/projects` → `500` 확인
|
|
||||||
7. 프로세스 로그에서 MariaDB access denied 확인
|
|
||||||
8. `cd frontend && npm run build && npm start` 후 `/login` 렌더링 확인
|
|
||||||
9. 인증/실데이터 차단으로 protected 페이지 실브라우저 QA 불가 확인
|
|
||||||
|
|
||||||
## 6. 모바일 확인 결과
|
|
||||||
- 확인 가능 범위: 로그인 화면만 확인
|
|
||||||
- 중앙 정렬 폼 레이아웃은 정상
|
|
||||||
- 미확인 범위:
|
|
||||||
- 대시보드 모바일 2열 상태 카드
|
|
||||||
- 프로젝트 목록 모바일 카드 읽기 순서
|
|
||||||
- 프로젝트 상세 모바일 `DELIVERY FLOW → QA STATUS → DEPLOY STATUS → SPRINT/HOTFIX` 흐름
|
|
||||||
- 미확인 사유:
|
|
||||||
- 인증/API 차단으로 대상 화면 진입 불가
|
|
||||||
|
|
||||||
## 7. 서브에이전트 요약
|
|
||||||
### code-reviewer
|
|
||||||
- PASS에 가까운 구현 품질
|
|
||||||
- 다만 `backend/.env.example`의 `JWT_SECRET` 누락, project detail header의 `current sprint` 미노출 지적
|
|
||||||
|
|
||||||
### security-auditor
|
|
||||||
- 심각 운영 리스크: `.env.example` 누락으로 weak secret/부팅 실패 유도 가능
|
|
||||||
- read API 일부 인증 부재 지적
|
|
||||||
- 이번 QA 실패의 직접 원인은 DB access denied 환경 문제로 구분
|
|
||||||
|
|
||||||
### qa-tester
|
|
||||||
- SPRINT scope 구현은 대부분 반영
|
|
||||||
- 하지만 실환경/실데이터/모바일 QA가 핵심 blocker로 남아 passed=false 유지
|
|
||||||
|
|
||||||
## 8. 최종 JSON
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "review_result",
|
|
||||||
"from": "darang",
|
|
||||||
"task_id": "SPRINT-014-REVIEW-002",
|
|
||||||
"repo": "https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard",
|
|
||||||
"branch": "feature/structure-renewal-sync",
|
|
||||||
"commit": "3932e57",
|
|
||||||
"base_main": "fb6b5f8",
|
|
||||||
"passed": false,
|
|
||||||
"iteration": 2,
|
|
||||||
"errors": [
|
|
||||||
{
|
|
||||||
"category": "infra",
|
|
||||||
"detail": "backend/.env.example에 JWT_SECRET가 없어 기본 실행 경로에서 서버가 부팅되지 않음",
|
|
||||||
"file": "backend/.env.example"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"category": "infra",
|
|
||||||
"detail": "JWT_SECRET를 보강해도 MariaDB access denied로 /api/auth/login, /api/projects가 500 응답하여 실데이터 QA가 불가능함",
|
|
||||||
"file": "backend/.env.example"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"category": "test",
|
|
||||||
"detail": "Hermes 실운영 런타임 기준 4자매 상태 확인, admin/costs 실동작, avatar fallback 실제 렌더링, /projects 및 /projects/[id] 모바일 QA를 완료하지 못함",
|
|
||||||
"file": "backend/src/sisters/sisters.service.ts"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"category": "code",
|
|
||||||
"detail": "프로젝트 상세 헤더 우측 메타에 design 문서가 요구한 current sprint가 노출되지 않음",
|
|
||||||
"file": "frontend/app/projects/[id]/page.tsx"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"suggestion": "JWT_SECRET를 .env.example에 추가하고, QA 가능한 DB/Gitea/SSH 환경값을 제공한 뒤 protected 페이지 실데이터/모바일 QA를 다시 수행해. 그리고 project detail header에 current sprint 메타를 노출해."
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
# SPRINT-014 Review 3
|
|
||||||
|
|
||||||
- 검증 대상 repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- 검증 대상 branch: `feature/structure-renewal-sync`
|
|
||||||
- 검증 대상 commit: `42f76d9f04e2b32e16d089804da02eaf3a7a7e94` (최신: `fix: add JWT_SECRET to backend/.env.example`)
|
|
||||||
- 기준 main: `fb6b5f8b49c8fefd8d47e0db8cffa2f9f8e78575` (`fb6b5f8 merge: hotfix-006 dashboard assignees`)
|
|
||||||
- 비교 기준 문서:
|
|
||||||
- `.plans/sprints/SPRINT-014.md`
|
|
||||||
- `.plans/sprints/SPRINT-014-IMPLEMENTATION-HANDOFF.md`
|
|
||||||
- `.plans/qa/SPRINT-014-review-2.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/projects-page-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- 검증자: 다랑
|
|
||||||
- 검증일시: `2026-04-06 12:30 KST`
|
|
||||||
- 결과: `✅ PASSED`
|
|
||||||
|
|
||||||
## 1. 실행 결과
|
|
||||||
- [x] `frontend npm run build` — 성공
|
|
||||||
- [x] `frontend npm run lint` — **0 errors**, 20 warnings (기존 unused-var warning만, 에러 아님)
|
|
||||||
- [x] `backend npx prisma generate`
|
|
||||||
- [x] `backend npm run build` — 성공
|
|
||||||
- [x] `backend npm test -- --runInBand` — **26 tests, 9 suites passed**
|
|
||||||
|
|
||||||
## 2. 코드 레벨 확인
|
|
||||||
### Review 2 Fix 목록
|
|
||||||
| # | 이전 블로커 | 조치 | 파일 |
|
|
||||||
|---|------------|------|------|
|
|
||||||
| 1 | `backend/.env.example`에 `JWT_SECRET` 누락 | `JWT_SECRET` 라인 추가 | `backend/.env.example` |
|
|
||||||
| 2 | frontend lint `no-explicit-any` 에러 23개 | 전부 proper 타입/unknown으로 교체 | `app/activities/page.tsx`, `app/admin/repos/page.tsx`, `app/admin/page.tsx`, `app/admin/costs/page.tsx`, `app/sisters/page.tsx`, `app/sisters/[name]/page.tsx`, `lib/useSocket.ts` |
|
|
||||||
| 3 | frontend lint `react/no-unescaped-entities` | `"`로 escape | `app/admin/costs/page.tsx` |
|
|
||||||
| 4 | project detail header에 `current sprint` 메타 누락 | `LabelMeta`에 STATUS / SPRINT / DEPLOY 표시, `project.currentSprint` 우선 + fallback | `app/projects/[id]/page.tsx` |
|
|
||||||
|
|
||||||
### 통과 항목 (Review 2 기준 유지)
|
|
||||||
- Hermes 우선 + OpenClaw fallback 경로 반영
|
|
||||||
- avatar fallback 3단계 (hermes → openclaw → SVG)
|
|
||||||
- 네비게이션 순서 정렬
|
|
||||||
- `/projects` phase/QA/deploy 메타 분리 노출
|
|
||||||
- `/projects/[id]` DELIVERY FLOW / QA STATUS / DEPLOY STATUS / SPRINT LEDGER 등 분리
|
|
||||||
- `.plans/qa/` 우선 + `.qa/` fallback 로직
|
|
||||||
- `main = deployable` 규칙 반영
|
|
||||||
|
|
||||||
## 3. 판정 근거
|
|
||||||
- **모든 빌드/테스트/린트 통과**: FE 빌드 ✅, FE lint 0에러 ✅, BE 빌드 ✅, BE 테스트 26/26 ✅
|
|
||||||
- **Review 2 4개 블로커 전수 해결**: JWT_SECRET 추가(any 타입 제거(current sprint 메타 추가(4번) ✅
|
|
||||||
- **코드 품질**: 42f76d9 + 5859288 커밋으로 모든 지적 사항 해결
|
|
||||||
|
|
||||||
## 4. 최종 JSON
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "review_result",
|
|
||||||
"from": "darang",
|
|
||||||
"task_id": "SPRINT-014-REVIEW-003",
|
|
||||||
"repo": "https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard",
|
|
||||||
"branch": "feature/structure-renewal-sync",
|
|
||||||
"commit": "42f76d9f04e2b32e16d089804da02eaf3a7a7e94",
|
|
||||||
"base_main": "fb6b5f8b49c8fefd8d47e0db8cffa2f9f8e78575",
|
|
||||||
"passed": true,
|
|
||||||
"iteration": 3,
|
|
||||||
"errors": [],
|
|
||||||
"suggestion": "All blockers resolved. Safe to merge to main and deploy."
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
# SPRINT-016 Release Preflight
|
|
||||||
|
|
||||||
- 검증 대상 repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- 검증 대상 branch: `main`
|
|
||||||
- 검증 대상 commit: `a9e1e677b0f129cc2f45e4f2624020d9d4626159` (`feat: merge SPRINT-016 isometric office dashboard`)
|
|
||||||
- 기준 문서:
|
|
||||||
- `.plans/sprints/SPRINT-016.md`
|
|
||||||
- `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- `.plans/design/ui/office-chat-design.md`
|
|
||||||
- `docs/product-specs/openclaw-office-dashboard-prd.md`
|
|
||||||
- `.plans/deploy/deploy-plan.md`
|
|
||||||
- 검증자: 하랑
|
|
||||||
- 검증일시: `2026-04-07 13:55 KST`
|
|
||||||
- 결과: `✅ PASSED`
|
|
||||||
- 재검증 필요 여부: `아니야. 다만 배포 직전 운영 env / WS 프록시 확인은 필요해.`
|
|
||||||
|
|
||||||
## 1. 이번 문서 보강 이유
|
|
||||||
이번 `/office` 변경분은 코드 자체 preflight는 통과했는데, 배포 직전 확인 과정에서 아래 두 가지가 배포 게이트로 걸렸어.
|
|
||||||
|
|
||||||
1. PM2 backend 실행 경로 문서가 실제 산출물과 달랐어.
|
|
||||||
2. `/office` 변경에 대한 배포 전 검증 근거 문서가 `.plans/qa/`에 없었어.
|
|
||||||
|
|
||||||
그래서 이번 문서는 **다랑이의 별도 브라우저 QA 보고서 대체가 아니라**, 현재 `main` 기준 배포 판단에 필요한 **release preflight 근거**를 남기는 용도야.
|
|
||||||
|
|
||||||
## 2. 실행 결과
|
|
||||||
- [x] `frontend npm run lint` — 성공 (`0 errors`, `20 warnings`, 전부 기존 unused-var 경고)
|
|
||||||
- [x] `frontend npm run build` — 성공
|
|
||||||
- [x] `backend npm run build` — 성공
|
|
||||||
- [x] `backend npm test -- --runInBand` — 성공 (`9 suites`, `26 tests` passed)
|
|
||||||
- [x] `backend/dist/src/main.js` 실제 산출물 존재 확인
|
|
||||||
- [x] Next build 결과에 `/office` route 포함 확인
|
|
||||||
|
|
||||||
## 3. 확인한 핵심 근거
|
|
||||||
### 배포 문서/산출물 정합성
|
|
||||||
- 기존 문서의 backend PM2 경로 `dist/main.js`는 실제 빌드 결과와 달랐어.
|
|
||||||
- 실제 Nest 진입 파일은 `backend/dist/src/main.js`였고, 배포 문서와 아키텍처 문서를 이 기준으로 수정했어.
|
|
||||||
|
|
||||||
### `/office` 변경분 상태
|
|
||||||
- 오피스 대시보드 관련 파일이 `main`에 반영돼 있어.
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `frontend/components/office/ContextPanel.tsx`
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `frontend/components/office/ServerHealthPanel.tsx`
|
|
||||||
- Next production build 산출물에서 `/office`가 정적 라우트로 생성되는 것까지 확인했어.
|
|
||||||
|
|
||||||
### 코드 preflight
|
|
||||||
- frontend는 lint/build 모두 통과했어.
|
|
||||||
- backend는 build/test 모두 통과했어.
|
|
||||||
- 현재 `main` 헤드는 `a9e1e67`로 고정 확인했어.
|
|
||||||
|
|
||||||
## 4. 배포 전 운영 체크
|
|
||||||
이건 코드 blocker는 아니고, 이랑이가 배포 직전에 확인하면 돼.
|
|
||||||
|
|
||||||
- Dev 서버 env
|
|
||||||
- `DATABASE_URL`
|
|
||||||
- `JWT_SECRET`
|
|
||||||
- `SSH_KEY_PATH`
|
|
||||||
- `GITEA_BASE_URL`
|
|
||||||
- `GITEA_TOKEN`
|
|
||||||
- `CORS_ORIGINS`
|
|
||||||
- Frontend env
|
|
||||||
- `NEXT_PUBLIC_API_URL`
|
|
||||||
- 필요 시 `NEXT_PUBLIC_WS_URL`
|
|
||||||
- Nginx websocket 프록시 또는 WS URL 설정
|
|
||||||
|
|
||||||
## 5. 최종 판정
|
|
||||||
- **배포 문서 경로 오류 수정 완료**
|
|
||||||
- **`/office` 변경분 release preflight 근거 문서화 완료**
|
|
||||||
- **현재 기준 코드/빌드/테스트 blocker 없음**
|
|
||||||
|
|
||||||
## 6. 최종 JSON
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "release_preflight",
|
|
||||||
"from": "harang",
|
|
||||||
"task_id": "SPRINT-016-RELEASE-PREFLIGHT",
|
|
||||||
"repo": "https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard",
|
|
||||||
"branch": "main",
|
|
||||||
"commit": "a9e1e677b0f129cc2f45e4f2624020d9d4626159",
|
|
||||||
"passed": true,
|
|
||||||
"errors": [],
|
|
||||||
"notes": [
|
|
||||||
"PM2 backend entry corrected to backend/dist/src/main.js",
|
|
||||||
"frontend lint/build passed",
|
|
||||||
"backend build/test passed",
|
|
||||||
"office route present in production build output",
|
|
||||||
"deploy-time env and websocket proxy checks remain operational checks only"
|
|
||||||
],
|
|
||||||
"suggestion": "Safe to proceed with deploy after environment and websocket configuration checks."
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
# SPRINT-018 review-1 QA draft
|
|
||||||
|
|
||||||
## 목적
|
|
||||||
SPRINT-018의 truth contract가 `/office`, `/`, `/projects/[id]`, `/org` 전반에서 같은 의미로 보이는지 확인하는 QA 초안이야.
|
|
||||||
|
|
||||||
## 참고 문서
|
|
||||||
- `.plans/sprints/SPRINT-018.md`
|
|
||||||
- `.plans/design/api-design.md`
|
|
||||||
- `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/design/ui/org-design.md`
|
|
||||||
|
|
||||||
## 공통 확인 항목
|
|
||||||
- `working`, `owner`, `participant`, `source`, `freshness` 의미가 페이지 간 동일한가
|
|
||||||
- `360px`, `390px`, `768px`, `1280px+`에서 horizontal scroll이 없는가
|
|
||||||
- 긴 badge, 긴 meta, 긴 source 문구가 wrap되는가
|
|
||||||
- null/empty 상태가 fallback 고정값으로 대체되지 않는가
|
|
||||||
|
|
||||||
## 상태 시나리오 매트릭스
|
|
||||||
| 시나리오 | `/office` | `/` | `/projects/[id]` | `/org` |
|
|
||||||
|---|---|---|---|---|
|
|
||||||
| socket disconnected | connection off + snapshot/fallback 유지 | event stream off, freshness 유지 | 영향 없음 또는 snapshot note | 영향 없음 |
|
|
||||||
| snapshot only | `snapshot only` 상태 구분 | `SNAPSHOT n AGO` 표기 | participant/source snapshot 표기 | org snapshot 표기 |
|
|
||||||
| fallback only | fallback seed가 working 주입 안 함 | owner null 유지 | participant empty 유지 | fallback org snapshot 표기 |
|
|
||||||
| connected idle | working 강조 없음 | sister row idle 표기 | participant로 과장 노출 안 함 | member idle 표기 |
|
|
||||||
| active working | why active 근거 노출 | active focus만 짧게 표시 | current owner/participant reason 표기 | member active badge 표기 |
|
|
||||||
| no active owner | 기본 owner 없음 | `NO ACTIVE OWNER` | `NO ACTIVE OWNER` | unit lead 미정 가능 |
|
|
||||||
| empty chat | empty state 즉시 노출 | N/A | N/A | N/A |
|
|
||||||
| JWT missing | send disabled reason 노출 | N/A | N/A | N/A |
|
|
||||||
|
|
||||||
## breakpoint 체크
|
|
||||||
|
|
||||||
### 360px
|
|
||||||
#### `/office`
|
|
||||||
- [ ] 첫 viewport에 summary, group blocks, quick action이 보인다
|
|
||||||
- [ ] scene 축소판이 없다
|
|
||||||
- [ ] chat/pipeline/health에서 horizontal scroll이 없다
|
|
||||||
|
|
||||||
#### `/`
|
|
||||||
- [ ] top chips가 wrap된다
|
|
||||||
- [ ] owner 영역이 잘리지 않는다
|
|
||||||
- [ ] sister/status/pipeline cards가 넘치지 않는다
|
|
||||||
|
|
||||||
#### `/projects/[id]`
|
|
||||||
- [ ] flow card가 1열 stack으로 보인다
|
|
||||||
- [ ] participant reason/source badge가 wrap된다
|
|
||||||
- [ ] git row가 넘치지 않는다
|
|
||||||
|
|
||||||
#### `/org`
|
|
||||||
- [ ] org summary와 team cards가 1열로 읽힌다
|
|
||||||
- [ ] independent agents section이 누락되지 않는다
|
|
||||||
|
|
||||||
### 390px
|
|
||||||
- [ ] 360px 체크를 모두 통과한다
|
|
||||||
- [ ] 긴 한글 문장과 영문 source label이 wrap된다
|
|
||||||
|
|
||||||
### 768px
|
|
||||||
- [ ] 2열 전환 시 시선 흐름이 깨지지 않는다
|
|
||||||
- [ ] scene/context, pipeline, org units가 애매한 overflow 없이 재배치된다
|
|
||||||
|
|
||||||
### 1280px+
|
|
||||||
- [ ] `/office` desktop group scene이 유지된다
|
|
||||||
- [ ] `/` executive snapshot hierarchy가 분명하다
|
|
||||||
- [ ] `/projects/[id]` participant 의미가 sidebar 축약으로 무너지지 않는다
|
|
||||||
- [ ] `/org` functional teams + independent agents가 함께 읽힌다
|
|
||||||
|
|
||||||
## 페이지별 semantic checks
|
|
||||||
### `/office`
|
|
||||||
- [ ] `working`이 fallback seed에서 나오지 않는다
|
|
||||||
- [ ] default context가 선택 전에도 보인다
|
|
||||||
- [ ] `connected idle`, `active working`, `snapshot only`, `fallback`, `offline`이 구분된다
|
|
||||||
|
|
||||||
### `/`
|
|
||||||
- [ ] connection badge와 freshness badge가 분리된다
|
|
||||||
- [ ] owner null 상태에서 특정 자매 fallback 고정 노출이 없다
|
|
||||||
- [ ] source badge가 `mirrored event`, `snapshot`, `doc-derived`, `fallback` 중 하나로 읽힌다
|
|
||||||
|
|
||||||
### `/projects/[id]`
|
|
||||||
- [ ] `ASSIGNED NODES`가 제거된다
|
|
||||||
- [ ] participant와 task assignee가 분리된다
|
|
||||||
- [ ] why-visible 없는 participant가 없다
|
|
||||||
|
|
||||||
### `/org`
|
|
||||||
- [ ] hard-coded root tree 의존이 없다
|
|
||||||
- [ ] independent agents가 별도 그룹으로 보인다
|
|
||||||
- [ ] status/source/freshness vocabulary가 다른 페이지와 같다
|
|
||||||
|
|
||||||
## 남은 follow-up / scope cut
|
|
||||||
- 실제 DTO 구현 후 field naming 최종 점검 필요
|
|
||||||
- activity evidence가 부족한 환경에서 `working confidence` 정책 추가 검토 필요
|
|
||||||
- independent agents data sourcing이 부족하면 v1에서는 snapshot 기반으로 제한 가능
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
# SPRINT-014 Implementation Handoff
|
|
||||||
|
|
||||||
## 대상 브랜치
|
|
||||||
- repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- branch: `feature/structure-renewal-sync`
|
|
||||||
- 기준 commit: `94cc4da` (`docs: refine sprint-014 implementation handoff`)
|
|
||||||
|
|
||||||
## 목적
|
|
||||||
Hermes 전환으로 깨진 자매 상태/아바타/프로젝트 운영 화면을 새 문서 구조와 함께 정렬한다.
|
|
||||||
|
|
||||||
## 이번 브랜치에서 이미 정리된 것
|
|
||||||
### 문서
|
|
||||||
- `ARCHITECTURE.md`
|
|
||||||
- `README.md`
|
|
||||||
- `.plans/OVERVIEW.md`
|
|
||||||
- `.plans/design/index.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/projects-page-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/sprints/SPRINT-014.md`
|
|
||||||
- `.plans/deploy/main-release-flow.md`
|
|
||||||
- `docs/references/repo-structure.md`
|
|
||||||
- `docs/product-specs/project-information-architecture.md`
|
|
||||||
- `docs/tech-debt-tracker.md`
|
|
||||||
- `docs/QUALITY_SCORE.md`
|
|
||||||
|
|
||||||
### 구현 반영 대상
|
|
||||||
- Hermes 우선 / OpenClaw fallback 경로 처리
|
|
||||||
- avatar fallback 경로 보강
|
|
||||||
- 프로젝트 phase / QA / deploy 메타 구조 확장
|
|
||||||
- 프로젝트 상세 delivery flow / QA / deploy / sprint / hotfix 분리
|
|
||||||
- 프로젝트 네비 두 번째 위치 정렬
|
|
||||||
- `main = deployable`, `이랑 = latest main redeploy only` 문구 반영
|
|
||||||
|
|
||||||
## 나랑 작업 단위
|
|
||||||
1. `backend-runtime`
|
|
||||||
- `backend/src/sisters/sisters.service.ts`
|
|
||||||
- `backend/src/sisters/sister-detail.service.ts`
|
|
||||||
- `backend/src/admin/admin.service.ts`
|
|
||||||
- `backend/src/costs/costs.service.ts`
|
|
||||||
2. `avatar-fallback`
|
|
||||||
- `backend/src/sisters/avatar.service.ts`
|
|
||||||
- 공통 avatar 사용처 확인
|
|
||||||
3. `projects-nav`
|
|
||||||
- `frontend/components/common/Sidebar.tsx`
|
|
||||||
- 모바일 탭/공통 네비
|
|
||||||
4. `projects-phase`
|
|
||||||
- `backend/src/projects/projects.service.ts`
|
|
||||||
- `frontend/app/projects/page.tsx`
|
|
||||||
- `frontend/components/projects/ProjectCard.tsx`
|
|
||||||
5. `project-detail-flow`
|
|
||||||
- `backend/src/projects/sprint-sync.service.ts`
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- `frontend/components/projects/SprintAccordion.tsx`
|
|
||||||
- `frontend/components/projects/TaskTable.tsx`
|
|
||||||
6. `deploy-copy`
|
|
||||||
- 프로젝트 목록/상세의 deploy wording 정리
|
|
||||||
|
|
||||||
## 반드시 읽고 구현할 문서
|
|
||||||
- `.plans/sprints/SPRINT-014.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/projects-page-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/deploy/main-release-flow.md`
|
|
||||||
- `ARCHITECTURE.md`
|
|
||||||
|
|
||||||
## 검증 결과
|
|
||||||
### 통과
|
|
||||||
- Backend test: `npm test -- --runInBand`
|
|
||||||
- Backend build: `npm run build`
|
|
||||||
- Frontend build: `npm run build`
|
|
||||||
- Sprint scope frontend lint 재확인 통과
|
|
||||||
|
|
||||||
### 다랑 review-2 기준 blocker
|
|
||||||
- 최신 QA 문서: `.plans/qa/SPRINT-014-review-2.md`
|
|
||||||
- 결과: `FAILED`
|
|
||||||
- blocker 1: `backend/.env.example`에 `JWT_SECRET`가 없어 기본 실행 경로에서 backend 부팅이 깨짐
|
|
||||||
- blocker 2: `JWT_SECRET`를 넣어도 현재 제공 환경값 기준 MariaDB access denied로 `/api/auth/login`, `/api/projects`가 `500` 응답함
|
|
||||||
- blocker 3: protected 페이지 실데이터/모바일 QA가 auth+DB 차단으로 완료되지 못함
|
|
||||||
- blocker 4: `frontend/app/projects/[id]/page.tsx` 상단 헤더 우측 메타에 design 문서가 요구한 `current sprint`가 아직 노출되지 않음
|
|
||||||
- 따라서 이번 브랜치는 **QA failed 상태**이며, 위 4개를 정리한 뒤 같은 branch에서 다시 다랑 재검증을 받아야 한다.
|
|
||||||
|
|
||||||
## QA 전달 규칙
|
|
||||||
- 다랑은 `.plans/qa/`에 결과 md 작성
|
|
||||||
- 보고 형식은 최소 아래를 포함
|
|
||||||
- `repo`
|
|
||||||
- `branch`
|
|
||||||
- `passed`
|
|
||||||
- `errors[]`
|
|
||||||
- 구 구조 fallback 확인 포함
|
|
||||||
- `.plans/qa/` 우선 + `.qa/` fallback
|
|
||||||
- `.plans/hotfix/` 우선 + 구 구조 fallback
|
|
||||||
|
|
||||||
## 배포 규칙
|
|
||||||
1. 다랑 QA 통과 전 `main` merge 금지
|
|
||||||
2. 하랑 확인 후 `main` merge
|
|
||||||
3. merge 시점부터 `main`이 배포 기준
|
|
||||||
4. 이랑은 feature branch 배포 금지
|
|
||||||
5. 이랑은 최신 `main` pull 후 재배포만 수행
|
|
||||||
|
|
||||||
## 완료 기준
|
|
||||||
- Hermes 환경에서 자매가 전원 offline으로 고정되지 않음
|
|
||||||
- avatar 이미지가 없어도 broken image 없이 fallback 유지
|
|
||||||
- 프로젝트가 네비게이션 두 번째 위치에 보임
|
|
||||||
- 프로젝트 목록에서 `PLANNING / IMPLEMENT / QA / READY FOR DEPLOY / DEPLOYED`가 읽힘
|
|
||||||
- 프로젝트 상세에서 `DELIVERY FLOW / QA STATUS / DEPLOY STATUS / SPRINT LEDGER / HOTFIX HISTORY`가 분리됨
|
|
||||||
- 문서/화면 모두 `main = deployable` 원칙과 `이랑 = latest main redeploy only` 규칙이 일치함
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
# SPRINT-014 나랑 전달용 메시지
|
|
||||||
|
|
||||||
나랑, 이번 건 `feature/structure-renewal-sync`에서 같은 브랜치로 이어서 고치면 돼.
|
|
||||||
|
|
||||||
- repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- branch: `feature/structure-renewal-sync`
|
|
||||||
- latest commit: `ad163e5`
|
|
||||||
- QA 상태: `failed` (`.plans/qa/SPRINT-014-review-2.md` 기준)
|
|
||||||
- 우선 읽을 문서:
|
|
||||||
- `.plans/sprints/SPRINT-014.md`
|
|
||||||
- `.plans/sprints/SPRINT-014-IMPLEMENTATION-HANDOFF.md`
|
|
||||||
- `.plans/qa/SPRINT-014-review-2.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/projects-page-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/deploy/main-release-flow.md`
|
|
||||||
|
|
||||||
이번 재작업 핵심은 blocker 4개 정리야.
|
|
||||||
1. `backend/.env.example`에 `JWT_SECRET` 추가해서 기본 실행 경로가 바로 깨지지 않게 만들기
|
|
||||||
2. QA 가능한 환경값 기준으로 auth / projects API가 500 없이 뜨게 정리하기
|
|
||||||
3. protected 페이지 기준 실데이터 + 모바일 QA가 가능하도록 막힌 조건 해소하기
|
|
||||||
4. `frontend/app/projects/[id]/page.tsx` 헤더 우측 메타에 `current sprint` 노출하기
|
|
||||||
|
|
||||||
권장 작업 순서:
|
|
||||||
- `backend-config`
|
|
||||||
- `runtime-validation`
|
|
||||||
- `project-detail-header`
|
|
||||||
- `protected-pages-qa-ready`
|
|
||||||
|
|
||||||
우선 수정이 필요한 파일/영역:
|
|
||||||
- `backend/.env.example`
|
|
||||||
- `backend` 런타임 환경값 로딩 경로 전반
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- auth / projects API 실제 QA에 필요한 설정값
|
|
||||||
|
|
||||||
검증 기준:
|
|
||||||
- `backend/.env.example`만 복사해도 최소 부팅은 가능해야 해
|
|
||||||
- `POST /api/auth/login`, `GET /api/projects`가 500 없이 응답해야 해
|
|
||||||
- `/projects`, `/projects/[id]`, `/admin/costs` 실데이터 QA가 가능해야 해
|
|
||||||
- 모바일에서도 프로젝트 상세 흐름이 문서 순서대로 읽혀야 해
|
|
||||||
- 다랑 review 결과가 `passed=true`로 바뀌기 전까지 `main` merge 금지야
|
|
||||||
|
|
||||||
주의:
|
|
||||||
- 이번 작업은 구현 범위를 넓히는 게 아니라 review-2 blocker 제거가 목적이야
|
|
||||||
- 수정 끝나면 같은 브랜치로 push하고, 다랑에게 `.plans/qa/SPRINT-014-review-2.md` 기준으로 재검증 다시 요청해
|
|
||||||
- QA passed 확인 전 `main` merge 금지야
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
# SPRINT-014: Hermes 전환 + 프로젝트 구조/정보 아키텍처 리뉴얼
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
개정된 저장소 구조와 운영 규칙에 맞춰 문서 체계를 정렬하고, Hermes 전환으로 깨진 자매 상태/아바타/프로젝트 정보 구조를 함께 복구한다.
|
|
||||||
|
|
||||||
## 범위
|
|
||||||
- 문서 구조 표준화 (`ARCHITECTURE.md`, `.plans`, `docs`)
|
|
||||||
- OpenClaw 경로 하드코딩 제거 또는 Hermes 우선 + OpenClaw fallback 전환
|
|
||||||
- 프로젝트 목록/상세 UI를 새 파일 구조와 배포 흐름 기준으로 재설계
|
|
||||||
- 네비게이션에서 프로젝트를 두 번째 페이지로 고정
|
|
||||||
- `main = deployable`, `erang = redeploy latest main only` 흐름 반영
|
|
||||||
|
|
||||||
## 태스크
|
|
||||||
|
|
||||||
### TASK-063: 문서 구조 리뉴얼 반영
|
|
||||||
- 루트에 `ARCHITECTURE.md` 추가
|
|
||||||
- `docs/references/`, `docs/product-specs/`, `docs/tech-debt-tracker.md`, `docs/QUALITY_SCORE.md` 정렬
|
|
||||||
- `.plans/design/index.md` 추가
|
|
||||||
- `README.md`, `.plans/OVERVIEW.md`를 새 구조 기준으로 갱신
|
|
||||||
|
|
||||||
### TASK-064: 자매 런타임 경로를 Hermes 기준으로 전환
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-063
|
|
||||||
- **설명:** Hermes 전환 후 깨진 자매 상태/세션/서브에이전트 조회를 복구한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/sisters/sisters.service.ts`
|
|
||||||
- `backend/src/sisters/sister-detail.service.ts`
|
|
||||||
- `backend/src/admin/admin.service.ts`
|
|
||||||
- `backend/src/costs/costs.service.ts`
|
|
||||||
- **구현 메모:**
|
|
||||||
- 상태 체크 서비스명/경로를 Hermes 기준으로 수정
|
|
||||||
- workspace / sessions / agents 경로를 Hermes 우선으로 변경
|
|
||||||
- 운영/로그/세션 경로에 `.openclaw` 하드코딩이 남아 있으면 함께 정리
|
|
||||||
- 이행 기간 동안 `.openclaw` fallback 유지
|
|
||||||
- **완료 기준:**
|
|
||||||
- Hermes 기반 실제 노드에서 전체 자매가 `OFFLINE`으로 고정되지 않음
|
|
||||||
- 기존 `.openclaw` 환경에서도 조회가 깨지지 않음
|
|
||||||
- sisters/admin/costs 관련 테스트 또는 빌드가 통과함
|
|
||||||
|
|
||||||
### TASK-065: 자매 프로필 사진 fallback 체계 보강
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-064
|
|
||||||
- **설명:** 프로필 이미지가 없거나 경로가 바뀌어도 broken image 없이 안정적으로 표시되게 한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/sisters/avatar.service.ts`
|
|
||||||
- `frontend/components/**` 내 공통 avatar 사용처
|
|
||||||
- **구현 메모:**
|
|
||||||
- `~/.hermes/avatar.*` 우선 탐색
|
|
||||||
- 없으면 `~/.openclaw/avatar.*` fallback
|
|
||||||
- 둘 다 없으면 현재 SVG fallback 유지
|
|
||||||
- 프론트엔드 공통 avatar 사용처에서 broken image가 아닌 fallback이 항상 보이게 확인
|
|
||||||
- **완료 기준:**
|
|
||||||
- 실이미지 유무와 무관하게 프로필 영역이 깨지지 않음
|
|
||||||
- fallback SVG가 대시보드/자매 상세/목록에서 일관되게 보임
|
|
||||||
|
|
||||||
### TASK-066: 프로젝트 네비게이션/IA 개편
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-063
|
|
||||||
- **디자인:** `.plans/design/ui/dashboard-design.md`, `.plans/design/ui/projects-page-design.md`
|
|
||||||
- **설명:** 프로젝트를 두 번째 핵심 페이지로 고정하고 데스크톱/모바일 네비 순서를 통일한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/components/common/Sidebar.tsx`
|
|
||||||
- 모바일 하단 탭/공통 네비 관련 컴포넌트
|
|
||||||
- 대시보드/프로젝트 진입 링크 사용처
|
|
||||||
- **완료 기준:**
|
|
||||||
- 프로젝트가 `대시 → 프로 → 활동 ...` 순서에서 두 번째에 위치함
|
|
||||||
- 모바일 하단 탭과 사이드바 순서가 동일함
|
|
||||||
- 대시보드/프로젝트 화면 링크 동선이 새 순서를 반영함
|
|
||||||
|
|
||||||
### TASK-067: 프로젝트 목록 진행률/메타 구조 개편
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-066
|
|
||||||
- **디자인:** `.plans/design/ui/projects-page-design.md`
|
|
||||||
- **설명:** 프로젝트 목록을 Sprint 퍼센트 중심에서 phase/QA/deploy 중심 운영 리스트로 재구성한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/projects/page.tsx`
|
|
||||||
- `frontend/components/projects/ProjectCard.tsx`
|
|
||||||
- `backend/src/projects/projects.service.ts`
|
|
||||||
- **구현 메모:**
|
|
||||||
- 현재 단계(`PLANNING`, `IMPLEMENT`, `QA`, `READY FOR DEPLOY`, `DEPLOYED`)를 우선 표시
|
|
||||||
- `main` 배포 상태 또는 재배포 필요 상태를 읽을 수 있게 메타 확장
|
|
||||||
- project list API에 UI가 필요한 phase/qa/deploy 메타를 공급할 수 있게 확장 검토
|
|
||||||
- **완료 기준:**
|
|
||||||
- 프로젝트 목록에서 현재 단계/QA 상태/배포 상태를 한눈에 읽을 수 있음
|
|
||||||
- `READY FOR DEPLOY`와 `DEPLOYED ON MAIN`이 시각적으로 구분됨
|
|
||||||
- FE/BE 타입체크 또는 빌드가 통과함
|
|
||||||
|
|
||||||
### TASK-068: 프로젝트 상세 Sprint/Hotfix/QA/Deploy 흐름 개편
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-067
|
|
||||||
- **디자인:** `.plans/design/ui/project-detail-design.md`
|
|
||||||
- **설명:** 프로젝트 상세를 운영 흐름 화면으로 재구성하고 신/구 문서 구조를 모두 읽도록 정리한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- `frontend/components/projects/SprintAccordion.tsx`
|
|
||||||
- `frontend/components/projects/TaskTable.tsx`
|
|
||||||
- `backend/src/projects/projects.service.ts`
|
|
||||||
- `backend/src/projects/sprint-sync.service.ts`
|
|
||||||
- **구현 메모:**
|
|
||||||
- Sprint / Hotfix / Assigned Nodes / QA / Deploy 상태를 분리된 정보 블록으로 정리
|
|
||||||
- 모바일에서 `DELIVERY FLOW → QA STATUS → DEPLOY STATUS → SPRINT/HOTFIX` 순으로 재배치
|
|
||||||
- `.plans/hotfix/`, `.plans/qa/`를 우선 읽고 구 구조도 fallback 지원
|
|
||||||
- `.plans/qa/` 우선, `.qa/` fallback
|
|
||||||
- Hotfix 문서 위치 변경 이후에도 history/ledger가 깨지지 않게 호환 처리
|
|
||||||
- **완료 기준:**
|
|
||||||
- 프로젝트 상세에서 delivery flow / QA / deploy / sprint / hotfix 정보가 분리되어 보임
|
|
||||||
- 신규 `.plans/hotfix`, `.plans/qa` 구조와 기존 `.qa` 데이터가 모두 깨지지 않음
|
|
||||||
- 모바일 화면에서 세로 읽기 흐름이 자연스러움
|
|
||||||
|
|
||||||
### TASK-069: 배포 플로우를 코드/문서/UI에 반영
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-067, TASK-068
|
|
||||||
- **설명:** `main = deployable` 원칙과 이랑의 `latest main redeploy only` 규칙을 프로젝트 메타/UI 문구에 반영한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `backend/src/projects/projects.service.ts`
|
|
||||||
- `frontend/app/projects/page.tsx`
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- 배포 상태를 표기하는 공통 컴포넌트
|
|
||||||
- **완료 기준:**
|
|
||||||
- `main` merge 후 배포 상태가 된다는 규칙이 배포 문서/프로젝트 메타/UI 문구에 반영됨
|
|
||||||
- 이랑 화면/관리 기능에서 재배포 대상이 `main`임이 명확히 보임
|
|
||||||
- feature branch 직접 배포처럼 오해할 수 있는 문구가 제거됨
|
|
||||||
|
|
||||||
## 권장 구현 순서
|
|
||||||
1. TASK-064 → Hermes 경로/상태 복구
|
|
||||||
2. TASK-065 → avatar fallback 안정화
|
|
||||||
3. TASK-066 → 네비게이션 순서 정렬
|
|
||||||
4. TASK-067 → 프로젝트 목록 phase 메타 확장
|
|
||||||
5. TASK-068 → 프로젝트 상세 흐름/호환 처리
|
|
||||||
6. TASK-069 → deploy wording + `main` 기준 고정 확인
|
|
||||||
|
|
||||||
## 나랑 구현 체크포인트
|
|
||||||
- 작은 단위로 나눠 커밋할 것 (`backend-runtime`, `avatar-fallback`, `projects-nav`, `projects-phase`, `project-detail-flow`, `deploy-copy` 정도로 분리 권장)
|
|
||||||
- 구현 중간에도 FE/BE 각각 빌드 또는 테스트를 자주 확인할 것
|
|
||||||
- QA 요청 전 모바일 실기기/반응형 확인 필수
|
|
||||||
- QA 결과 문서는 `.plans/qa/`에 작성하고, 구 구조 호환 테스트 결과도 함께 남길 것
|
|
||||||
|
|
||||||
## 검증 기준
|
|
||||||
- Hermes 기반 실제 운영 환경에서 자매가 offline으로만 고정되지 않음
|
|
||||||
- 자매 프로필 사진이 없을 때도 fallback이 깨지지 않음
|
|
||||||
- 프로젝트 페이지가 새 구조(`.plans/hotfix`, `.plans/qa`)를 기준으로 읽히고, 기존 데이터도 깨지지 않음
|
|
||||||
- 프로젝트가 두 번째 네비 항목으로 보임
|
|
||||||
- 다랑 QA 통과 → 하랑 main merge → 이랑 main pull + 재배포 흐름이 문서/화면에서 일관되게 확인됨
|
|
||||||
- FE/BE 빌드 통과
|
|
||||||
- 외부 URL 모바일 QA 필수
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
# SPRINT-015 Narang Handoff
|
|
||||||
|
|
||||||
## repo / branch
|
|
||||||
- repo: `https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard`
|
|
||||||
- branch: `feature/sprint-015-v3-redesign-plan`
|
|
||||||
|
|
||||||
## 읽을 문서
|
|
||||||
1. `.plans/sprints/SPRINT-015.md`
|
|
||||||
2. `.plans/design/ui/dashboard-design.md`
|
|
||||||
3. `.plans/design/index.md`
|
|
||||||
4. 기존 구현 참조가 필요하면 `.plans/sprints/SPRINT-014.md`
|
|
||||||
|
|
||||||
## 이번에 해야 하는 일
|
|
||||||
대시보드 메인(`/`)을 v3 정보 구조로 재설계해.
|
|
||||||
|
|
||||||
핵심은 이거야.
|
|
||||||
- 현행 미니멀 터미널 톤 유지
|
|
||||||
- 레퍼런스의 정보 구조 적극 채택
|
|
||||||
- `ACTIVE PIPELINE`을 대표 섹션으로 도입
|
|
||||||
- 4자매 상태 카드 / Activity Feed / Sprint Metrics / Infra / Mistake Log를 운영 화면답게 재배치
|
|
||||||
- 장식은 줄이고 실데이터 연결 가능한 구조로 구현
|
|
||||||
|
|
||||||
## 절대 기준
|
|
||||||
- glassmorphism으로 회귀하지 마
|
|
||||||
- styled-components 체계 유지
|
|
||||||
- fake mock 느낌 강한 장식 UI로 끝내지 마
|
|
||||||
- hover 없이도 핵심 정보 읽혀야 해
|
|
||||||
- 데스크톱 먼저 맞추고 모바일 세로 흐름까지 꼭 정리해
|
|
||||||
- 기존 페이지 동선 숨기지 마
|
|
||||||
|
|
||||||
## 구현 우선순위
|
|
||||||
1. 상단 Global Status Bar / Hero Summary
|
|
||||||
2. 4자매 상태 카드 v3
|
|
||||||
3. `ACTIVE PIPELINE`
|
|
||||||
4. `ACTIVITY FEED` / `SPRINT METRICS`
|
|
||||||
5. `INFRASTRUCTURE OVERVIEW` / `MISTAKE LOG & HARNESS`
|
|
||||||
6. 반응형/빈 상태/오프라인 상태 정리
|
|
||||||
|
|
||||||
## 확인 포인트
|
|
||||||
- 첫 화면 첫 스크롤 안에서 자매 상태 + 현재 파이프라인이 읽혀야 함
|
|
||||||
- 색은 상태 의미가 있을 때만 강하게 사용
|
|
||||||
- Activity / Metrics / Infra / Mistake가 각각 따로 노는 패널이 아니라 운영 맥락으로 이어져야 함
|
|
||||||
- `ACTIVE PIPELINE`은 예쁘기만 한 다이어그램이 아니라 현재 handoff / review loop / escalation을 보여줘야 함
|
|
||||||
|
|
||||||
## QA 전 필수
|
|
||||||
- `npm run build` 통과
|
|
||||||
- 반응형 확인
|
|
||||||
- 데이터 없을 때/길 때/오프라인일 때 레이아웃 확인
|
|
||||||
- 외부 URL 기준으로 실제 읽기 흐름 확인
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
# SPRINT-015: Master Dashboard v3 정보 구조 리디자인
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
기존 미니멀 터미널 UI를 유지하면서, 자기야가 제안한 레퍼런스의 강한 정보 구조를 흡수해 메인 대시보드를 `4자매 운영 관제의 대표 화면`으로 재정의한다.
|
|
||||||
|
|
||||||
## 핵심 방향
|
|
||||||
- glassmorphism으로 회귀하지 않음
|
|
||||||
- 현재 프로덕션의 미니멀 터미널 톤 유지
|
|
||||||
- 대신 레이아웃/정보 위계/운영 흐름 표현은 새 레퍼런스를 적극 반영
|
|
||||||
- 장식보다 운영 가독성을 우선
|
|
||||||
- 데스크톱 우선 설계 후 모바일 세로 흐름까지 함께 정리
|
|
||||||
|
|
||||||
## 디자인 원칙
|
|
||||||
1. **정보 구조 우선**
|
|
||||||
- 예쁜 카드보다 `지금 무엇이 진행 중인지`가 먼저 읽혀야 함
|
|
||||||
2. **운영 화면다운 밀도**
|
|
||||||
- 한 화면에서 자매 상태 / 현재 파이프라인 / 활동 / 지표 / 인프라를 함께 판단 가능해야 함
|
|
||||||
3. **현행 톤 유지**
|
|
||||||
- 배경, border, mono 보조 텍스트, 브라켓/터미널 감성은 유지
|
|
||||||
4. **애니메이션 절제**
|
|
||||||
- 상태 강조용 pulse/flow만 제한적으로 사용
|
|
||||||
- 불필요한 glow, 과한 색 번짐, 반복 뱃지는 줄임
|
|
||||||
5. **실데이터 우선**
|
|
||||||
- 예시 숫자가 아니라 실제 runtime/task/project/deploy 데이터를 붙일 수 있는 구조로 설계
|
|
||||||
|
|
||||||
## 범위
|
|
||||||
- 메인 대시보드(`/`) 레이아웃 v3 개편
|
|
||||||
- 상단 global status bar 재설계
|
|
||||||
- 4자매 상태 카드 재배치/요약 정보 재정의
|
|
||||||
- `ACTIVE PIPELINE` 섹션 신설
|
|
||||||
- `ACTIVITY FEED` / `SPRINT METRICS` 병렬 구조 재정렬
|
|
||||||
- `INFRASTRUCTURE OVERVIEW` / `MISTAKE LOG & HARNESS` 하단 운영 영역 재구성
|
|
||||||
- 기존 프로젝트/활동/자매/관리 페이지와 연결되는 진입 동선 재정리
|
|
||||||
|
|
||||||
## 제외 범위
|
|
||||||
- 이번 Sprint에서 새 도메인 기능 추가는 하지 않음
|
|
||||||
- 백엔드 데이터 모델을 대규모로 갈아엎지 않음
|
|
||||||
- 기존 페이지 전체를 동시 리디자인하지 않음
|
|
||||||
- chart 라이브러리 교체는 필요할 때만 제한적으로 수행
|
|
||||||
|
|
||||||
## 태스크
|
|
||||||
|
|
||||||
### TASK-070: 대시보드 v3 IA 확정 및 섹션 맵 정리
|
|
||||||
- **담당:** 하랑이 → 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **설명:** 레퍼런스를 현행 제품에 맞게 번역한 섹션 구조/우선순위를 확정한다.
|
|
||||||
- **산출물:**
|
|
||||||
- `.plans/design/ui/dashboard-design.md` 갱신
|
|
||||||
- 섹션별 데이터 소스 매핑 표
|
|
||||||
- **완료 기준:**
|
|
||||||
- 상단바 / 자매 카드 / Active Pipeline / Activity Feed / Metrics / Infra / Mistake Log의 역할이 문서로 명확함
|
|
||||||
|
|
||||||
### TASK-071: 상단 Global Status Bar + Hero Summary 개편
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- `frontend/components/**` 내 dashboard 공통 헤더/요약 관련 컴포넌트
|
|
||||||
- **설명:**
|
|
||||||
- 좌측 브랜드/페이지 아이덴티티
|
|
||||||
- 중앙 sprint/day 또는 현재 운영 focus
|
|
||||||
- 우측 연결 상태/알림/관리자 프로필 요약
|
|
||||||
구조를 재정의한다.
|
|
||||||
- **완료 기준:**
|
|
||||||
- 첫 화면 상단에서 현재 스프린트/연결 상태를 즉시 읽을 수 있음
|
|
||||||
- 모바일에서 세로 스택 또는 2단 구조로 무너지지 않음
|
|
||||||
|
|
||||||
### TASK-072: 4자매 상태 카드 v3 재설계
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- `frontend/components/sisters/**` 또는 대시보드 상태 카드 컴포넌트
|
|
||||||
- **설명:** 각 자매 카드에 아래 정보를 안정적으로 담는다.
|
|
||||||
- 이름 / 역할
|
|
||||||
- 현재 상태 (`IDLE`, `WORKING`, `REVIEWING`, `OFFLINE` 등)
|
|
||||||
- CPU / RAM 또는 대응 운영 지표
|
|
||||||
- 현재 작업 한 줄 요약
|
|
||||||
- **완료 기준:**
|
|
||||||
- 카드 4개가 한 세트로 읽힘
|
|
||||||
- 색상/강조는 자매별 역할과 상태를 동시에 표현함
|
|
||||||
- 아바타/아이콘/텍스트 길이 차이로 카드 높이가 깨지지 않음
|
|
||||||
|
|
||||||
### TASK-073: `ACTIVE PIPELINE` 시각화 도입
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-070
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- 새 공통 컴포넌트 생성 가능 (`frontend/components/dashboard/ActivePipeline.tsx` 등)
|
|
||||||
- **설명:**
|
|
||||||
- User → Harang → Narang → Darang → Irang 흐름을 운영 그래프로 표현
|
|
||||||
- maker-checker loop, escalation 조건, 현재 active task를 읽을 수 있게 구성
|
|
||||||
- **구현 메모:**
|
|
||||||
- SVG/HTML 혼합 구현 허용
|
|
||||||
- 애니메이션은 실제 active state가 있을 때만 제한적으로 사용
|
|
||||||
- 정적인 장식보다 상태 전달이 우선
|
|
||||||
- **완료 기준:**
|
|
||||||
- 현재 누가 받고/처리하고/검토 중인지 한눈에 보임
|
|
||||||
- 3회 실패 escalation 같은 운영 규칙이 과하지 않게 드러남
|
|
||||||
|
|
||||||
### TASK-074: `ACTIVITY FEED` / `SPRINT METRICS` 병렬 재배치
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- 기존 activity/task/metrics 컴포넌트
|
|
||||||
- **설명:** 활동 피드와 지표를 같은 행에서 비교하는 운영 레이아웃으로 정렬한다.
|
|
||||||
- **완료 기준:**
|
|
||||||
- 활동 피드는 이벤트 타입/주체/대상 task를 읽기 쉬움
|
|
||||||
- metrics는 total tasks, 완료율, 반복 횟수, first-pass rate, escalation 수를 빠르게 읽을 수 있음
|
|
||||||
- mock처럼 보이지 않도록 실제 데이터 연결 포인트가 드러남
|
|
||||||
|
|
||||||
### TASK-075: `INFRASTRUCTURE OVERVIEW` / `MISTAKE LOG & HARNESS` 하단 운영 영역 구성
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **설명:** 인프라 상태 맵과 mistake/harness 규칙 영역을 하단 2열 운영 패널로 정리한다.
|
|
||||||
- **주요 파일:**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
- 관련 API 데이터를 읽는 서비스/타입
|
|
||||||
- **완료 기준:**
|
|
||||||
- Gateway / sisters infra / deploy access 흐름이 읽힘
|
|
||||||
- MISTAKE.md/하네스 규칙 로그는 운영 학습 자산처럼 보여야 함
|
|
||||||
- 모바일에서는 Infra → Mistake Log 순 세로 배치
|
|
||||||
|
|
||||||
### TASK-076: 현행 디자인 시스템과 v3 레이아웃 정합화
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-071 ~ TASK-075
|
|
||||||
- **설명:** 새 레이아웃이 기존 미니멀 터미널 UI와 충돌하지 않게 색/간격/타이포/테두리 규칙을 정리한다.
|
|
||||||
- **완료 기준:**
|
|
||||||
- 기존 프로젝트/활동/설정 페이지와 같은 제품군처럼 보임
|
|
||||||
- Tailwind 레퍼런스의 분위기를 가져오되 styled-components 기반 현행 톤과 충돌하지 않음
|
|
||||||
|
|
||||||
### TASK-077: 반응형/실데이터 QA 준비
|
|
||||||
- **담당:** 나랑이 → 다랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **의존성:** TASK-071 ~ TASK-076
|
|
||||||
- **설명:** 데스크톱/태블릿/모바일 반응형과 실데이터 연결 상태를 확인하고 QA 요청 준비를 마친다.
|
|
||||||
- **완료 기준:**
|
|
||||||
- Desktop / Tablet / Mobile 주요 breakpoints 확인
|
|
||||||
- 빈 상태 / 긴 텍스트 / offline 상태 / 데이터 없음 상태가 깨지지 않음
|
|
||||||
- QA 전달 시 스크린샷 또는 확인 포인트 포함
|
|
||||||
|
|
||||||
## 데이터 매핑 기준
|
|
||||||
| 섹션 | 우선 데이터 |
|
|
||||||
|---|---|
|
|
||||||
| Global Status Bar | current sprint, connection status, notifications, current operator |
|
|
||||||
| Sister Cards | runtime status, role, usage metrics, current work summary |
|
|
||||||
| Active Pipeline | latest handoff, active implementation, active review, escalation count |
|
|
||||||
| Activity Feed | latest activities/log events/task transitions |
|
|
||||||
| Sprint Metrics | total tasks, completion, review loops, first-pass rate, escalations |
|
|
||||||
| Infrastructure Overview | gateway/node/server/process summary |
|
|
||||||
| Mistake Log & Harness | latest MISTAKE/Harness rules or derived operational lessons |
|
|
||||||
|
|
||||||
## UX 규칙
|
|
||||||
- 정보 순서는 `지금 상태 → 흐름 → 근거 이벤트 → 정량 지표 → 인프라/학습 자산`
|
|
||||||
- 카드 하나하나보다 섹션 간 관계가 더 중요함
|
|
||||||
- hover가 없어도 중요한 정보는 보여야 함
|
|
||||||
- 색은 상태 의미가 있을 때만 강하게 쓴다
|
|
||||||
- `Working`, `Reviewing`, `Ready for Deploy` 같은 운영 단어는 전체 제품에서 같은 표현을 유지한다
|
|
||||||
|
|
||||||
## 구현 제약
|
|
||||||
- styled-components 구조 유지
|
|
||||||
- 기존 공통 토큰/색 변수 최대한 재사용
|
|
||||||
- 새 레이아웃 때문에 기존 페이지 진입 동선이 숨지면 안 됨
|
|
||||||
- 과한 애니메이션/지속적인 repaint 유발 구현 지양
|
|
||||||
- fake 숫자 하드코딩으로 끝내지 말고 실데이터 연결 지점을 남길 것
|
|
||||||
|
|
||||||
## 검증 기준
|
|
||||||
- 홈 화면 진입 시 `하나랑 대시보드가 무엇을 운영하는지` 즉시 이해됨
|
|
||||||
- 4자매 상태와 현재 파이프라인이 첫 스크롤 안에서 읽힘
|
|
||||||
- 활동/지표/인프라/학습 로그가 운영자 관점에서 자연스럽게 이어짐
|
|
||||||
- 데스크톱/모바일 모두 정보 손실 없이 읽힘
|
|
||||||
- 현행 미니멀 터미널 UI와 충돌하지 않음
|
|
||||||
|
|
||||||
## 참고
|
|
||||||
- 레퍼런스는 `정보 구조`를 강하게 채택
|
|
||||||
- 비주얼은 현재 제품 톤을 유지한 상태로 70%만 차용
|
|
||||||
- `ACTIVE PIPELINE`은 이번 v3 리디자인의 대표 섹션으로 취급
|
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
# SPRINT-016: 4자매 Isometric Office Dashboard 재기획
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
기존 하나랑 대시보드를 `운영 패널 중심 UI`에서 한 단계 확장해, 4자매 메인 에이전트와 17개 서브에이전트가 실제로 협업하는 흐름을 **2D 등축 투영 오피스**로 시각화하는 차세대 관제 화면으로 재기획한다.
|
|
||||||
|
|
||||||
핵심은 이거야.
|
|
||||||
- 4자매의 고정 좌석과 역할이 한눈에 보여야 해
|
|
||||||
- 서브에이전트가 어떤 워크플로우 안에서 움직이는지 보여야 해
|
|
||||||
- 단순 예쁜 씬이 아니라 실시간 상태/협업/채팅/서버 헬스를 같이 판단할 수 있어야 해
|
|
||||||
- OpenClaw Gateway WebSocket을 기준으로 실제 상태를 반영해야 해
|
|
||||||
|
|
||||||
## 참고 레퍼런스
|
|
||||||
- 참고 프로젝트: `https://github.com/WW-AI-Lab/openclaw-office`
|
|
||||||
- 채택 포인트:
|
|
||||||
- 2D 등축 투영 오피스
|
|
||||||
- 고정 좌석 + 동적 이동
|
|
||||||
- 상태 애니메이션 / 연결선 / 회의실 은유
|
|
||||||
- Chat 작업공간과 관리 패널 결합
|
|
||||||
- 그대로 복제하지 않고, 하나랑 4자매 구조와 Lobster/Discord handoff 흐름에 맞게 번역한다.
|
|
||||||
|
|
||||||
## 운영 구조
|
|
||||||
### 메인 에이전트 (고정 데스크 / 독립 OpenClaw 인스턴스)
|
|
||||||
- 하랑이 (Planning)
|
|
||||||
- 나랑이 (Dev)
|
|
||||||
- 다랑이 (QA)
|
|
||||||
- 이랑이 (Infra)
|
|
||||||
|
|
||||||
### 서브에이전트
|
|
||||||
- 하랑이: `planner`, `task-tracker`, `prd-writer`
|
|
||||||
- 나랑이: `worker`, `db-designer`, `test-writer`, `refactorer`
|
|
||||||
- 다랑이: `reviewer`, `code-reviewer`, `qa-tester`, `security-auditor`, `ux-reviewer`
|
|
||||||
- 이랑이: `deploy-manager`, `db-manager`, `nginx-manager`, `monitoring`, `dns-manager`
|
|
||||||
|
|
||||||
총 21개 에이전트 (main 4 + sub 17)
|
|
||||||
|
|
||||||
## 파이프라인 모델
|
|
||||||
### 자매 내부
|
|
||||||
- Lobster 워크플로우 기반 순차 실행
|
|
||||||
- 예:
|
|
||||||
- `plan-sprint.lobster`
|
|
||||||
- `implement-sprint.lobster`
|
|
||||||
- `review-sprint.lobster`
|
|
||||||
- `deploy-check.lobster`
|
|
||||||
|
|
||||||
### 자매 간
|
|
||||||
- Discord 멘션 기반 자연어 핸드오프
|
|
||||||
- `자기야 → 하랑이 → 나랑이 → 다랑이 → 이랑이`
|
|
||||||
- 실패 시 `다랑이 → 나랑이` 되돌림 루프 지원
|
|
||||||
|
|
||||||
## 제품 목표
|
|
||||||
1. 4자매와 서브에이전트 협업 구조를 직관적으로 보여준다
|
|
||||||
2. OpenClaw Gateway WebSocket 기반 실시간 상태 모니터링을 제공한다
|
|
||||||
3. 자매 선택 직접 채팅과 운영 관제를 한 제품 안에 통합한다
|
|
||||||
4. Lobster 워크플로우 / 스프린트 / QA / 배포 흐름을 하나의 모델로 묶는다
|
|
||||||
5. 서버 헬스와 에이전트 헬스를 같은 맥락에서 본다
|
|
||||||
|
|
||||||
## 범위
|
|
||||||
- 메인 오피스 대시보드 (`/` 또는 신규 workspace landing)
|
|
||||||
- 에이전트 상태 시각화
|
|
||||||
- 회의실/협업 연결선/동적 이동 규칙
|
|
||||||
- 자매 선택 직접 채팅 인터페이스
|
|
||||||
- 파이프라인 현황 패널
|
|
||||||
- 서버 상태 패널
|
|
||||||
- 모바일/태블릿 대응 전략
|
|
||||||
- 데이터 소스 / WebSocket 이벤트 / 폴링 보정 전략 문서화
|
|
||||||
|
|
||||||
## 제외 범위
|
|
||||||
- 이번 Sprint에서 실제 Gateway 프로토콜을 새로 정의하지 않음
|
|
||||||
- 3D 전환 안 함
|
|
||||||
- 음성/영상 통화 기능 없음
|
|
||||||
- 에이전트 생성/삭제 전체 관리 콘솔을 이번 Sprint 핵심으로 두지 않음
|
|
||||||
|
|
||||||
## 정보 구조
|
|
||||||
### 1. Office Scene
|
|
||||||
- 4자매 고정 좌석
|
|
||||||
- 각 자매 주변에 자기 서브에이전트 풀 배치
|
|
||||||
- 상태에 따라 idle / thinking / tool_calling / speaking / error 시각화
|
|
||||||
- 회의실 / 작업대 / 대기 구역 / 인프라 구역 구분
|
|
||||||
|
|
||||||
### 2. Agent Detail Layer
|
|
||||||
- 선택한 자매/서브에이전트 상세
|
|
||||||
- 현재 세션 / 최근 메시지 / tool call / 리소스 지표
|
|
||||||
- 최근 handoff / 현재 워크플로우 단계
|
|
||||||
|
|
||||||
### 3. Chat Workspace
|
|
||||||
- 자매 선택 direct chat
|
|
||||||
- 최근 대화 히스토리
|
|
||||||
- 작업 지시 / 응답 / 툴 호출 상태 확인
|
|
||||||
|
|
||||||
### 4. Pipeline Panel
|
|
||||||
- 현재 Sprint
|
|
||||||
- active Lobster workflow
|
|
||||||
- cycle / retry / review loop
|
|
||||||
- handoff 상태
|
|
||||||
- deploy gate / approval 상태
|
|
||||||
|
|
||||||
### 5. Server Health Panel
|
|
||||||
- 4자매 서버 헬스
|
|
||||||
- Dev 서버
|
|
||||||
- Docker/infra 상태
|
|
||||||
- heartbeat / websocket / reconnect 상태
|
|
||||||
|
|
||||||
## 디자인 원칙
|
|
||||||
1. **은유는 강하게, 판단은 더 강하게**
|
|
||||||
- 오피스는 분위기용이 아니라 상태 판단용이야.
|
|
||||||
2. **실시간 우선, 추정은 정직하게**
|
|
||||||
- live / snapshot / doc-derived / fallback 구분 유지
|
|
||||||
3. **고정 좌석 + 동적 이동**
|
|
||||||
- 메인 자매는 늘 같은 자리에 있어야 함
|
|
||||||
- 서브에이전트만 워크플로우에 따라 이동/연결
|
|
||||||
4. **4자매 중심성 유지**
|
|
||||||
- 21개 전체를 보여도 중심은 언제나 하랑/나랑/다랑/이랑이야
|
|
||||||
5. **운영 패널과 오피스 뷰 결합**
|
|
||||||
- 보기 좋은 씬만 있고 운영 판단이 안 되면 실패
|
|
||||||
|
|
||||||
## 기술 방향
|
|
||||||
- Frontend: 기존 Next.js + styled-components 유지
|
|
||||||
- Backend: 기존 Nest.js + Prisma 유지
|
|
||||||
- 실시간: OpenClaw Gateway WebSocket 중심
|
|
||||||
- 보조 동기화: low-frequency polling snapshot 허용
|
|
||||||
- 렌더링: SVG + CSS animation 또는 canvas-lite 검토 가능
|
|
||||||
- 상태 저장: 기존 구조 유지하되 office scene 전용 store 계층 검토
|
|
||||||
|
|
||||||
## 데이터 소스 기준
|
|
||||||
| 대상 | 우선 소스 |
|
|
||||||
|---|---|
|
|
||||||
| 메인 에이전트 상태 | 4자매 Gateway WebSocket |
|
|
||||||
| 서브에이전트 상태 | 각 자매 runtime/agent event + workflow 상태 |
|
|
||||||
| 협업 연결선 | handoff / workflow transition / event stream |
|
|
||||||
| 채팅 인터페이스 | session/chat API |
|
|
||||||
| 파이프라인 현황 | Lobster workflow state + activity log |
|
|
||||||
| 서버 헬스 | admin/system/health 계열 API |
|
|
||||||
|
|
||||||
## 태스크
|
|
||||||
|
|
||||||
### TASK-091: 제품 PRD 및 IA 재정의
|
|
||||||
- **담당:** 하랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **산출물:**
|
|
||||||
- `docs/product-specs/openclaw-office-dashboard-prd.md`
|
|
||||||
- `.plans/OVERVIEW.md` 갱신
|
|
||||||
- **완료 기준:**
|
|
||||||
- 오피스 대시보드 비전/핵심 사용자/핵심 흐름/핵심 화면이 문서화됨
|
|
||||||
|
|
||||||
### TASK-092: 오피스 씬 레이아웃 설계
|
|
||||||
- **담당:** 하랑이 → 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **산출물:**
|
|
||||||
- `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- **완료 기준:**
|
|
||||||
- 4자매 좌석 / 서브에이전트 위치 / 회의실 / 인프라 구역 구조가 정의됨
|
|
||||||
|
|
||||||
### TASK-093: 채팅 워크스페이스 설계
|
|
||||||
- **담당:** 하랑이 → 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **산출물:**
|
|
||||||
- `.plans/design/ui/office-chat-design.md`
|
|
||||||
- **완료 기준:**
|
|
||||||
- 자매 선택 direct chat 구조와 패널 관계가 정의됨
|
|
||||||
|
|
||||||
### TASK-094: Gateway/WebSocket 실시간 모델 정의
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **주요 범위:**
|
|
||||||
- 4개 Gateway 연결 전략
|
|
||||||
- presence / health / workflow / agent event 정리
|
|
||||||
- reconnect / reconciliation 규칙
|
|
||||||
- **완료 기준:**
|
|
||||||
- live / snapshot / fallback 구분이 문서와 코드 양쪽에서 유지됨
|
|
||||||
|
|
||||||
### TASK-095: 메인 오피스 씬 구현
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **완료 기준:**
|
|
||||||
- 4자매 고정 좌석과 서브에이전트 동적 이동이 구현됨
|
|
||||||
- 상태별 시각 표현이 동작함
|
|
||||||
|
|
||||||
### TASK-096: 협업 시각화 + 회의실 이동 구현
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **완료 기준:**
|
|
||||||
- handoff 연결선
|
|
||||||
- 회의실 이동 상태
|
|
||||||
- review/deploy loop 표현이 동작함
|
|
||||||
|
|
||||||
### TASK-097: 직접 채팅 인터페이스 구현
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **완료 기준:**
|
|
||||||
- 자매 선택 direct chat 가능
|
|
||||||
- 최근 대화/응답/상태가 확인됨
|
|
||||||
|
|
||||||
### TASK-098: 서버 헬스 패널 구현
|
|
||||||
- **담당:** 나랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **완료 기준:**
|
|
||||||
- 4자매 + Dev + Docker 서버 상태가 함께 보임
|
|
||||||
|
|
||||||
### TASK-099: QA / 모바일 / 실브라우저 검증
|
|
||||||
- **담당:** 다랑이
|
|
||||||
- **상태:** pending
|
|
||||||
- **완료 기준:**
|
|
||||||
- Desktop / Tablet / Mobile 실브라우저 기준 확인
|
|
||||||
- live/snapshot 구분 검증
|
|
||||||
- 성능/가독성/blocker 확인
|
|
||||||
|
|
||||||
## 권장 구현 순서
|
|
||||||
1. PRD / IA / 오피스 씬 문서화
|
|
||||||
2. Gateway 실시간 모델 정리
|
|
||||||
3. 메인 오피스 씬 구현
|
|
||||||
4. 연결선 / 회의실 / 채팅 / 패널 구현
|
|
||||||
5. QA + 모바일 검증
|
|
||||||
|
|
||||||
## 완료 기준
|
|
||||||
- 4자매와 서브에이전트 구조가 오피스 화면에서 한눈에 보임
|
|
||||||
- 실시간 상태와 파이프라인이 실제 운영 흐름과 맞음
|
|
||||||
- 채팅/헬스/파이프라인이 오피스 뷰와 분리되지 않고 자연스럽게 이어짐
|
|
||||||
- 문서, 설계, 구현 기준이 `.plans/`에 정리됨
|
|
||||||
@@ -1,212 +0,0 @@
|
|||||||
# SPRINT-017: `/office` 모바일 화면 전면 개편
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
`/office`를 데스크톱 축소판이 아니라 **모바일 전용 운영 화면**으로 다시 정리해. 이번 Sprint의 성공 기준은 단순 반응형이 아니야. `360px`, `390px` 첫 화면에서 운영자가 바로 읽어야 할 정보가 세로 흐름으로 보이고, direct chat, pipeline, health, context가 모바일 기준으로 다시 배치되어야 해.
|
|
||||||
|
|
||||||
## 이번 Sprint의 한 줄 정의
|
|
||||||
`main`에 이미 있는 `/office` 구현을 기준으로, **새 API 없이** `frontend/app/office/page.tsx`와 `frontend/components/office/*`의 모바일 IA와 상태 표현을 다시 잠근다.
|
|
||||||
|
|
||||||
## 배경
|
|
||||||
현재 `main` 구현은 데스크톱 기준 구조가 먼저 잡혀 있어.
|
|
||||||
|
|
||||||
### 현재 구현에서 확인된 문제
|
|
||||||
1. `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `aspect-ratio: 800 / 460` 고정 씬이라 `mobile(<768)`에서 데스크톱 축소판처럼 보인다.
|
|
||||||
2. `frontend/app/office/page.tsx`
|
|
||||||
- 헤더 아래에 모바일 전용 summary hero가 없다.
|
|
||||||
- `ChatArea`가 `520px`, 모바일에서 `460px` 고정 높이라 세로 흐름을 끊는다.
|
|
||||||
- 핵심 정보가 `OfficeScene`, `ContextPanel`, 하단 패널로 흩어져 첫 viewport 우선순위가 없다.
|
|
||||||
3. `frontend/components/office/ContextPanel.tsx`
|
|
||||||
- 선택 전에는 "에이전트를 선택하면 상세 정보가 표시됩니다"만 보여서 첫 진입 정보가 비어 있다.
|
|
||||||
4. `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `overflow-x: auto`와 `min-width` 카드에 기대고 있어 모바일에서 가로 스크롤이 전제된다.
|
|
||||||
5. `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- direct chat이 모바일 세로 흐름보다 데스크톱 3열 구조에 가깝다.
|
|
||||||
- `JWT 없음`, `runtime 확인 중`, `empty`, `전송 실패`가 모바일에서 즉시 읽히는 구조가 아니다.
|
|
||||||
|
|
||||||
## 참고 문서
|
|
||||||
- 실행 개요: `.plans/OVERVIEW.md`
|
|
||||||
- 이전 Sprint: `.plans/sprints/SPRINT-016.md`
|
|
||||||
- 오피스 모바일 IA: `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- 오피스 direct chat 모바일 기준: `.plans/design/ui/office-chat-design.md`
|
|
||||||
- API 참고: `.plans/design/api-design.md`
|
|
||||||
- 제품 PRD: `docs/product-specs/openclaw-office-dashboard-prd.md`
|
|
||||||
|
|
||||||
## 기준 구현 경로
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `frontend/components/office/ContextPanel.tsx`
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `frontend/components/office/ServerHealthPanel.tsx`
|
|
||||||
|
|
||||||
## breakpoint 기준
|
|
||||||
- **360px:** 최소 지원 모바일 폭, 첫 viewport 가독성 기준
|
|
||||||
- **390px:** 기본 모바일 기준 폭
|
|
||||||
- **768px:** tablet 전환 시작점
|
|
||||||
- **1280px+:** desktop 기존 구조 유지 기준
|
|
||||||
|
|
||||||
## Sprint 범위
|
|
||||||
### 포함
|
|
||||||
- `mobile(<768)` 전용 상단 summary view-model 정의
|
|
||||||
- 첫 viewport 정보 우선순위 재설계
|
|
||||||
- compact sister status 블록 도입
|
|
||||||
- focus / health / quick action 블록 도입
|
|
||||||
- 모바일에서 office scene을 compact sister stack 또는 selectable status cards로 대체
|
|
||||||
- direct chat 모바일 1열 레이아웃 재정의
|
|
||||||
- pipeline / health 패널의 모바일 카드 흐름 재정의
|
|
||||||
- `live / snapshot / fallback` 및 `loading / empty / error / stale` 표현 통일
|
|
||||||
- `360 / 390 / 768 / 1280+` QA 기준 작성
|
|
||||||
|
|
||||||
### 제외
|
|
||||||
- 신규 백엔드 API
|
|
||||||
- WebSocket reconnect 정책 재설계
|
|
||||||
- 새 도메인 데이터 모델 추가
|
|
||||||
- 별도 모바일 앱
|
|
||||||
- 데스크톱 오피스 씬 컨셉 리뉴얼
|
|
||||||
|
|
||||||
## mobile first success criteria
|
|
||||||
### 첫 viewport 필수 정보 (`360px`, `390px`)
|
|
||||||
첫 화면 안에서 아래가 모두 보여야 해.
|
|
||||||
1. 4자매 상태 요약
|
|
||||||
2. current focus
|
|
||||||
3. health summary
|
|
||||||
4. quick actions
|
|
||||||
|
|
||||||
### 금지 사항
|
|
||||||
- 가로 스크롤
|
|
||||||
- 데스크톱 씬 축소판 유지
|
|
||||||
- 선택 전 빈 상태로 시작하는 context 구조
|
|
||||||
- 채팅 타임라인/입력창 잘림
|
|
||||||
|
|
||||||
### 유지 사항
|
|
||||||
- `live / snapshot / fallback` 의미 자체는 바꾸지 않는다
|
|
||||||
- desktop(`1280px+`)에서는 기존 scene + side panel 구조를 기능적으로 유지한다
|
|
||||||
- 기존 fetch 결과만 재조합하고 새 API는 추가하지 않는다
|
|
||||||
|
|
||||||
## 실행 계획
|
|
||||||
|
|
||||||
### T1. scope와 mobile IA 잠금
|
|
||||||
**대상 문서**
|
|
||||||
- `.plans/OVERVIEW.md`
|
|
||||||
- `.plans/sprints/SPRINT-017.md`
|
|
||||||
- `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- `.plans/design/ui/office-chat-design.md`
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- 첫 viewport 필수 정보가 문서에 명시된다
|
|
||||||
- 금지 사항과 유지 사항이 문서에 명시된다
|
|
||||||
- 실제 구현 파일 경로가 교차 참조된다
|
|
||||||
|
|
||||||
### T2. 모바일 상단 summary view-model 정의
|
|
||||||
**대상 파일**
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- 기존 sisters / ops / server 데이터를 재조합해 모바일 summary에 필요한 값을 만든다
|
|
||||||
- 선택 전에도 빈 화면이 아니라 기본 summary 콘텐츠가 먼저 보이게 한다
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- sister status 집계가 계산된다
|
|
||||||
- current focus가 상단에서 바로 보인다
|
|
||||||
- health summary와 quick action 대상이 함께 계산된다
|
|
||||||
|
|
||||||
### T3. `/office` 레이아웃을 mobile-first 세로 스택으로 재배치
|
|
||||||
**대상 파일**
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- 모바일에서는 `summary hero → compact sister status → focus/health/action block → panel sections` 순서로 재구성한다
|
|
||||||
- desktop(`1280px+`)에서만 기존 scene + context + bottom panels 구조를 유지한다
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- `360px`, `390px` 첫 viewport에서 핵심 정보 4종이 읽힌다
|
|
||||||
- 페이지 전체에 가로 스크롤이 없다
|
|
||||||
- desktop 구조가 기능적으로 유지된다
|
|
||||||
|
|
||||||
### T4. scene / context 모바일 대체
|
|
||||||
**대상 파일**
|
|
||||||
- `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `frontend/components/office/ContextPanel.tsx`
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- 모바일에서는 `800x460` 씬을 그대로 축소하지 않는다
|
|
||||||
- compact sister stack 또는 selectable status cards로 바꾼다
|
|
||||||
- context는 별도 우측 패널이 아니라 인라인 상세, accordion, sheet 중 하나로 흡수한다
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- 선택 없이도 기본 context가 보인다
|
|
||||||
- sister 선택과 상세 확인이 세로 흐름 안에서 끝난다
|
|
||||||
- 모바일에서 scene은 상징이 아니라 정보 전달 수단이 된다
|
|
||||||
|
|
||||||
### T5. direct chat 모바일 1열 재정렬
|
|
||||||
**대상 파일**
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- 자매 전환, runtime badge, 타임라인, composer, 보조 상태를 한 컬럼 흐름으로 재배치한다
|
|
||||||
- 고정 높이 의존을 줄인다
|
|
||||||
- `JWT 없음`, `empty`, `전송 실패`, `runtime 확인 중` 상태를 상단 또는 입력 근처에서 즉시 읽히게 한다
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- `360px`, `390px`에서 메시지, 입력창, 상태 라벨이 겹치지 않는다
|
|
||||||
- send disabled 이유가 숨겨지지 않는다
|
|
||||||
- `user / assistant / tool` 메시지 구분이 유지된다
|
|
||||||
|
|
||||||
### T6. pipeline / health 모바일 카드화
|
|
||||||
**대상 파일**
|
|
||||||
- `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `frontend/components/office/ServerHealthPanel.tsx`
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- pipeline은 가로 노드열 대신 세로 단계 카드로 재배치한다
|
|
||||||
- health는 summary 우선, 상세는 확장 또는 후순위 카드로 정리한다
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- 모바일에서 가로 스크롤이 없다
|
|
||||||
- active task, focus, review loop, deploy state가 1~2스크린 안에 파악된다
|
|
||||||
- online count와 source badge가 유지된다
|
|
||||||
|
|
||||||
### T7. 상태 라벨 통일
|
|
||||||
**대상 파일**
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `frontend/components/office/ServerHealthPanel.tsx`
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- `live / snapshot / fallback` 라벨을 모바일 기준으로 짧게 통일한다
|
|
||||||
- `loading / empty / error / stale` 표현을 패널 간 같은 톤으로 맞춘다
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- source 의미가 첫 화면과 각 패널에서 같은 단어로 보인다
|
|
||||||
- `empty`와 `error`가 다른 문구로 표현된다
|
|
||||||
- `fallback` 의미가 사라지지 않는다
|
|
||||||
|
|
||||||
### T8. breakpoint QA
|
|
||||||
**산출물**
|
|
||||||
- `.plans/qa/SPRINT-017-review-1.md` 이상
|
|
||||||
|
|
||||||
**작업**
|
|
||||||
- `360 / 390 / 768 / 1280+` 실브라우저 체크
|
|
||||||
- 첫 viewport 정보 충족 여부와 horizontal scroll 부재 확인
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- breakpoint별 결과가 분리 기록된다
|
|
||||||
- blocker / warning / follow-up이 분리된다
|
|
||||||
- direct chat, pipeline, health, context 재배치 검증이 남는다
|
|
||||||
|
|
||||||
## 완료 기준
|
|
||||||
- `360px`, `390px` 첫 화면에서 4자매 상태, current focus, health summary, quick actions를 모두 읽을 수 있다
|
|
||||||
- `mobile(<768)`에서 데스크톱 축소판이 사라진다
|
|
||||||
- `ContextPanel` 선택 의존 구조가 모바일 기본 흐름 안으로 흡수된다
|
|
||||||
- `PipelinePanel`과 `ServerHealthPanel`이 가로 스크롤 없이 읽힌다
|
|
||||||
- `ChatWorkspace`가 모바일 direct chat로 동작하고, `JWT 없음 / empty / error / runtime 확인 중` 상태가 즉시 읽힌다
|
|
||||||
- `live / snapshot / fallback` 의미가 유지된 채 문구가 통일된다
|
|
||||||
|
|
||||||
## 핸드오프 메모
|
|
||||||
- 하랑이는 scope와 우선순위를 잠근다
|
|
||||||
- 나랑이는 `page.tsx`와 `office/*` 모바일 IA를 구현한다
|
|
||||||
- 다랑이는 `360 / 390 / 768 / 1280+` 기준으로 실브라우저 QA를 남긴다
|
|
||||||
- 이번 Sprint는 "안정화 전체"가 아니라 **모바일 운영 화면 재구성**까지로 좁게 끝낸다
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
# SPRINT-018: dashboard truth redesign
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
`/office`, `/`, `/projects/[id]`, `/org`를 하나의 운영 정보 구조로 재정렬하고, `connection`, `activity`, `participation`, `freshness`, `source`를 분리한 source-of-truth로 다시 잠근다.
|
|
||||||
|
|
||||||
## 한 줄 정의
|
|
||||||
SPRINT-017의 모바일 개편 범위와 HOTFIX-006의 정합성 보정 범위를 이어서, 이번 Sprint는 **운영 의미를 다시 정의하는 문서 Sprint**다.
|
|
||||||
|
|
||||||
## 배경
|
|
||||||
현재 구현은 화면마다 정보는 많지만, 운영 의미가 섞여 있다.
|
|
||||||
- `/office`는 fallback seed가 `working`처럼 읽히는 구간이 있다
|
|
||||||
- `/`는 `socket off`와 freshness가 분리되지 않아 전체 오류처럼 보일 수 있다
|
|
||||||
- `/projects/[id]`는 unique assignee 목록을 실제 participant처럼 보여준다
|
|
||||||
- `/org`는 회사형 조직도가 아니라 하드코딩된 자매 트리에 가깝다
|
|
||||||
- 모바일 `360px`, `390px` 기준으로 긴 문장과 카드가 쉽게 넘친다
|
|
||||||
|
|
||||||
## 참고 문서
|
|
||||||
- 실행 개요: `.plans/OVERVIEW.md`
|
|
||||||
- 이전 Sprint: `.plans/sprints/SPRINT-017.md`
|
|
||||||
- 관련 hotfix: `.plans/hotfix/HOTFIX-006.md`
|
|
||||||
- API 설계: `.plans/design/api-design.md`
|
|
||||||
- UI 설계:
|
|
||||||
- `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
- `.plans/design/ui/project-detail-design.md`
|
|
||||||
- `.plans/design/ui/org-design.md`
|
|
||||||
- QA 초안: `.plans/qa/SPRINT-018-review-1.md`
|
|
||||||
|
|
||||||
## 페이지 역할 고정
|
|
||||||
| 페이지 | 역할 | primary question | source priority |
|
|
||||||
|---|---|---|---|
|
|
||||||
| `/office` | live operations workspace | 지금 누가 연결되어 있고, 누가 실제로 일하고 있으며, 어디에 바로 개입해야 하나 | live → snapshot → fallback |
|
|
||||||
| `/` | executive snapshot | 지금 운영 전체에서 가장 먼저 볼 변화가 무엇인가 | mirrored event + snapshot + doc-derived |
|
|
||||||
| `/projects/[id]` | delivery detail | 이 프로젝트의 구현, QA, deploy, 참여 상태가 어디까지 왔나 | project snapshot + participant summary + task assignee aggregate |
|
|
||||||
| `/org` | company org map | 누가 어떤 조직 단위에 속하고, independent agents는 어디에 위치하나 | org snapshot |
|
|
||||||
|
|
||||||
## 공통 용어 표
|
|
||||||
| 용어 | 정의 | 금지 |
|
|
||||||
|---|---|---|
|
|
||||||
| `connection` | gateway/socket/runtime 연결 가능 여부 | activity와 같은 뜻으로 쓰기 |
|
|
||||||
| `activity` | 최근 event, session, message, task evidence | connection만 보고 activity 추정 확정하기 |
|
|
||||||
| `working` | 명시적 운영 상태. active task, current session, recent operator evidence가 있는 경우만 active 표시 | fallback seed나 단순 animated state로 주입하기 |
|
|
||||||
| `owner` | 현재 책임자. 없으면 null 허용 | fallback 기본값으로 특정 자매 고정하기 |
|
|
||||||
| `participant` | 현재 프로젝트/흐름에서 왜 보이는지 설명 가능한 사람 | unique assignee 목록을 그대로 participant로 표기하기 |
|
|
||||||
| `assignee` | task 할당 기준 인원 | participant와 같은 섹션명 쓰기 |
|
|
||||||
| `freshness` | 언제 생성, 동기화, 미러링되었는지 | socket on/off만으로 freshness 대체하기 |
|
|
||||||
| `source` | 값이 어디서 왔는지 (`live`, `mirrored event`, `snapshot`, `doc-derived`, `fallback`) | 서로 다른 source를 같은 사실처럼 라벨링하기 |
|
|
||||||
|
|
||||||
## Sprint 원칙
|
|
||||||
- `360px`, `390px` 기준 horizontal scroll 금지
|
|
||||||
- 긴 badge, 긴 meta 문구, 긴 이유 문구는 wrap 기준으로 설계
|
|
||||||
- fallback, snapshot, live를 같은 사실처럼 보이게 하지 않음
|
|
||||||
- `working`, `owner`, `participant`는 추정치와 확정치를 분리해 표시
|
|
||||||
- 페이지별 역할은 다르지만 source/freshness contract는 공유
|
|
||||||
|
|
||||||
## 범위
|
|
||||||
### 포함
|
|
||||||
- SPRINT-018 운영 정보 구조와 용어 잠금
|
|
||||||
- sisters/dashboard/project/org API truth contract 재설계 문서화
|
|
||||||
- `/office`, `/`, `/projects/[id]`, `/org` UI 정보 구조 재설계
|
|
||||||
- source badge, freshness label, empty/null 표현 기준 통일
|
|
||||||
- 교차 페이지 QA 시나리오 초안 작성
|
|
||||||
|
|
||||||
### 제외
|
|
||||||
- 실제 API 구현
|
|
||||||
- DB schema migration
|
|
||||||
- websocket namespace 변경
|
|
||||||
- 새 역할 체계 추가
|
|
||||||
- 조직도 authoring 툴 구축
|
|
||||||
|
|
||||||
## 실행 계획
|
|
||||||
|
|
||||||
### T1. 운영 정보 구조 및 source-of-truth 명세 잠금
|
|
||||||
**대상 문서**
|
|
||||||
- `.plans/OVERVIEW.md`
|
|
||||||
- `.plans/sprints/SPRINT-018.md`
|
|
||||||
- `.plans/design/api-design.md`
|
|
||||||
- `.plans/design/ui/office-dashboard-design.md`
|
|
||||||
- `.plans/design/ui/dashboard-design.md`
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- 페이지 역할이 고정된다
|
|
||||||
- 공통 용어 표가 문서에 들어간다
|
|
||||||
- 모바일 overflow 금지 규칙이 문서에 명시된다
|
|
||||||
- fallback / null / empty 처리 기준이 문서에 들어간다
|
|
||||||
|
|
||||||
### T2. 자매 운영 상태 source-of-truth 계약 재설계
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `backend/src/sisters/sisters.service.ts`
|
|
||||||
- `backend/src/dashboard/dashboard.service.ts`
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- `connection`, `activity`, `working`, `lastActiveAt`, `source`, `freshness`를 분리 반환한다
|
|
||||||
- `connected but idle`, `snapshot only`, `fallback`, `offline`을 구분 가능한 상태로 만든다
|
|
||||||
- 프론트 fallback seed는 `working`을 직접 주입하지 않는다
|
|
||||||
|
|
||||||
### T3. 프로젝트 참여자 계약 분리 설계
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
- `backend/src/projects/*`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- participant summary와 task assignee aggregate를 별도 필드로 분리한다
|
|
||||||
- participant마다 `whyVisible`을 붙인다
|
|
||||||
- active participant가 없으면 null/empty를 그대로 보여준다
|
|
||||||
|
|
||||||
### T4. 조직도 데이터 계약 재설계
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `backend/src/sisters/sister-detail.service.ts`
|
|
||||||
- `frontend/app/org/page.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- `/api/org`는 `orgUnits`, `members`, `reportingLines`, `independentAgents`를 반환한다
|
|
||||||
- sister-owned agents와 independent agents를 분리한다
|
|
||||||
- 특정 자매를 하드코딩한 고정 트리에 의존하지 않는다
|
|
||||||
|
|
||||||
### T5. `/office` shell, scene, context 재배치
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `frontend/app/office/page.tsx`
|
|
||||||
- `frontend/components/office/OfficeScene.tsx`
|
|
||||||
- `frontend/components/office/ContextPanel.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- desktop은 group/scene 중심 운영 레이아웃으로 재구성한다
|
|
||||||
- mobile(`<768`)은 `summary → group blocks → detail flow`로 바꾼다
|
|
||||||
- 첫 진입 시 빈 context 대신 운영 summary를 보여준다
|
|
||||||
|
|
||||||
### T6. `/office` 하위 패널 모바일 정보 밀도 재정렬
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `frontend/components/office/ChatWorkspace.tsx`
|
|
||||||
- `frontend/components/office/PipelinePanel.tsx`
|
|
||||||
- `frontend/components/office/ServerHealthPanel.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- horizontal scroll을 제거한다
|
|
||||||
- `JWT missing`, `runtime checking`, `empty`, `error`, `send disabled`를 즉시 읽히게 한다
|
|
||||||
- 상태 라벨 톤을 패널 간 통일한다
|
|
||||||
|
|
||||||
### T7. 메인 대시보드 운영 의미 재정렬
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `frontend/app/page.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- socket connection과 freshness를 분리한다
|
|
||||||
- active owner가 없을 때 fallback owner를 고정 노출하지 않는다
|
|
||||||
- 주요 섹션에 source 라벨을 일관되게 붙인다
|
|
||||||
|
|
||||||
### T8. 프로젝트 상세 레이아웃과 참여자 표현 재설계
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `frontend/app/projects/[id]/page.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- `ASSIGNED NODES`를 truthful section으로 교체한다
|
|
||||||
- participant, current owner, task assignee를 분리한다
|
|
||||||
- 나랑이 단독 노출도 확정 참여처럼 읽히지 않게 `reason/source`를 붙인다
|
|
||||||
|
|
||||||
### T9. 회사형 조직도 UI 전면 재설계
|
|
||||||
**기준 구현 파일**
|
|
||||||
- `frontend/app/org/page.tsx`
|
|
||||||
|
|
||||||
**핵심 결정**
|
|
||||||
- HQ, functional teams, members, independent agents 구조로 재배치한다
|
|
||||||
- terminal tree 한 벌이 아니라 mobile에서도 읽히는 카드형 org map을 만든다
|
|
||||||
|
|
||||||
### T10. 교차 페이지 QA 및 문서 마감
|
|
||||||
**산출물**
|
|
||||||
- `.plans/qa/SPRINT-018-review-1.md`
|
|
||||||
- `.plans/OVERVIEW.md`
|
|
||||||
- `.plans/sprints/SPRINT-018.md`
|
|
||||||
|
|
||||||
**done when**
|
|
||||||
- `/office`, `/`, `/projects/[id]`, `/org`를 `360 / 390 / 768 / 1280+`로 분리 기록한다
|
|
||||||
- `socket disconnected`, `snapshot only`, `fallback only`, `connected idle`, `active working`, `no active owner`, `empty chat`, `JWT missing`를 검증한다
|
|
||||||
- `working / owner / participant / source badge` 의미가 페이지 간 같게 보이는지 확인한다
|
|
||||||
|
|
||||||
## acceptance
|
|
||||||
- 각 페이지 역할과 공통 용어가 문서에 고정되어 있다
|
|
||||||
- API 문서에 `connection / activity / working / freshness / source` 분리 계약이 있다
|
|
||||||
- `/office`, `/`, `/projects/[id]`, `/org` UI 문서가 truthful empty/null 상태를 포함한다
|
|
||||||
- 모바일 `360px`, `390px`에서 overflow 금지 규칙이 모든 관련 문서에 반영되어 있다
|
|
||||||
- QA 문서가 breakpoint와 상태 시나리오를 함께 다룬다
|
|
||||||
|
|
||||||
## rollout
|
|
||||||
1. 문서 기준 잠금
|
|
||||||
2. backend contract 구현
|
|
||||||
3. `/office`와 `/` state badge 정리
|
|
||||||
4. project detail participant model 반영
|
|
||||||
5. org contract + UI 반영
|
|
||||||
6. 교차 페이지 QA
|
|
||||||
|
|
||||||
## out-of-scope follow-up
|
|
||||||
- activity evidence를 더 세밀하게 저장하는 schema 정리
|
|
||||||
- participant reason 자동 생성 규칙 정교화
|
|
||||||
- org map edit UI
|
|
||||||
- source badge analytics
|
|
||||||
|
|
||||||
## handoff 메모
|
|
||||||
- SPRINT-017 문서는 `/office` mobile IA 기준으로 유지한다. SPRINT-018은 그 위에 cross-page truth contract를 추가하는 Sprint다.
|
|
||||||
- HOTFIX-006의 `socket / freshness / doc-derived` 문제는 이번 Sprint에서 메인 대시보드 전체 계약으로 승격한다.
|
|
||||||
- 구현 시 문서보다 더 센 추정치 표현이 생기면 문서 기준이 우선이다.
|
|
||||||
@@ -1,40 +1,11 @@
|
|||||||
# HOTFIX-006 review iteration 2
|
# HOTFIX-006 review iteration 2
|
||||||
- reviewed_at: 2026-04-05 14:03 UTC
|
- reviewed_at: 2026-04-05 09:33 KST
|
||||||
- passed: true
|
- passed: false
|
||||||
- repo: https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard
|
- blocking:
|
||||||
- branch: hotfix/HOTFIX-006-dashboard-assignees
|
- backend build still fails with PrismaService type errors (`this.prisma.project/sprint/task/sisterConfig` missing), so build-pass claim is still false on latest branch state
|
||||||
|
- non_blocking:
|
||||||
## checks
|
- frontend fixes requested in review #1 are reflected: project avatar removed, mobile charts use overflow-x/min-width, hotfix history renders summary/description fallback, assigned nodes derive from assignees with avatars
|
||||||
- backend test: ✅ passed (`npx prisma generate` 후 jest 26 tests / 9 suites 통과)
|
- subagents:
|
||||||
- backend build: ✅ passed (`npx prisma generate` 후 build 통과)
|
- code-reviewer: not run (agent unavailable in current environment)
|
||||||
- frontend build: ✅ passed
|
- security-auditor: not run (agent unavailable in current environment)
|
||||||
- frontend lint: ⚠️ failed (repo-wide pre-existing `no-explicit-any` / unused vars 위주)
|
- qa-tester: not run (agent unavailable in current environment)
|
||||||
- frontend visual check: ✅ passed
|
|
||||||
- dashboard 홈에서 `SISTER LOAD`, `PROJECT PROGRESS` 그래프 정상 렌더링 확인
|
|
||||||
- 프로젝트 상세에서 `HOTFIX HISTORY`, `ASSIGNED NODES` 정상 렌더링 확인
|
|
||||||
- mock API 기준 ASSIGNED NODES 다중 assignee(`narang`, `darang`, `erang`) 반영 확인
|
|
||||||
|
|
||||||
## blocking issues
|
|
||||||
- 없음
|
|
||||||
|
|
||||||
## non-blocking notes
|
|
||||||
- clean install 직후 backend jest/build는 Prisma client 미생성 상태로 실패했고 `npx prisma generate` 후 정상화됨
|
|
||||||
- frontend lint 실패는 이번 hotfix 전용 이슈가 아니라 repo-wide 타입/unused 규칙 위반 영향
|
|
||||||
- `frontend/app/page.tsx`, `frontend/app/projects/[id]/page.tsx`의 `any` 사용은 후속 정리 권장
|
|
||||||
|
|
||||||
## subagent summaries
|
|
||||||
- code-reviewer: PASS
|
|
||||||
- 범위 이탈 없음
|
|
||||||
- low: history fetch N+1 패턴, 일부 설계와의 시각적 차이(avatar → initial mark), any 타입 잔존
|
|
||||||
- security-auditor: PASS
|
|
||||||
- hotfix 범위 내 high 없음
|
|
||||||
- repo-wide backend dependency audit 이슈는 기존 항목
|
|
||||||
- qa-tester: PASS
|
|
||||||
- iteration 1 blocking 이슈(HOTFIX HISTORY 미표시, ASSIGNED NODES 하드코딩, backend build 실패) 해소 확인
|
|
||||||
- dashboard/project detail 화면 요구사항 충족 확인
|
|
||||||
|
|
||||||
## verdict
|
|
||||||
- `.plans/design/ui/dashboard-design.md` 기준 그래프 렌더링 정상
|
|
||||||
- `.plans/design/ui/project-detail-design.md` 기준 HOTFIX HISTORY / ASSIGNED NODES 렌더링 정상
|
|
||||||
- `.plans` 범위 이탈 없음
|
|
||||||
- HOTFIX-006 머지 가능
|
|
||||||
|
|||||||
@@ -1,40 +1,16 @@
|
|||||||
# HOTFIX-006 review iteration 3
|
# HOTFIX-006 review iteration 3
|
||||||
- reviewed_at: 2026-04-05 14:16 UTC
|
- reviewed_at: 2026-04-05 09:35 KST
|
||||||
- passed: true
|
- passed: true
|
||||||
- repo: https://git.nabomhalang.co.kr/hanarang/hanarang-dashboard
|
- blocking: none
|
||||||
- branch: hotfix/HOTFIX-006-dashboard-assignees
|
- non_blocking:
|
||||||
|
- backend build depends on Prisma Client regeneration; local clean/CI 환경이면 `npx prisma generate` 선행 보장 필요
|
||||||
## checks
|
- backend npm audit still reports 7 vulnerabilities (4 moderate, 3 high) in dependency tree
|
||||||
- backend test: ✅ passed (`npx prisma generate` 후 jest 26 tests / 9 suites 통과)
|
- verification:
|
||||||
- backend build: ✅ passed (`npx prisma generate` 후 build 통과)
|
- frontend npm run build: passed
|
||||||
- frontend build: ✅ passed
|
- backend npx prisma generate: passed
|
||||||
- frontend lint: ⚠️ failed (repo-wide pre-existing `no-explicit-any` / unused vars)
|
- backend npm run build: passed
|
||||||
- frontend visual check: ✅ passed
|
- frontend fixes retained: project neutral mark, mobile chart horizontal scroll, hotfix summary/description rendering, assignee-based assigned nodes
|
||||||
- dashboard 홈에서 `SISTER LOAD`, `PROJECT PROGRESS` 그래프 정상 렌더링 확인
|
- subagents:
|
||||||
- 프로젝트 상세에서 `HOTFIX HISTORY`, `ASSIGNED NODES` 정상 표시 확인
|
- code-reviewer: not run (agent unavailable in current environment)
|
||||||
- mock API 기준 `narang`, `darang`, `erang` 다중 assignee 표시 확인
|
- security-auditor: not run (agent unavailable in current environment)
|
||||||
|
- qa-tester: not run (agent unavailable in current environment)
|
||||||
## blocking issues
|
|
||||||
- 없음
|
|
||||||
|
|
||||||
## non-blocking notes
|
|
||||||
- clean install 직후 backend는 Prisma Client 생성 전이라 test/build 불가했고 `npx prisma generate` 후 정상화됨
|
|
||||||
- `.plans` 변경 자체는 범위 이탈 없음. 다만 `HOTFIX-006.md` 계획 파일은 보이지 않아 추적성 관점에선 후속 보완 권장
|
|
||||||
- frontend lint 실패는 이번 hotfix 전용 이슈가 아니라 repo-wide 기존 부채
|
|
||||||
|
|
||||||
## subagent summaries
|
|
||||||
- code-reviewer: PASS
|
|
||||||
- 범위 이탈 없음
|
|
||||||
- non-blocking: `HOTFIX-006.md` 부재, history fetch N+1, 일부 any 타입/시각적 차이
|
|
||||||
- security-auditor: PASS
|
|
||||||
- hotfix 범위 내 high 없음
|
|
||||||
- medium: history endpoint 병렬 fetch 과다 가능성
|
|
||||||
- qa-tester: PASS
|
|
||||||
- 그래프 렌더링 / ASSIGNED NODES / HOTFIX HISTORY 요구사항 충족 확인
|
|
||||||
- 신규 sprint-sync spec 3건 포함 backend 테스트 통과 확인
|
|
||||||
|
|
||||||
## verdict
|
|
||||||
- dashboard graph rendering: pass
|
|
||||||
- project detail assigned nodes multi-assignee: pass
|
|
||||||
- `.plans` 범위 이탈: pass
|
|
||||||
- HOTFIX-006 머지 가능
|
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
# ARCHITECTURE.md — 하나랑 대시보드
|
|
||||||
|
|
||||||
## 목표
|
|
||||||
하나랑 대시보드는 4자매 멀티에이전트 운영 상태, 프로젝트 진행, QA 결과, 배포 상태를 한눈에 보여주는 관제 대시보드야.
|
|
||||||
이 문서는 현재 런타임 구조와, 이번 Sprint 014에서 반영할 Hermes 전환/문서 구조 개편 기준을 함께 정리해.
|
|
||||||
|
|
||||||
## 핵심 원칙
|
|
||||||
- 하랑은 코드 직접 수정하지 않고 문서/오케스트레이션만 담당
|
|
||||||
- `main`은 항상 배포 가능 상태를 유지
|
|
||||||
- 나랑 구현 → 다랑 QA → 하랑 main merge → 이랑 main pull + 재배포 순서를 고정
|
|
||||||
- 문서가 코드보다 먼저 올라가야 함
|
|
||||||
- 런타임/문서 구조 변경 시 한 번에 끊지 말고 호환 구간을 둠
|
|
||||||
|
|
||||||
## 시스템 아키텍처
|
|
||||||
|
|
||||||
### 1) Control Plane
|
|
||||||
- Frontend: `frontend/` (Next.js 16 + styled-components)
|
|
||||||
- Backend: `backend/` (Nest.js + Prisma)
|
|
||||||
- DB: MariaDB
|
|
||||||
- Gitea 연동: repo / branch / commit / PR / plan 문서 tree 조회
|
|
||||||
|
|
||||||
### 2) Agent Plane
|
|
||||||
- 하랑: Orchestrator / Planner
|
|
||||||
- 나랑: Generator / Developer
|
|
||||||
- 다랑: Evaluator / QA
|
|
||||||
- 이랑: Infra / Deploy
|
|
||||||
|
|
||||||
### 3) Execution Plane
|
|
||||||
- 각 자매 노드는 Hermes 기반 워크스페이스를 사용
|
|
||||||
- 기존 OpenClaw 경로를 일부 유지하던 코드는 Hermes 경로를 우선 지원해야 함
|
|
||||||
- 이번 개편에서 다음 경로를 기본값으로 삼음
|
|
||||||
- workspace: `~/.hermes/workspace`
|
|
||||||
- sessions: `~/.hermes/sessions`
|
|
||||||
- agents: `~/.hermes/workspace/agents`
|
|
||||||
- avatars: `~/.hermes/avatar.(png|jpg|jpeg|webp)`
|
|
||||||
- 단, 이행 기간 동안은 `.openclaw` 경로도 fallback으로 함께 읽어야 함
|
|
||||||
|
|
||||||
## 배포/운영 흐름
|
|
||||||
1. 하랑이 `.plans/`, `ARCHITECTURE.md`, `docs/`를 먼저 작성하고 push
|
|
||||||
2. 나랑이가 feature/hotfix branch에서 구현 후 push
|
|
||||||
3. 다랑이가 같은 branch를 pull해서 QA 수행, `.plans/qa/`에 결과 md 작성 후 push
|
|
||||||
4. 하랑이가 QA 결과를 확인하고 `main`으로 merge
|
|
||||||
5. `main`은 즉시 배포 기준 브랜치가 됨
|
|
||||||
6. 이랑이는 별도 수정 없이 최신 `main`을 pull해서 재배포만 수행
|
|
||||||
|
|
||||||
## 저장소 구조 — 표준
|
|
||||||
```text
|
|
||||||
hanarang-dashboard/
|
|
||||||
├── AGENTS.md
|
|
||||||
├── ARCHITECTURE.md
|
|
||||||
├── README.md
|
|
||||||
├── .plans/
|
|
||||||
│ ├── OVERVIEW.md
|
|
||||||
│ ├── design/
|
|
||||||
│ │ ├── index.md
|
|
||||||
│ │ ├── DESIGN-SYSTEM.md
|
|
||||||
│ │ ├── architecture.md
|
|
||||||
│ │ ├── api-design.md
|
|
||||||
│ │ ├── db-schema.md
|
|
||||||
│ │ └── ui/
|
|
||||||
│ ├── sprints/
|
|
||||||
│ ├── hotfix/
|
|
||||||
│ ├── qa/
|
|
||||||
│ └── deploy/
|
|
||||||
├── docs/
|
|
||||||
│ ├── product-specs/
|
|
||||||
│ ├── references/
|
|
||||||
│ ├── tech-debt-tracker.md
|
|
||||||
│ └── QUALITY_SCORE.md
|
|
||||||
├── frontend/
|
|
||||||
└── backend/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Sprint 014 이행 규칙
|
|
||||||
- Backend는 다음 두 구조를 동시에 읽을 수 있어야 함
|
|
||||||
- 기존: `.plans/sprints/`, `.qa/`, `.openclaw/...`
|
|
||||||
- 신규: `.plans/sprints/`, `.plans/hotfix/`, `.plans/qa/`, `.hermes/...`
|
|
||||||
- Frontend 프로젝트 페이지는 Sprint / Hotfix / QA / Deploy 흐름을 기준으로 다시 구성
|
|
||||||
- 네비게이션에서 프로젝트는 두 번째 위치로 고정
|
|
||||||
|
|
||||||
## 이번 개편의 직접 목적
|
|
||||||
- Hermes 전환 때문에 전체 자매가 offline으로 보이는 문제 해결
|
|
||||||
- 자매 프로필 이미지 fallback 체계 정리
|
|
||||||
- 변경된 파일 구조에 맞춘 프로젝트 진행률/이력/핫픽스 UI 재설계
|
|
||||||
- `main = deployable` 원칙을 코드/문서/UI에 일관되게 반영
|
|
||||||
77
README.md
77
README.md
@@ -1,53 +1,38 @@
|
|||||||
# 하나랑 대시보드
|
# 하나랑 대시보드
|
||||||
|
|
||||||
4자매 멀티에이전트 파이프라인 관제 대시보드.
|
4자매 멀티에이전트 파이프라인 관제 대시보드.
|
||||||
자기야가 한눈에 전체 현황, 프로젝트 흐름, QA 상태, 배포 상태를 파악하고 관리하는 화면.
|
자기야가 한눈에 전체 현황을 파악하고 관리할 수 있는 화면.
|
||||||
|
|
||||||
## 기술 스택
|
## 기술 스택
|
||||||
- Frontend: Next.js 16 + styled-components
|
|
||||||
- Backend: Nest.js + Prisma
|
|
||||||
- DB: MariaDB
|
|
||||||
- Realtime: Socket.IO
|
|
||||||
- FE: `https://hanarang.nabomhalang.co.kr`
|
|
||||||
- BE: `https://hanarang-api.nabomhalang.co.kr`
|
|
||||||
|
|
||||||
## 표준 저장소 구조
|
| 레이어 | 기술 |
|
||||||
```text
|
|--------|------|
|
||||||
|
| Frontend | Next.js + styled-components |
|
||||||
|
| Backend | Nest.js + Prisma |
|
||||||
|
| DB | MariaDB |
|
||||||
|
| 도메인 (FE) | `hanarang.nabomhalang.co.kr` |
|
||||||
|
| 도메인 (BE) | `hanarang-api.nabomhalang.co.kr` |
|
||||||
|
|
||||||
|
## 프로젝트 구조
|
||||||
|
|
||||||
|
```
|
||||||
hanarang-dashboard/
|
hanarang-dashboard/
|
||||||
├── ARCHITECTURE.md
|
├── frontend/ # Next.js (포트 3004)
|
||||||
├── README.md
|
├── backend/ # Nest.js (포트 3005)
|
||||||
├── .plans/
|
├── .gitignore
|
||||||
│ ├── OVERVIEW.md
|
├── .env.example
|
||||||
│ ├── design/
|
└── README.md
|
||||||
│ ├── sprints/
|
|
||||||
│ ├── hotfix/
|
|
||||||
│ ├── qa/
|
|
||||||
│ └── deploy/
|
|
||||||
├── docs/
|
|
||||||
│ ├── product-specs/
|
|
||||||
│ ├── references/
|
|
||||||
│ ├── tech-debt-tracker.md
|
|
||||||
│ └── QUALITY_SCORE.md
|
|
||||||
├── frontend/
|
|
||||||
└── backend/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 작업 파이프라인
|
|
||||||
1. 하랑이 문서 작성 및 선 push
|
|
||||||
2. 나랑이 구현 branch 작업
|
|
||||||
3. 다랑이 QA + `.plans/qa/` 결과 문서 push
|
|
||||||
4. 하랑이 QA 확인 후 `main` merge
|
|
||||||
5. 이랑이 최신 `main` pull + 재배포
|
|
||||||
|
|
||||||
> `main`은 항상 배포 가능 상태를 유지해.
|
|
||||||
|
|
||||||
## 실행 방법
|
## 실행 방법
|
||||||
|
|
||||||
### 사전 준비
|
### 사전 준비
|
||||||
1. 루트 `.env.example` 참고
|
|
||||||
2. `backend/.env` 작성
|
1. `.env.example`을 참고해 `backend/.env` 파일 생성
|
||||||
3. `SSH_KEY_PATH` 설정
|
2. SSH 키 설정 (`SSH_KEY_PATH`)
|
||||||
|
|
||||||
### Backend
|
### Backend
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd backend
|
cd backend
|
||||||
npm install
|
npm install
|
||||||
@@ -57,14 +42,22 @@ npm run dev
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Frontend
|
### Frontend
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd frontend
|
cd frontend
|
||||||
npm install
|
npm install
|
||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
## 참고 문서
|
## 환경 변수
|
||||||
- 아키텍처: `ARCHITECTURE.md`
|
|
||||||
- 실행 문서: `.plans/OVERVIEW.md`
|
루트 `.env.example` 참조.
|
||||||
- 구조 기준: `docs/references/repo-structure.md`
|
|
||||||
- 프로젝트 IA: `docs/product-specs/project-information-architecture.md`
|
## 자매 담당
|
||||||
|
|
||||||
|
| 역할 | 이름 | 담당 |
|
||||||
|
|------|------|------|
|
||||||
|
| 기획 | 하랑이 | Orchestrator |
|
||||||
|
| 개발 | 나랑이 | Generator |
|
||||||
|
| 검증 | 다랑이 | Evaluator |
|
||||||
|
| 인프라 | 이랑이 | Infra Manager |
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
DATABASE_URL="mysql://hanarang:PASSWORD@10.10.10.146:33006/hanarang_dashboard"
|
DATABASE_URL="mysql://hanarang:PASSWORD@10.10.10.146:33006/hanarang_dashboard"
|
||||||
JWT_SECRET="change-this-to-a-secure-random-string-in-production"
|
|
||||||
SSH_KEY_PATH="/home/narang/.ssh/id_rsa"
|
SSH_KEY_PATH="/home/narang/.ssh/id_rsa"
|
||||||
BACKEND_PORT=3005
|
BACKEND_PORT=3005
|
||||||
|
|||||||
20
backend/package-lock.json
generated
20
backend/package-lock.json
generated
@@ -12,7 +12,6 @@
|
|||||||
"@nestjs/common": "^11.0.1",
|
"@nestjs/common": "^11.0.1",
|
||||||
"@nestjs/config": "^4.0.3",
|
"@nestjs/config": "^4.0.3",
|
||||||
"@nestjs/core": "^11.0.1",
|
"@nestjs/core": "^11.0.1",
|
||||||
"@nestjs/event-emitter": "^3.0.1",
|
|
||||||
"@nestjs/jwt": "^11.0.2",
|
"@nestjs/jwt": "^11.0.2",
|
||||||
"@nestjs/passport": "^11.0.5",
|
"@nestjs/passport": "^11.0.5",
|
||||||
"@nestjs/platform-express": "^11.0.1",
|
"@nestjs/platform-express": "^11.0.1",
|
||||||
@@ -2295,19 +2294,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nestjs/event-emitter": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@nestjs/event-emitter/-/event-emitter-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-0Ln/x+7xkU6AJFOcQI9tIhUMXVF7D5itiaQGOyJbXtlAfAIt8gzDdJm+Im7cFzKoWkiW5nCXCPh6GSvdQd/3Dw==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"eventemitter2": "6.4.9"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
||||||
"@nestjs/core": "^10.0.0 || ^11.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@nestjs/jwt": {
|
"node_modules/@nestjs/jwt": {
|
||||||
"version": "11.0.2",
|
"version": "11.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@nestjs/jwt/-/jwt-11.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@nestjs/jwt/-/jwt-11.0.2.tgz",
|
||||||
@@ -6218,12 +6204,6 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eventemitter2": {
|
|
||||||
"version": "6.4.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz",
|
|
||||||
"integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/events": {
|
"node_modules/events": {
|
||||||
"version": "3.3.0",
|
"version": "3.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
||||||
|
|||||||
@@ -6,9 +6,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prisma:generate": "prisma generate",
|
|
||||||
"prebuild": "npm run prisma:generate",
|
|
||||||
"pretest": "npm run prisma:generate",
|
|
||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
"start": "nest start",
|
"start": "nest start",
|
||||||
@@ -27,7 +24,6 @@
|
|||||||
"@nestjs/common": "^11.0.1",
|
"@nestjs/common": "^11.0.1",
|
||||||
"@nestjs/config": "^4.0.3",
|
"@nestjs/config": "^4.0.3",
|
||||||
"@nestjs/core": "^11.0.1",
|
"@nestjs/core": "^11.0.1",
|
||||||
"@nestjs/event-emitter": "^3.0.1",
|
|
||||||
"@nestjs/jwt": "^11.0.2",
|
"@nestjs/jwt": "^11.0.2",
|
||||||
"@nestjs/passport": "^11.0.5",
|
"@nestjs/passport": "^11.0.5",
|
||||||
"@nestjs/platform-express": "^11.0.1",
|
"@nestjs/platform-express": "^11.0.1",
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ export class ActivityController {
|
|||||||
constructor(private readonly activityService: ActivityService) {}
|
constructor(private readonly activityService: ActivityService) {}
|
||||||
|
|
||||||
@Get('activity')
|
@Get('activity')
|
||||||
getFeed(@Query('limit') limit?: string, @Query('offset') offset?: string) {
|
getFeed(
|
||||||
|
@Query('limit') limit?: string,
|
||||||
|
@Query('offset') offset?: string,
|
||||||
|
) {
|
||||||
return this.activityService.getFeed(
|
return this.activityService.getFeed(
|
||||||
limit ? parseInt(limit, 10) : 50,
|
limit ? parseInt(limit, 10) : 50,
|
||||||
offset ? parseInt(offset, 10) : 0,
|
offset ? parseInt(offset, 10) : 0,
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
|||||||
import { ActivityController } from './activity.controller';
|
import { ActivityController } from './activity.controller';
|
||||||
import { ActivityService } from './activity.service';
|
import { ActivityService } from './activity.service';
|
||||||
import { PrismaModule } from '../prisma/prisma.module';
|
import { PrismaModule } from '../prisma/prisma.module';
|
||||||
|
import { EventsModule } from '../events/events.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [PrismaModule],
|
imports: [PrismaModule, EventsModule],
|
||||||
controllers: [ActivityController],
|
controllers: [ActivityController],
|
||||||
providers: [ActivityService],
|
providers: [ActivityService],
|
||||||
exports: [ActivityService],
|
exports: [ActivityService],
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
||||||
import { ActivityService } from './activity.service';
|
import { ActivityService } from './activity.service';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
@@ -8,9 +7,7 @@ describe('ActivityService', () => {
|
|||||||
|
|
||||||
const mockPrisma = {
|
const mockPrisma = {
|
||||||
activityLog: {
|
activityLog: {
|
||||||
create: jest
|
create: jest.fn().mockResolvedValue({ id: 1, action: 'test', createdAt: new Date() }),
|
||||||
.fn()
|
|
||||||
.mockResolvedValue({ id: 1, action: 'test', createdAt: new Date() }),
|
|
||||||
findMany: jest.fn().mockResolvedValue([]),
|
findMany: jest.fn().mockResolvedValue([]),
|
||||||
count: jest.fn().mockResolvedValue(0),
|
count: jest.fn().mockResolvedValue(0),
|
||||||
},
|
},
|
||||||
@@ -21,7 +18,6 @@ describe('ActivityService', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
ActivityService,
|
ActivityService,
|
||||||
{ provide: PrismaService, useValue: mockPrisma },
|
{ provide: PrismaService, useValue: mockPrisma },
|
||||||
EventEmitter2,
|
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable, Optional } from '@nestjs/common';
|
||||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { EventsGateway } from '../events/events.gateway';
|
||||||
|
|
||||||
export interface LogActivityDto {
|
export interface LogActivityDto {
|
||||||
sisterId?: number;
|
sisterId?: number;
|
||||||
@@ -15,11 +15,7 @@ function sanitizeActivityDetail(detail?: string | null): string | undefined {
|
|||||||
const raw = detail.trim();
|
const raw = detail.trim();
|
||||||
|
|
||||||
// 내부 stderr/명령문 직접 노출 금지
|
// 내부 stderr/명령문 직접 노출 금지
|
||||||
if (
|
if (/stderr:/i.test(raw) || /command not found/i.test(raw) || /bash:\s*line/i.test(raw)) {
|
||||||
/stderr:/i.test(raw) ||
|
|
||||||
/command not found/i.test(raw) ||
|
|
||||||
/bash:\s*line/i.test(raw)
|
|
||||||
) {
|
|
||||||
return '내부 작업 중 오류가 발생했어. 자세한 시스템 로그는 관리자 로그에서 확인할 수 있어.';
|
return '내부 작업 중 오류가 발생했어. 자세한 시스템 로그는 관리자 로그에서 확인할 수 있어.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +30,7 @@ function sanitizeActivityDetail(detail?: string | null): string | undefined {
|
|||||||
export class ActivityService {
|
export class ActivityService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly eventEmitter: EventEmitter2,
|
@Optional() private readonly events?: EventsGateway,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async log(dto: LogActivityDto) {
|
async log(dto: LogActivityDto) {
|
||||||
@@ -49,7 +45,9 @@ export class ActivityService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.eventEmitter.emit('activity.logged', record);
|
if (this.events) {
|
||||||
|
this.events.broadcastActivity(record);
|
||||||
|
}
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
@@ -68,10 +66,7 @@ export class ActivityService {
|
|||||||
this.prisma.activityLog.count(),
|
this.prisma.activityLog.count(),
|
||||||
]);
|
]);
|
||||||
return {
|
return {
|
||||||
items: items.map((item) => ({
|
items: items.map((item) => ({ ...item, detail: sanitizeActivityDetail(item.detail) })),
|
||||||
...item,
|
|
||||||
detail: sanitizeActivityDetail(item.detail),
|
|
||||||
})),
|
|
||||||
total,
|
total,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
@@ -92,10 +87,7 @@ export class ActivityService {
|
|||||||
this.prisma.activityLog.count({ where: { projectId } }),
|
this.prisma.activityLog.count({ where: { projectId } }),
|
||||||
]);
|
]);
|
||||||
return {
|
return {
|
||||||
items: items.map((item) => ({
|
items: items.map((item) => ({ ...item, detail: sanitizeActivityDetail(item.detail) })),
|
||||||
...item,
|
|
||||||
detail: sanitizeActivityDetail(item.detail),
|
|
||||||
})),
|
|
||||||
total,
|
total,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
|
|||||||
@@ -10,16 +10,9 @@ describe('AdminService', () => {
|
|||||||
let service: AdminService;
|
let service: AdminService;
|
||||||
|
|
||||||
const mockSister = {
|
const mockSister = {
|
||||||
id: 2,
|
id: 2, name: 'narang', ip: '10.10.10.216', user: 'narang',
|
||||||
name: 'narang',
|
lxcId: 105, status: 'online', lastSeen: new Date(),
|
||||||
ip: '10.10.10.216',
|
sshKeyPath: null, createdAt: new Date(), updatedAt: new Date(),
|
||||||
user: 'narang',
|
|
||||||
lxcId: 105,
|
|
||||||
status: 'online',
|
|
||||||
lastSeen: new Date(),
|
|
||||||
sshKeyPath: null,
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockPrisma = {
|
const mockPrisma = {
|
||||||
@@ -37,9 +30,7 @@ describe('AdminService', () => {
|
|||||||
{ provide: ActivityService, useValue: mockActivity },
|
{ provide: ActivityService, useValue: mockActivity },
|
||||||
{
|
{
|
||||||
provide: ConfigService,
|
provide: ConfigService,
|
||||||
useValue: {
|
useValue: { get: jest.fn().mockReturnValue('/home/narang/.ssh/id_rsa') },
|
||||||
get: jest.fn().mockReturnValue('/home/narang/.ssh/id_rsa'),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
@@ -50,11 +41,7 @@ describe('AdminService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('restartSister: SSH 성공 시 success=true', async () => {
|
it('restartSister: SSH 성공 시 success=true', async () => {
|
||||||
mockSsh.executeCommand.mockResolvedValue({
|
mockSsh.executeCommand.mockResolvedValue({ stdout: 'RESTART_OK', stderr: '', code: 0 });
|
||||||
stdout: 'RESTART_OK',
|
|
||||||
stderr: '',
|
|
||||||
code: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await service.restartSister('narang');
|
const result = await service.restartSister('narang');
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,7 @@ import { SshService } from '../sisters/ssh.service';
|
|||||||
import { ActivityService } from '../activity/activity.service';
|
import { ActivityService } from '../activity/activity.service';
|
||||||
import { SisterName } from '../common/sister-name.pipe';
|
import { SisterName } from '../common/sister-name.pipe';
|
||||||
|
|
||||||
const ALLOWED_HARNESS_FILES = [
|
const ALLOWED_HARNESS_FILES = ['AGENTS.md', 'SOUL.md', 'PROTOCOL.md', 'TOOLS.md', 'HEARTBEAT.md'] as const;
|
||||||
'AGENTS.md',
|
|
||||||
'SOUL.md',
|
|
||||||
'PROTOCOL.md',
|
|
||||||
'TOOLS.md',
|
|
||||||
'HEARTBEAT.md',
|
|
||||||
] as const;
|
|
||||||
type HarnessFile = (typeof ALLOWED_HARNESS_FILES)[number];
|
type HarnessFile = (typeof ALLOWED_HARNESS_FILES)[number];
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -34,7 +28,7 @@ export class AdminService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
keyPath,
|
keyPath,
|
||||||
'if command -v hermes >/dev/null 2>&1; then hermes gateway restart && echo "RESTART_OK"; elif systemctl --user restart hermes-agent >/dev/null 2>&1; then echo "RESTART_OK"; elif command -v openclaw >/dev/null 2>&1; then openclaw gateway restart && echo "RESTART_OK"; elif systemctl --user restart openclaw-gateway >/dev/null 2>&1; then echo "RESTART_OK"; fi',
|
'openclaw gateway restart && echo "RESTART_OK"',
|
||||||
);
|
);
|
||||||
|
|
||||||
const success = result.stdout.includes('RESTART_OK');
|
const success = result.stdout.includes('RESTART_OK');
|
||||||
@@ -42,9 +36,7 @@ export class AdminService {
|
|||||||
await this.activity.log({
|
await this.activity.log({
|
||||||
sisterId: sister.id,
|
sisterId: sister.id,
|
||||||
action: 'gateway_restart',
|
action: 'gateway_restart',
|
||||||
detail: success
|
detail: success ? 'Gateway restart successful' : `stderr: ${result.stderr}`,
|
||||||
? 'Gateway restart successful'
|
|
||||||
: `stderr: ${result.stderr}`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { success, output: result.stdout, error: result.stderr || null };
|
return { success, output: result.stdout, error: result.stderr || null };
|
||||||
@@ -68,7 +60,7 @@ export class AdminService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
keyPath,
|
keyPath,
|
||||||
'SESSION_MAIN=~/.hermes/sessions/main.json; [ -f "$SESSION_MAIN" ] || SESSION_MAIN=~/.openclaw/sessions/main.json; rm -f "$SESSION_MAIN" && echo "RESET_OK"',
|
'rm -f ~/.openclaw/sessions/main.json && echo "RESET_OK"',
|
||||||
);
|
);
|
||||||
|
|
||||||
const success = result.stdout.includes('RESET_OK');
|
const success = result.stdout.includes('RESET_OK');
|
||||||
@@ -76,9 +68,7 @@ export class AdminService {
|
|||||||
await this.activity.log({
|
await this.activity.log({
|
||||||
sisterId: sister.id,
|
sisterId: sister.id,
|
||||||
action: 'session_reset',
|
action: 'session_reset',
|
||||||
detail: success
|
detail: success ? 'Session reset successful' : `stderr: ${result.stderr}`,
|
||||||
? 'Session reset successful'
|
|
||||||
: `stderr: ${result.stderr}`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { success, output: result.stdout, error: result.stderr || null };
|
return { success, output: result.stdout, error: result.stderr || null };
|
||||||
@@ -98,7 +88,7 @@ export class AdminService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
keyPath,
|
keyPath,
|
||||||
`WORKSPACE=~/.hermes/workspace; [ -d "$WORKSPACE" ] || WORKSPACE=~/.openclaw/workspace; cat "$WORKSPACE"/${file} 2>/dev/null || echo ""`,
|
`cat ~/.openclaw/workspace/${file} 2>/dev/null || echo ""`,
|
||||||
);
|
);
|
||||||
return { name, file, content: result.stdout };
|
return { name, file, content: result.stdout };
|
||||||
} catch {
|
} catch {
|
||||||
@@ -112,7 +102,7 @@ export class AdminService {
|
|||||||
const keyPath = this.getKeyPath();
|
const keyPath = this.getKeyPath();
|
||||||
|
|
||||||
// 내용에서 위험한 셸 escape + null byte 방지
|
// 내용에서 위험한 셸 escape + null byte 방지
|
||||||
const escaped = content.split('\0').join('').replace(/'/g, "'\\''");
|
const escaped = content.replace(/\x00/g, '').replace(/'/g, "'\\''");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await this.ssh.executeCommand(
|
const result = await this.ssh.executeCommand(
|
||||||
@@ -120,7 +110,7 @@ export class AdminService {
|
|||||||
sister.user,
|
sister.user,
|
||||||
keyPath,
|
keyPath,
|
||||||
[
|
[
|
||||||
`WORKSPACE=~/.hermes/workspace; [ -d "$WORKSPACE" ] || WORKSPACE=~/.openclaw/workspace; cd "$WORKSPACE"`,
|
`cd ~/.openclaw/workspace`,
|
||||||
`printf '%s' '${escaped}' > ${file}`,
|
`printf '%s' '${escaped}' > ${file}`,
|
||||||
`git add ${file} && git commit -m "admin: update ${file}" --allow-empty 2>&1`,
|
`git add ${file} && git commit -m "admin: update ${file}" --allow-empty 2>&1`,
|
||||||
`echo "WRITE_OK"`,
|
`echo "WRITE_OK"`,
|
||||||
@@ -151,7 +141,7 @@ export class AdminService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
keyPath,
|
keyPath,
|
||||||
`journalctl --user -u hermes-agent --no-pager -n ${lines} 2>/dev/null || journalctl --user -u hermes-gateway --no-pager -n ${lines} 2>/dev/null || journalctl --user -u openclaw-gateway --no-pager -n ${lines} 2>/dev/null || tail -n ${lines} ~/.hermes/logs/gateway.log 2>/dev/null || tail -n ${lines} ~/.openclaw/logs/gateway.log 2>/dev/null || echo "(로그 없음)"`,
|
`journalctl --user -u openclaw-gateway --no-pager -n ${lines} 2>/dev/null || tail -n ${lines} ~/.openclaw/logs/gateway.log 2>/dev/null || echo "(로그 없음)"`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
@@ -172,9 +162,7 @@ export class AdminService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getSister(name: SisterName) {
|
private async getSister(name: SisterName) {
|
||||||
const sister = await this.prisma.sisterConfig.findUnique({
|
const sister = await this.prisma.sisterConfig.findUnique({ where: { name } });
|
||||||
where: { name },
|
|
||||||
});
|
|
||||||
if (!sister) throw new Error(`Sister ${name} not found`);
|
if (!sister) throw new Error(`Sister ${name} not found`);
|
||||||
return sister;
|
return sister;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
|
||||||
import { ThrottlerModule } from '@nestjs/throttler';
|
import { ThrottlerModule } from '@nestjs/throttler';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
@@ -18,12 +17,10 @@ import { EventsModule } from './events/events.module';
|
|||||||
import { CostsModule } from './costs/costs.module';
|
import { CostsModule } from './costs/costs.module';
|
||||||
import { GiteaSyncModule } from './gitea-sync/gitea-sync.module';
|
import { GiteaSyncModule } from './gitea-sync/gitea-sync.module';
|
||||||
import { SettingsModule } from './settings/settings.module';
|
import { SettingsModule } from './settings/settings.module';
|
||||||
import { DashboardModule } from './dashboard/dashboard.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({ isGlobal: true }),
|
ConfigModule.forRoot({ isGlobal: true }),
|
||||||
EventEmitterModule.forRoot(),
|
|
||||||
ThrottlerModule.forRoot([{ ttl: 60000, limit: 100 }]),
|
ThrottlerModule.forRoot([{ ttl: 60000, limit: 100 }]),
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
SistersModule,
|
SistersModule,
|
||||||
@@ -39,7 +36,6 @@ import { DashboardModule } from './dashboard/dashboard.module';
|
|||||||
CostsModule,
|
CostsModule,
|
||||||
GiteaSyncModule,
|
GiteaSyncModule,
|
||||||
SettingsModule,
|
SettingsModule,
|
||||||
DashboardModule,
|
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
import { randomBytes, timingSafeEqual } from 'crypto';
|
|
||||||
import type { CookieOptions, Request, Response } from 'express';
|
|
||||||
|
|
||||||
export const ACCESS_TOKEN_COOKIE = 'hanarang_access_token';
|
|
||||||
export const REFRESH_TOKEN_COOKIE = 'hanarang_refresh_token';
|
|
||||||
export const CSRF_TOKEN_COOKIE = 'hanarang_csrf_token';
|
|
||||||
|
|
||||||
const ACCESS_TOKEN_MAX_AGE_MS = 15 * 60 * 1000;
|
|
||||||
const REFRESH_TOKEN_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
||||||
|
|
||||||
function isHttpsRequest(req?: Request): boolean {
|
|
||||||
const forwardedProto = req?.headers['x-forwarded-proto'];
|
|
||||||
const protocol = Array.isArray(forwardedProto)
|
|
||||||
? forwardedProto[0]
|
|
||||||
: forwardedProto;
|
|
||||||
|
|
||||||
return (
|
|
||||||
process.env.NODE_ENV === 'production' ||
|
|
||||||
req?.secure === true ||
|
|
||||||
protocol === 'https'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function baseCookieOptions(req?: Request): CookieOptions {
|
|
||||||
return {
|
|
||||||
path: '/',
|
|
||||||
secure: isHttpsRequest(req),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parseCookieHeader(
|
|
||||||
header?: string | string[],
|
|
||||||
): Record<string, string> {
|
|
||||||
const raw = Array.isArray(header) ? header.join(';') : header;
|
|
||||||
if (!raw) return {};
|
|
||||||
|
|
||||||
return raw
|
|
||||||
.split(';')
|
|
||||||
.map((part) => part.trim())
|
|
||||||
.filter((part) => part.length > 0)
|
|
||||||
.reduce<Record<string, string>>((cookies, part) => {
|
|
||||||
const eqIndex = part.indexOf('=');
|
|
||||||
if (eqIndex === -1) return cookies;
|
|
||||||
|
|
||||||
const key = decodeURIComponent(part.slice(0, eqIndex).trim());
|
|
||||||
const value = decodeURIComponent(part.slice(eqIndex + 1).trim());
|
|
||||||
cookies[key] = value;
|
|
||||||
return cookies;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCookieValue(
|
|
||||||
req: Pick<Request, 'headers'>,
|
|
||||||
name: string,
|
|
||||||
): string | undefined {
|
|
||||||
return parseCookieHeader(req.headers.cookie)[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateCsrfToken(): string {
|
|
||||||
return randomBytes(32).toString('hex');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hasValidCsrfToken(req: Request): boolean {
|
|
||||||
const cookieToken = getCookieValue(req, CSRF_TOKEN_COOKIE);
|
|
||||||
const headerToken = req.headers['x-csrf-token'];
|
|
||||||
const requestToken = Array.isArray(headerToken) ? headerToken[0] : headerToken;
|
|
||||||
|
|
||||||
if (!cookieToken || !requestToken) return false;
|
|
||||||
|
|
||||||
const cookieBuffer = Buffer.from(cookieToken);
|
|
||||||
const requestBuffer = Buffer.from(requestToken);
|
|
||||||
|
|
||||||
if (cookieBuffer.length !== requestBuffer.length) return false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return timingSafeEqual(cookieBuffer, requestBuffer);
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setAuthCookies(
|
|
||||||
res: Response,
|
|
||||||
req: Request,
|
|
||||||
tokens: { accessToken: string; refreshToken: string },
|
|
||||||
csrfToken = generateCsrfToken(),
|
|
||||||
) {
|
|
||||||
res.cookie(ACCESS_TOKEN_COOKIE, tokens.accessToken, {
|
|
||||||
...baseCookieOptions(req),
|
|
||||||
httpOnly: true,
|
|
||||||
sameSite: 'lax',
|
|
||||||
maxAge: ACCESS_TOKEN_MAX_AGE_MS,
|
|
||||||
});
|
|
||||||
|
|
||||||
res.cookie(REFRESH_TOKEN_COOKIE, tokens.refreshToken, {
|
|
||||||
...baseCookieOptions(req),
|
|
||||||
httpOnly: true,
|
|
||||||
sameSite: 'strict',
|
|
||||||
maxAge: REFRESH_TOKEN_MAX_AGE_MS,
|
|
||||||
});
|
|
||||||
|
|
||||||
res.cookie(CSRF_TOKEN_COOKIE, csrfToken, {
|
|
||||||
...baseCookieOptions(req),
|
|
||||||
httpOnly: false,
|
|
||||||
sameSite: 'strict',
|
|
||||||
maxAge: REFRESH_TOKEN_MAX_AGE_MS,
|
|
||||||
});
|
|
||||||
|
|
||||||
return csrfToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function clearAuthCookies(res: Response, req?: Request) {
|
|
||||||
res.clearCookie(ACCESS_TOKEN_COOKIE, {
|
|
||||||
...baseCookieOptions(req),
|
|
||||||
httpOnly: true,
|
|
||||||
sameSite: 'lax',
|
|
||||||
});
|
|
||||||
res.clearCookie(REFRESH_TOKEN_COOKIE, {
|
|
||||||
...baseCookieOptions(req),
|
|
||||||
httpOnly: true,
|
|
||||||
sameSite: 'strict',
|
|
||||||
});
|
|
||||||
res.clearCookie(CSRF_TOKEN_COOKIE, {
|
|
||||||
...baseCookieOptions(req),
|
|
||||||
httpOnly: false,
|
|
||||||
sameSite: 'strict',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,96 +1,37 @@
|
|||||||
import {
|
import {
|
||||||
BadRequestException,
|
|
||||||
Body,
|
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
|
||||||
HttpCode,
|
|
||||||
Post,
|
Post,
|
||||||
Req,
|
Get,
|
||||||
Res,
|
Body,
|
||||||
UnauthorizedException,
|
Headers,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
Request,
|
Request,
|
||||||
|
BadRequestException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import type {
|
|
||||||
Request as ExpressRequest,
|
|
||||||
Response as ExpressResponse,
|
|
||||||
} from 'express';
|
|
||||||
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
|
|
||||||
import { AuthService, LoginDto } from './auth.service';
|
import { AuthService, LoginDto } from './auth.service';
|
||||||
import {
|
|
||||||
getCookieValue,
|
|
||||||
hasValidCsrfToken,
|
|
||||||
setAuthCookies,
|
|
||||||
clearAuthCookies,
|
|
||||||
REFRESH_TOKEN_COOKIE,
|
|
||||||
} from './auth-cookies';
|
|
||||||
import { JwtGuard } from './jwt.guard';
|
import { JwtGuard } from './jwt.guard';
|
||||||
|
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
|
||||||
interface AuthenticatedRequest extends ExpressRequest {
|
|
||||||
user: { userId: number };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Controller('api/auth')
|
@Controller('api/auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
constructor(private readonly authService: AuthService) {}
|
constructor(private readonly authService: AuthService) {}
|
||||||
|
|
||||||
@HttpCode(200)
|
|
||||||
@UseGuards(ThrottlerGuard)
|
@UseGuards(ThrottlerGuard)
|
||||||
@Throttle({ default: { limit: 5, ttl: 60000 } })
|
@Throttle({ default: { limit: 5, ttl: 60000 } })
|
||||||
@Post('login')
|
@Post('login')
|
||||||
async login(
|
login(@Body() dto: LoginDto) {
|
||||||
@Body() dto: LoginDto,
|
return this.authService.login(dto);
|
||||||
@Req() req: ExpressRequest,
|
|
||||||
@Res({ passthrough: true }) res: ExpressResponse,
|
|
||||||
) {
|
|
||||||
const tokens = await this.authService.login(dto);
|
|
||||||
setAuthCookies(res, req, tokens);
|
|
||||||
|
|
||||||
return {
|
|
||||||
username: tokens.username,
|
|
||||||
role: tokens.role,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HttpCode(200)
|
|
||||||
@UseGuards(ThrottlerGuard)
|
|
||||||
@Throttle({ default: { limit: 3, ttl: 60000 } })
|
|
||||||
@Post('refresh')
|
@Post('refresh')
|
||||||
async refresh(
|
refresh(@Headers('x-refresh-token') token: string) {
|
||||||
@Req() req: ExpressRequest,
|
|
||||||
@Res({ passthrough: true }) res: ExpressResponse,
|
|
||||||
) {
|
|
||||||
const cookieToken = getCookieValue(req, REFRESH_TOKEN_COOKIE);
|
|
||||||
const headerToken = req.headers['x-refresh-token'];
|
|
||||||
const token = cookieToken ?? (Array.isArray(headerToken) ? headerToken[0] : headerToken);
|
|
||||||
|
|
||||||
if (!token) throw new BadRequestException('Refresh token required');
|
if (!token) throw new BadRequestException('Refresh token required');
|
||||||
if (cookieToken && !hasValidCsrfToken(req)) {
|
return this.authService.refresh(token);
|
||||||
throw new UnauthorizedException('Invalid CSRF token');
|
|
||||||
}
|
|
||||||
|
|
||||||
const tokens = await this.authService.refresh(token);
|
|
||||||
setAuthCookies(res, req, tokens);
|
|
||||||
|
|
||||||
return {
|
|
||||||
username: tokens.username,
|
|
||||||
role: tokens.role,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@HttpCode(200)
|
|
||||||
@Post('logout')
|
|
||||||
logout(
|
|
||||||
@Req() req: ExpressRequest,
|
|
||||||
@Res({ passthrough: true }) res: ExpressResponse,
|
|
||||||
) {
|
|
||||||
clearAuthCookies(res, req);
|
|
||||||
return { ok: true };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtGuard)
|
@UseGuards(JwtGuard)
|
||||||
@Get('me')
|
@Get('me')
|
||||||
getMe(@Request() req: AuthenticatedRequest) {
|
getMe(@Request() req: any) {
|
||||||
return this.authService.getMe(req.user.userId);
|
return this.authService.getMe(req.user.userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import * as bcrypt from 'bcrypt';
|
|||||||
import { IsString, IsNotEmpty } from 'class-validator';
|
import { IsString, IsNotEmpty } from 'class-validator';
|
||||||
|
|
||||||
export class LoginDto {
|
export class LoginDto {
|
||||||
@IsString()
|
@IsString() @IsNotEmpty()
|
||||||
@IsNotEmpty()
|
|
||||||
username!: string;
|
username!: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString() @IsNotEmpty()
|
||||||
@IsNotEmpty()
|
|
||||||
password!: string;
|
password!: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +22,7 @@ export class AuthService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async login(dto: LoginDto) {
|
async login(dto: LoginDto) {
|
||||||
const user = await this.prisma.user.findUnique({
|
const user = await this.prisma.user.findUnique({ where: { username: dto.username } });
|
||||||
where: { username: dto.username },
|
|
||||||
});
|
|
||||||
if (!user) throw new UnauthorizedException('Invalid credentials');
|
if (!user) throw new UnauthorizedException('Invalid credentials');
|
||||||
|
|
||||||
const ok = await bcrypt.compare(dto.password, user.password);
|
const ok = await bcrypt.compare(dto.password, user.password);
|
||||||
@@ -37,16 +33,11 @@ export class AuthService {
|
|||||||
|
|
||||||
async refresh(refreshToken: string) {
|
async refresh(refreshToken: string) {
|
||||||
try {
|
try {
|
||||||
const payload = this.jwt.verify<{
|
const payload = this.jwt.verify<{ sub: number; username: string; role: string }>(
|
||||||
sub: number;
|
refreshToken,
|
||||||
username: string;
|
{ secret: this.config.get<string>('JWT_SECRET') + '_refresh' },
|
||||||
role: string;
|
);
|
||||||
}>(refreshToken, {
|
const user = await this.prisma.user.findUnique({ where: { id: payload.sub } });
|
||||||
secret: this.config.get<string>('JWT_SECRET') + '_refresh',
|
|
||||||
});
|
|
||||||
const user = await this.prisma.user.findUnique({
|
|
||||||
where: { id: payload.sub },
|
|
||||||
});
|
|
||||||
if (!user) throw new UnauthorizedException();
|
if (!user) throw new UnauthorizedException();
|
||||||
return this.signTokens(user.id, user.username, user.role);
|
return this.signTokens(user.id, user.username, user.role);
|
||||||
} catch {
|
} catch {
|
||||||
@@ -69,10 +60,7 @@ export class AuthService {
|
|||||||
const payload = { sub: userId, username, role };
|
const payload = { sub: userId, username, role };
|
||||||
|
|
||||||
const accessToken = this.jwt.sign(payload, { secret, expiresIn: '15m' });
|
const accessToken = this.jwt.sign(payload, { secret, expiresIn: '15m' });
|
||||||
const refreshToken = this.jwt.sign(payload, {
|
const refreshToken = this.jwt.sign(payload, { secret: secret + '_refresh', expiresIn: '7d' });
|
||||||
secret: secret + '_refresh',
|
|
||||||
expiresIn: '7d',
|
|
||||||
});
|
|
||||||
|
|
||||||
return { accessToken, refreshToken, username, role };
|
return { accessToken, refreshToken, username, role };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
import { PassportStrategy } from '@nestjs/passport';
|
import { PassportStrategy } from '@nestjs/passport';
|
||||||
import type { Request } from 'express';
|
|
||||||
import { ExtractJwt, Strategy } from 'passport-jwt';
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
||||||
import { ACCESS_TOKEN_COOKIE, getCookieValue } from './auth-cookies';
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
|
||||||
export interface JwtPayload {
|
export interface JwtPayload {
|
||||||
sub: number;
|
sub: number;
|
||||||
@@ -11,21 +9,13 @@ export interface JwtPayload {
|
|||||||
role: string;
|
role: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cookieTokenExtractor(req?: Request): string | null {
|
|
||||||
if (!req) return null;
|
|
||||||
return getCookieValue(req, ACCESS_TOKEN_COOKIE) ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||||
constructor(config: ConfigService) {
|
constructor(config: ConfigService) {
|
||||||
const secret = config.get<string>('JWT_SECRET');
|
const secret = config.get<string>('JWT_SECRET');
|
||||||
if (!secret) throw new Error('JWT_SECRET not set');
|
if (!secret) throw new Error('JWT_SECRET not set');
|
||||||
super({
|
super({
|
||||||
jwtFromRequest: ExtractJwt.fromExtractors([
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||||
cookieTokenExtractor,
|
|
||||||
ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
||||||
]),
|
|
||||||
ignoreExpiration: false,
|
ignoreExpiration: false,
|
||||||
secretOrKey: secret,
|
secretOrKey: secret,
|
||||||
});
|
});
|
||||||
@@ -33,10 +23,6 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
|||||||
|
|
||||||
validate(payload: JwtPayload) {
|
validate(payload: JwtPayload) {
|
||||||
if (!payload?.sub) throw new UnauthorizedException();
|
if (!payload?.sub) throw new UnauthorizedException();
|
||||||
return {
|
return { userId: payload.sub, username: payload.username, role: payload.role };
|
||||||
userId: payload.sub,
|
|
||||||
username: payload.username,
|
|
||||||
role: payload.role,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,28 @@
|
|||||||
import {
|
import { Injectable, CanActivate, ExecutionContext, ForbiddenException, SetMetadata } from '@nestjs/common';
|
||||||
Injectable,
|
|
||||||
CanActivate,
|
|
||||||
ExecutionContext,
|
|
||||||
ForbiddenException,
|
|
||||||
SetMetadata,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { Reflector } from '@nestjs/core';
|
import { Reflector } from '@nestjs/core';
|
||||||
import type { Request as ExpressRequest } from 'express';
|
|
||||||
|
|
||||||
export const ROLES_KEY = 'roles';
|
export const ROLES_KEY = 'roles';
|
||||||
export const Roles = (...roles: string[]) => SetMetadata(ROLES_KEY, roles);
|
export const Roles = (...roles: string[]) => SetMetadata(ROLES_KEY, roles);
|
||||||
|
|
||||||
interface RoleUser {
|
|
||||||
role: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RequestWithUser extends ExpressRequest {
|
|
||||||
user?: RoleUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RoleGuard implements CanActivate {
|
export class RoleGuard implements CanActivate {
|
||||||
constructor(private readonly reflector: Reflector) {}
|
constructor(private readonly reflector: Reflector) {}
|
||||||
|
|
||||||
canActivate(context: ExecutionContext): boolean {
|
canActivate(context: ExecutionContext): boolean {
|
||||||
const requiredRoles = this.reflector.getAllAndOverride<string[]>(
|
const requiredRoles = this.reflector.getAllAndOverride<string[]>(ROLES_KEY, [
|
||||||
ROLES_KEY,
|
context.getHandler(),
|
||||||
[context.getHandler(), context.getClass()],
|
context.getClass(),
|
||||||
);
|
]);
|
||||||
|
|
||||||
if (!requiredRoles || requiredRoles.length === 0) return true;
|
if (!requiredRoles || requiredRoles.length === 0) return true;
|
||||||
|
|
||||||
const request = context.switchToHttp().getRequest<RequestWithUser>();
|
const request = context.switchToHttp().getRequest();
|
||||||
const user = request.user;
|
const user = request.user;
|
||||||
|
|
||||||
if (!user) throw new ForbiddenException('Authentication required');
|
if (!user) throw new ForbiddenException('Authentication required');
|
||||||
|
|
||||||
const hasRole = requiredRoles.includes(user.role);
|
const hasRole = requiredRoles.includes(user.role);
|
||||||
if (!hasRole)
|
if (!hasRole) throw new ForbiddenException(`Role '${user.role}' not authorized. Required: ${requiredRoles.join(', ')}`);
|
||||||
throw new ForbiddenException(
|
|
||||||
`Role '${user.role}' not authorized. Required: ${requiredRoles.join(', ')}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ export class CostsController {
|
|||||||
@Get()
|
@Get()
|
||||||
getCosts(@Query('period') period?: string) {
|
getCosts(@Query('period') period?: string) {
|
||||||
const validPeriods: CostPeriod[] = ['day', 'week', 'month'];
|
const validPeriods: CostPeriod[] = ['day', 'week', 'month'];
|
||||||
const p = validPeriods.includes(period as CostPeriod)
|
const p = validPeriods.includes(period as CostPeriod) ? (period as CostPeriod) : 'week';
|
||||||
? (period as CostPeriod)
|
|
||||||
: 'week';
|
|
||||||
return this.costsService.getCosts(p);
|
return this.costsService.getCosts(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ const MODEL_PRICING: Record<string, { input: number; output: number }> = {
|
|||||||
default: { input: 3.0, output: 15.0 },
|
default: { input: 3.0, output: 15.0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SISTER_NAMES: SisterName[] = ['harang', 'narang', 'darang', 'erang'];
|
||||||
|
|
||||||
export type CostPeriod = 'day' | 'week' | 'month';
|
export type CostPeriod = 'day' | 'week' | 'month';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -36,23 +38,14 @@ export class CostsService {
|
|||||||
this.getTimeline(since, period),
|
this.getTimeline(since, period),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return { period, since: since.toISOString(), summary, bySister, byModel, timeline };
|
||||||
period,
|
|
||||||
since: since.toISOString(),
|
|
||||||
summary,
|
|
||||||
bySister,
|
|
||||||
byModel,
|
|
||||||
timeline,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async recordCosts(sisterName: SisterName) {
|
async recordCosts(sisterName: SisterName) {
|
||||||
const keyPath = this.config.get<string>('SSH_KEY_PATH');
|
const keyPath = this.config.get<string>('SSH_KEY_PATH');
|
||||||
if (!keyPath) return;
|
if (!keyPath) return;
|
||||||
|
|
||||||
const sister = await this.prisma.sisterConfig.findUnique({
|
const sister = await this.prisma.sisterConfig.findUnique({ where: { name: sisterName } });
|
||||||
where: { name: sisterName },
|
|
||||||
});
|
|
||||||
if (!sister) return;
|
if (!sister) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -61,15 +54,14 @@ export class CostsService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
keyPath,
|
keyPath,
|
||||||
`SESSION_FILE=~/.hermes/sessions/main.json; \
|
`SESSION_FILE=~/.openclaw/sessions/main.json; \
|
||||||
[ -f "$SESSION_FILE" ] || SESSION_FILE=~/.openclaw/sessions/main.json; \
|
|
||||||
if [ ! -f "$SESSION_FILE" ]; then echo "unknown 0 0"; \
|
if [ ! -f "$SESSION_FILE" ]; then echo "unknown 0 0"; \
|
||||||
elif command -v node >/dev/null 2>&1; then \
|
elif command -v node >/dev/null 2>&1; then \
|
||||||
SESSION_FILE="$SESSION_FILE" node -e "try{const d=require('fs').readFileSync(process.env.SESSION_FILE,'utf8');const j=JSON.parse(d);const u=j.usage||{};console.log((j.model||'unknown')+' '+(u.input_tokens||0)+' '+(u.output_tokens||0))}catch(e){console.log('unknown 0 0')}" 2>/dev/null; \
|
node -e "try{const d=require('fs').readFileSync(process.env.HOME+'/.openclaw/sessions/main.json','utf8');const j=JSON.parse(d);const u=j.usage||{};console.log((j.model||'unknown')+' '+(u.input_tokens||0)+' '+(u.output_tokens||0))}catch(e){console.log('unknown 0 0')}" 2>/dev/null; \
|
||||||
elif command -v python3 >/dev/null 2>&1; then \
|
elif command -v python3 >/dev/null 2>&1; then \
|
||||||
cat "$SESSION_FILE" | python3 -c "import json,sys;d=json.load(sys.stdin);u=d.get('usage',{});print(d.get('model','unknown'),u.get('input_tokens',0),u.get('output_tokens',0))" 2>/dev/null; \
|
cat $SESSION_FILE | python3 -c "import json,sys;d=json.load(sys.stdin);u=d.get('usage',{});print(d.get('model','unknown'),u.get('input_tokens',0),u.get('output_tokens',0))" 2>/dev/null; \
|
||||||
elif command -v jq >/dev/null 2>&1; then \
|
elif command -v jq >/dev/null 2>&1; then \
|
||||||
echo "$(jq -r '.model // "unknown"' "$SESSION_FILE") $(jq -r '.usage.input_tokens // 0' "$SESSION_FILE") $(jq -r '.usage.output_tokens // 0' "$SESSION_FILE")" 2>/dev/null; \
|
echo "$(jq -r '.model // "unknown"' $SESSION_FILE) $(jq -r '.usage.input_tokens // 0' $SESSION_FILE) $(jq -r '.usage.output_tokens // 0' $SESSION_FILE)" 2>/dev/null; \
|
||||||
else echo "unknown 0 0"; fi`,
|
else echo "unknown 0 0"; fi`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -106,12 +98,7 @@ export class CostsService {
|
|||||||
private async getSummary(since: Date) {
|
private async getSummary(since: Date) {
|
||||||
const result = await this.prisma.costLog.aggregate({
|
const result = await this.prisma.costLog.aggregate({
|
||||||
where: { recordedAt: { gte: since } },
|
where: { recordedAt: { gte: since } },
|
||||||
_sum: {
|
_sum: { inputTokens: true, outputTokens: true, totalTokens: true, estimatedUsd: true },
|
||||||
inputTokens: true,
|
|
||||||
outputTokens: true,
|
|
||||||
totalTokens: true,
|
|
||||||
estimatedUsd: true,
|
|
||||||
},
|
|
||||||
_count: true,
|
_count: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,23 +144,14 @@ export class CostsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getTimeline(since: Date, period: CostPeriod) {
|
private async getTimeline(since: Date, period: CostPeriod) {
|
||||||
void period;
|
|
||||||
const logs = await this.prisma.costLog.findMany({
|
const logs = await this.prisma.costLog.findMany({
|
||||||
where: { recordedAt: { gte: since } },
|
where: { recordedAt: { gte: since } },
|
||||||
orderBy: { recordedAt: 'asc' },
|
orderBy: { recordedAt: 'asc' },
|
||||||
select: {
|
select: { sisterName: true, totalTokens: true, estimatedUsd: true, recordedAt: true },
|
||||||
sisterName: true,
|
|
||||||
totalTokens: true,
|
|
||||||
estimatedUsd: true,
|
|
||||||
recordedAt: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 날짜별 집계
|
// 날짜별 집계
|
||||||
const grouped: Record<
|
const grouped: Record<string, { date: string; totalTokens: number; estimatedUsd: number }> = {};
|
||||||
string,
|
|
||||||
{ date: string; totalTokens: number; estimatedUsd: number }
|
|
||||||
> = {};
|
|
||||||
|
|
||||||
for (const log of logs) {
|
for (const log of logs) {
|
||||||
const dateKey = log.recordedAt.toISOString().slice(0, 10);
|
const dateKey = log.recordedAt.toISOString().slice(0, 10);
|
||||||
@@ -193,12 +171,9 @@ export class CostsService {
|
|||||||
private getSince(period: CostPeriod): Date {
|
private getSince(period: CostPeriod): Date {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
switch (period) {
|
switch (period) {
|
||||||
case 'day':
|
case 'day': return new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
||||||
return new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
case 'week': return new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
|
||||||
case 'week':
|
case 'month': return new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
||||||
return new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
|
|
||||||
case 'month':
|
|
||||||
return new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
|
||||||
import { DashboardService } from './dashboard.service';
|
|
||||||
|
|
||||||
@Controller('api/dashboard')
|
|
||||||
export class DashboardController {
|
|
||||||
constructor(private readonly dashboardService: DashboardService) {}
|
|
||||||
|
|
||||||
@Get('ops')
|
|
||||||
getOpsBoard(): Promise<any> {
|
|
||||||
return this.dashboardService.getOpsBoard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { DashboardController } from './dashboard.controller';
|
|
||||||
import { DashboardService } from './dashboard.service';
|
|
||||||
import { PrismaModule } from '../prisma/prisma.module';
|
|
||||||
import { ProjectsModule } from '../projects/projects.module';
|
|
||||||
import { GiteaModule } from '../gitea/gitea.module';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [PrismaModule, ProjectsModule, GiteaModule],
|
|
||||||
controllers: [DashboardController],
|
|
||||||
providers: [DashboardService],
|
|
||||||
exports: [DashboardService],
|
|
||||||
})
|
|
||||||
export class DashboardModule {}
|
|
||||||
@@ -1,335 +0,0 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
|
||||||
import { ProjectsService } from '../projects/projects.service';
|
|
||||||
import { GiteaService } from '../gitea/gitea.service';
|
|
||||||
|
|
||||||
interface ActivityRecord {
|
|
||||||
id: number;
|
|
||||||
action: string;
|
|
||||||
detail: string | null;
|
|
||||||
createdAt: Date;
|
|
||||||
sister: { name: string } | null;
|
|
||||||
project: { name: string } | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OpsBoardItem {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
body: string;
|
|
||||||
tone: 'default' | 'warn' | 'ok' | 'active';
|
|
||||||
author: string;
|
|
||||||
time: string;
|
|
||||||
category: string;
|
|
||||||
source: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FreshnessMeta {
|
|
||||||
generatedAt: string;
|
|
||||||
activityLatestAt: string | null;
|
|
||||||
sistersLatestAt: string | null;
|
|
||||||
qaDocLatestAt: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QA_PATH_CANDIDATES = ['.plans/qa/', '.qa/'];
|
|
||||||
const SISTER_ROLES: Record<string, string> = {
|
|
||||||
harang: 'Plan & Assign',
|
|
||||||
narang: 'Implement',
|
|
||||||
darang: 'Review / QA',
|
|
||||||
erang: 'Deploy / Infra',
|
|
||||||
};
|
|
||||||
|
|
||||||
function toneFromText(text: string): 'default' | 'warn' | 'ok' | 'active' {
|
|
||||||
const normalized = text.toLowerCase();
|
|
||||||
if (/(fail|error|blocker|offline|invalid|drift)/.test(normalized))
|
|
||||||
return 'warn';
|
|
||||||
if (/(passed|deploy|merged|restart_ok|write_ok|successful)/.test(normalized))
|
|
||||||
return 'ok';
|
|
||||||
if (/(review|qa|handoff|sync|update)/.test(normalized)) return 'active';
|
|
||||||
return 'default';
|
|
||||||
}
|
|
||||||
|
|
||||||
function nodeStateFromEvidence(params: {
|
|
||||||
sisterStatus?: string;
|
|
||||||
activity?: ActivityRecord | null;
|
|
||||||
name: string;
|
|
||||||
}): 'idle' | 'active' | 'review' | 'blocked' | 'ready' {
|
|
||||||
const { sisterStatus, activity, name } = params;
|
|
||||||
const text =
|
|
||||||
`${activity?.action ?? ''} ${activity?.detail ?? ''}`.toLowerCase();
|
|
||||||
|
|
||||||
if (name !== 'user' && sisterStatus === 'offline') return 'blocked';
|
|
||||||
if (/(review|qa)/.test(text)) return 'review';
|
|
||||||
if (
|
|
||||||
name === 'erang' &&
|
|
||||||
/(deploy|merged|ready for deploy|deployed)/.test(text)
|
|
||||||
)
|
|
||||||
return 'ready';
|
|
||||||
if (sisterStatus === 'working') return 'active';
|
|
||||||
if (activity) return 'ready';
|
|
||||||
return 'idle';
|
|
||||||
}
|
|
||||||
|
|
||||||
function sanitizeSummary(text?: string | null) {
|
|
||||||
const raw = text?.trim();
|
|
||||||
if (!raw) return null;
|
|
||||||
if (/stderr:/i.test(raw) || /command not found/i.test(raw) || /bash:\s*line/i.test(raw)) {
|
|
||||||
return '내부 작업 중 오류가 발생했어. 자세한 시스템 로그는 관리자 로그에서 확인해.';
|
|
||||||
}
|
|
||||||
if (/^ssh failed/i.test(raw) || /ssh connection failed/i.test(raw)) {
|
|
||||||
return '원격 노드 연결에 실패했어.';
|
|
||||||
}
|
|
||||||
return raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
function summarizeActivity(
|
|
||||||
activity?: ActivityRecord | null,
|
|
||||||
fallback = 'NO EVENT',
|
|
||||||
) {
|
|
||||||
return sanitizeSummary(activity?.detail) || activity?.action?.replace(/_/g, ' ') || fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseQaSummary(content: string): string {
|
|
||||||
const lines = content.split(/\r?\n/).map((line) => line.trim());
|
|
||||||
const taskLine = lines.find((line) => /^###\s+/.test(line));
|
|
||||||
if (taskLine) return taskLine.replace(/^###\s+/, '').trim();
|
|
||||||
const bullet = lines.find((line) => /^-\s+/.test(line));
|
|
||||||
if (bullet) return bullet.replace(/^-\s+/, '').trim();
|
|
||||||
return (
|
|
||||||
lines.find((line) => line.length > 0 && !line.startsWith('#')) ?? 'QA note'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function inferQaAuthor(path: string, content: string): string {
|
|
||||||
if (/darang/i.test(path) || /다랑/i.test(content)) return '다랑이';
|
|
||||||
if (/harang/i.test(path) || /하랑/i.test(content)) return '하랑이';
|
|
||||||
return 'QA Doc';
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractRepoName(repoUrl: string): string {
|
|
||||||
return repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DashboardService {
|
|
||||||
constructor(
|
|
||||||
private readonly prisma: PrismaService,
|
|
||||||
private readonly projectsService: ProjectsService,
|
|
||||||
private readonly gitea: GiteaService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async getOpsBoard() {
|
|
||||||
const [projects, sisters, rawActivities] = await Promise.all([
|
|
||||||
this.projectsService.getProjects(),
|
|
||||||
this.prisma.sisterConfig.findMany({ orderBy: { id: 'asc' } }),
|
|
||||||
this.prisma.activityLog.findMany({
|
|
||||||
orderBy: { createdAt: 'desc' },
|
|
||||||
take: 40,
|
|
||||||
include: {
|
|
||||||
sister: { select: { name: true } },
|
|
||||||
project: { select: { name: true } },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const activities = rawActivities as ActivityRecord[];
|
|
||||||
const latestProjectActivity =
|
|
||||||
activities.find((item) => item.project?.name) ?? null;
|
|
||||||
const latestBySister = new Map<string, ActivityRecord>();
|
|
||||||
for (const item of activities) {
|
|
||||||
if (item.sister?.name && !latestBySister.has(item.sister.name)) {
|
|
||||||
latestBySister.set(item.sister.name, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const focusProject = latestProjectActivity?.project?.name
|
|
||||||
? (projects.find(
|
|
||||||
(project) => project.name === latestProjectActivity.project?.name,
|
|
||||||
) ?? null)
|
|
||||||
: (projects.find((project) =>
|
|
||||||
['IMPLEMENT', 'QA', 'READY FOR DEPLOY'].includes(project.phase),
|
|
||||||
) ?? null);
|
|
||||||
|
|
||||||
const reviewLoopCount = activities.filter((item) =>
|
|
||||||
/(review|qa)/i.test(`${item.action} ${item.detail ?? ''}`),
|
|
||||||
).length;
|
|
||||||
const escalationCount = projects.filter(
|
|
||||||
(project) => (project.blockerCount ?? 0) > 0,
|
|
||||||
).length;
|
|
||||||
|
|
||||||
const nodes = [
|
|
||||||
{
|
|
||||||
id: 'user',
|
|
||||||
label: 'User',
|
|
||||||
role: 'Request / Approval',
|
|
||||||
state: nodeStateFromEvidence({
|
|
||||||
name: 'user',
|
|
||||||
activity: latestProjectActivity,
|
|
||||||
}),
|
|
||||||
detail: latestProjectActivity
|
|
||||||
? `${latestProjectActivity.project?.name ?? 'project'} · ${summarizeActivity(latestProjectActivity, 'NO EVENT')}`
|
|
||||||
: 'NO ACTIVE HANDOFF',
|
|
||||||
},
|
|
||||||
...sisters.map((sister) => {
|
|
||||||
const activity = latestBySister.get(sister.name) ?? null;
|
|
||||||
return {
|
|
||||||
id: sister.name,
|
|
||||||
label:
|
|
||||||
sister.name === 'erang'
|
|
||||||
? 'Irang'
|
|
||||||
: `${sister.name.slice(0, 1).toUpperCase()}${sister.name.slice(1)}`,
|
|
||||||
role: SISTER_ROLES[sister.name] ?? 'Unknown',
|
|
||||||
state: nodeStateFromEvidence({
|
|
||||||
name: sister.name,
|
|
||||||
sisterStatus: sister.status,
|
|
||||||
activity,
|
|
||||||
}),
|
|
||||||
detail: activity
|
|
||||||
? summarizeActivity(activity)
|
|
||||||
: sister.status === 'offline'
|
|
||||||
? 'RUNTIME OFFLINE'
|
|
||||||
: sister.lastSeen
|
|
||||||
? 'SNAPSHOT ONLY'
|
|
||||||
: 'NO EVENT',
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
const harnessItems = activities
|
|
||||||
.filter((item) => item.action === 'harness_updated')
|
|
||||||
.slice(0, 4)
|
|
||||||
.map(
|
|
||||||
(item) =>
|
|
||||||
({
|
|
||||||
id: `harness-${item.id}`,
|
|
||||||
title: item.detail ?? 'HARNESS UPDATED',
|
|
||||||
body: item.detail ?? 'HARNESS UPDATED',
|
|
||||||
tone: toneFromText(`${item.action} ${item.detail ?? ''}`),
|
|
||||||
author: item.sister?.name
|
|
||||||
? this.toDisplayName(item.sister.name)
|
|
||||||
: 'System',
|
|
||||||
time: item.createdAt.toISOString(),
|
|
||||||
category: 'harness',
|
|
||||||
source: `activity:${item.action}`,
|
|
||||||
}) satisfies OpsBoardItem,
|
|
||||||
);
|
|
||||||
|
|
||||||
const qaItems = await this.getLatestQaBoardItems(
|
|
||||||
projects.map((project) => ({
|
|
||||||
name: project.name,
|
|
||||||
repoName: extractRepoName(project.repoUrl),
|
|
||||||
updatedAt: project.updatedAt,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
|
|
||||||
const board = [...harnessItems, ...qaItems]
|
|
||||||
.sort((a, b) => new Date(b.time).getTime() - new Date(a.time).getTime())
|
|
||||||
.slice(0, 6);
|
|
||||||
|
|
||||||
const freshness: FreshnessMeta = {
|
|
||||||
generatedAt: new Date().toISOString(),
|
|
||||||
activityLatestAt: activities[0]?.createdAt?.toISOString() ?? null,
|
|
||||||
sistersLatestAt:
|
|
||||||
sisters
|
|
||||||
.map((sister) => sister.lastSeen)
|
|
||||||
.filter((value): value is Date => value instanceof Date)
|
|
||||||
.sort((a, b) => b.getTime() - a.getTime())[0]
|
|
||||||
?.toISOString() ?? null,
|
|
||||||
qaDocLatestAt:
|
|
||||||
board
|
|
||||||
.filter((item) => item.category === 'DOC-DERIVED')
|
|
||||||
.map((item) => item.time)
|
|
||||||
.sort((a, b) => new Date(b).getTime() - new Date(a).getTime())[0] ??
|
|
||||||
null,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
focusProject: focusProject
|
|
||||||
? {
|
|
||||||
name: focusProject.name,
|
|
||||||
ownerSister: focusProject.ownerSister ?? null,
|
|
||||||
phase: focusProject.phase,
|
|
||||||
currentSprint: focusProject.currentSprint ?? null,
|
|
||||||
progress: focusProject.progress ?? 0,
|
|
||||||
deployStatus: focusProject.deployStatus,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
pipeline: {
|
|
||||||
activeTask: focusProject
|
|
||||||
? `${focusProject.name} · ${focusProject.currentSprint ?? focusProject.phase}`
|
|
||||||
: 'NO ACTIVE PIPELINE',
|
|
||||||
focus: latestProjectActivity
|
|
||||||
? summarizeActivity(latestProjectActivity, 'NO EVENT')
|
|
||||||
: 'SNAPSHOT / NO ACTIVE HANDOFF',
|
|
||||||
reviewLoopCount,
|
|
||||||
escalationCount,
|
|
||||||
deployState: focusProject?.deployStatus ?? 'STANDBY',
|
|
||||||
nodes,
|
|
||||||
},
|
|
||||||
board,
|
|
||||||
freshness,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getLatestQaBoardItems(
|
|
||||||
projects: { name: string; repoName: string; updatedAt: string }[],
|
|
||||||
) {
|
|
||||||
const docs = await Promise.all(
|
|
||||||
projects.map(async (project) => {
|
|
||||||
if (!project.repoName) return [] as OpsBoardItem[];
|
|
||||||
|
|
||||||
const pathGroups = await Promise.all(
|
|
||||||
QA_PATH_CANDIDATES.map((path) =>
|
|
||||||
this.gitea.getRepoTree(project.repoName, path),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
const qaFiles = Array.from(
|
|
||||||
new Set(
|
|
||||||
pathGroups
|
|
||||||
.flat()
|
|
||||||
.filter((path) =>
|
|
||||||
/(?:SPRINT|HOTFIX)-\d+.*(?:review|qa).*\.md$/i.test(path),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
const latestPath = qaFiles.sort().at(-1);
|
|
||||||
if (!latestPath) return [] as OpsBoardItem[];
|
|
||||||
|
|
||||||
const content = await this.gitea.getRawFile(
|
|
||||||
project.repoName,
|
|
||||||
latestPath,
|
|
||||||
);
|
|
||||||
if (!content) return [] as OpsBoardItem[];
|
|
||||||
|
|
||||||
const summary = parseQaSummary(content);
|
|
||||||
const label =
|
|
||||||
latestPath.split('/').pop()?.replace(/\.md$/i, '') ?? latestPath;
|
|
||||||
const tone = toneFromText(content);
|
|
||||||
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: `qa-${project.repoName}-${label}`,
|
|
||||||
title: label,
|
|
||||||
body: summary,
|
|
||||||
tone,
|
|
||||||
author: inferQaAuthor(latestPath, content),
|
|
||||||
time: project.updatedAt,
|
|
||||||
category: 'DOC-DERIVED',
|
|
||||||
source: `${project.repoName}:${latestPath}`,
|
|
||||||
} satisfies OpsBoardItem,
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return docs.flat();
|
|
||||||
}
|
|
||||||
|
|
||||||
private toDisplayName(name: string) {
|
|
||||||
if (name === 'harang') return '하랑이';
|
|
||||||
if (name === 'narang') return '나랑이';
|
|
||||||
if (name === 'darang') return '다랑이';
|
|
||||||
if (name === 'erang') return '이랑이';
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,18 +10,6 @@ import { Server, Socket } from 'socket.io';
|
|||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { OnEvent } from '@nestjs/event-emitter';
|
|
||||||
import { ACCESS_TOKEN_COOKIE, parseCookieHeader } from '../auth/auth-cookies';
|
|
||||||
|
|
||||||
interface SocketUserPayload {
|
|
||||||
username?: string;
|
|
||||||
role?: string;
|
|
||||||
sub?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SocketWithUser extends Socket {
|
|
||||||
user?: SocketUserPayload;
|
|
||||||
}
|
|
||||||
|
|
||||||
@WebSocketGateway({
|
@WebSocketGateway({
|
||||||
cors: {
|
cors: {
|
||||||
@@ -49,19 +37,11 @@ export class EventsGateway
|
|||||||
this.logger.log('WebSocket Gateway initialized');
|
this.logger.log('WebSocket Gateway initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
handleConnection(client: SocketWithUser) {
|
handleConnection(client: Socket) {
|
||||||
// JWT 인증 필수 — 토큰 없거나 유효하지 않으면 disconnect
|
// JWT 인증 필수 — 토큰 없거나 유효하지 않으면 disconnect
|
||||||
const authHeader = client.handshake.headers.authorization;
|
|
||||||
const tokenFromHeader = Array.isArray(authHeader)
|
|
||||||
? authHeader[0]?.replace('Bearer ', '')
|
|
||||||
: authHeader?.replace('Bearer ', '');
|
|
||||||
const tokenFromCookie = parseCookieHeader(client.handshake.headers.cookie)[
|
|
||||||
ACCESS_TOKEN_COOKIE
|
|
||||||
];
|
|
||||||
const token =
|
const token =
|
||||||
(client.handshake.auth?.token as string | undefined) ??
|
(client.handshake.auth?.token as string) ??
|
||||||
tokenFromHeader ??
|
(client.handshake.headers.authorization as string)?.replace('Bearer ', '');
|
||||||
tokenFromCookie;
|
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
this.logger.debug(`WS rejected (no token): ${client.id}`);
|
this.logger.debug(`WS rejected (no token): ${client.id}`);
|
||||||
@@ -76,13 +56,9 @@ export class EventsGateway
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payload = this.jwtService.verify<SocketUserPayload>(token, {
|
const payload = this.jwtService.verify(token, { secret });
|
||||||
secret,
|
(client as any).user = payload;
|
||||||
});
|
this.logger.debug(`WS client connected: ${client.id} (${payload.username})`);
|
||||||
client.user = payload;
|
|
||||||
this.logger.debug(
|
|
||||||
`WS client connected: ${client.id} (${payload.username ?? 'unknown'})`,
|
|
||||||
);
|
|
||||||
} catch {
|
} catch {
|
||||||
this.logger.debug(`WS rejected (invalid token): ${client.id}`);
|
this.logger.debug(`WS rejected (invalid token): ${client.id}`);
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
@@ -108,12 +84,6 @@ export class EventsGateway
|
|||||||
this.server.emit('activity:new', { item, ts: Date.now() });
|
this.server.emit('activity:new', { item, ts: Date.now() });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** EventEmitter2에서 activity.logged 수신 → WebSocket 브로드캐스트 */
|
|
||||||
@OnEvent('activity.logged')
|
|
||||||
handleActivityLogged(record: unknown) {
|
|
||||||
this.broadcastActivity(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 연결된 클라이언트 수 */
|
/** 연결된 클라이언트 수 */
|
||||||
getClientCount(): number {
|
getClientCount(): number {
|
||||||
return this.server?.sockets?.sockets?.size ?? 0;
|
return this.server?.sockets?.sockets?.size ?? 0;
|
||||||
|
|||||||
@@ -13,11 +13,7 @@ import { SistersModule } from '../sisters/sisters.module';
|
|||||||
imports: [ConfigModule],
|
imports: [ConfigModule],
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
useFactory: (config: ConfigService) => ({
|
useFactory: (config: ConfigService) => ({
|
||||||
secret: (() => {
|
secret: (() => { const s = config.get<string>('JWT_SECRET'); if (!s) throw new Error('JWT_SECRET is not configured'); return s; })(),
|
||||||
const s = config.get<string>('JWT_SECRET');
|
|
||||||
if (!s) throw new Error('JWT_SECRET is not configured');
|
|
||||||
return s;
|
|
||||||
})(),
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { Injectable, Logger, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
||||||
Injectable,
|
|
||||||
Logger,
|
|
||||||
OnModuleInit,
|
|
||||||
OnModuleDestroy,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { SistersService } from '../sisters/sisters.service';
|
import { SistersService } from '../sisters/sisters.service';
|
||||||
import { EventsGateway } from './events.gateway';
|
import { EventsGateway } from './events.gateway';
|
||||||
|
|
||||||
@@ -11,10 +6,7 @@ import { EventsGateway } from './events.gateway';
|
|||||||
export class EventsScheduler implements OnModuleInit, OnModuleDestroy {
|
export class EventsScheduler implements OnModuleInit, OnModuleDestroy {
|
||||||
private readonly logger = new Logger(EventsScheduler.name);
|
private readonly logger = new Logger(EventsScheduler.name);
|
||||||
private timer: NodeJS.Timeout | null = null;
|
private timer: NodeJS.Timeout | null = null;
|
||||||
private readonly INTERVAL_MS = parseInt(
|
private readonly INTERVAL_MS = parseInt(process.env.WS_POLL_INTERVAL_MS ?? '30000', 10);
|
||||||
process.env.WS_POLL_INTERVAL_MS ?? '30000',
|
|
||||||
10,
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly sistersService: SistersService,
|
private readonly sistersService: SistersService,
|
||||||
@@ -22,12 +14,8 @@ export class EventsScheduler implements OnModuleInit, OnModuleDestroy {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
onModuleInit() {
|
onModuleInit() {
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => this.tick(), this.INTERVAL_MS);
|
||||||
void this.tick();
|
this.logger.log(`WebSocket scheduler started (interval: ${this.INTERVAL_MS}ms)`);
|
||||||
}, this.INTERVAL_MS);
|
|
||||||
this.logger.log(
|
|
||||||
`WebSocket scheduler started (interval: ${this.INTERVAL_MS}ms)`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onModuleDestroy() {
|
onModuleDestroy() {
|
||||||
|
|||||||
@@ -14,17 +14,13 @@ export class SistersScheduler {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (this.timer) return;
|
if (this.timer) return;
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(async () => {
|
||||||
void this.broadcast();
|
|
||||||
}, 30000);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async broadcast() {
|
|
||||||
try {
|
try {
|
||||||
const sisters = await this.sistersService.getAllSistersStatus();
|
const sisters = await this.sistersService.getAllSistersStatus();
|
||||||
this.eventsGateway.broadcastSisterStatus(sisters);
|
this.eventsGateway.broadcastSisterStatus(sisters);
|
||||||
} catch {
|
} catch {
|
||||||
this.logger.warn('Failed to broadcast sisters update');
|
this.logger.warn('Failed to broadcast sisters update');
|
||||||
}
|
}
|
||||||
|
}, 30000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,7 @@ import { AuthModule } from '../auth/auth.module';
|
|||||||
import { ProjectsModule } from '../projects/projects.module';
|
import { ProjectsModule } from '../projects/projects.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [PrismaModule, GiteaModule, ActivityModule, AuthModule, ProjectsModule],
|
||||||
PrismaModule,
|
|
||||||
GiteaModule,
|
|
||||||
ActivityModule,
|
|
||||||
AuthModule,
|
|
||||||
ProjectsModule,
|
|
||||||
],
|
|
||||||
controllers: [GiteaSyncController],
|
controllers: [GiteaSyncController],
|
||||||
providers: [GiteaSyncService],
|
providers: [GiteaSyncService],
|
||||||
exports: [GiteaSyncService],
|
exports: [GiteaSyncService],
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { GiteaService } from '../gitea/gitea.service';
|
import { GiteaService } from '../gitea/gitea.service';
|
||||||
import { ActivityService } from '../activity/activity.service';
|
import { ActivityService } from '../activity/activity.service';
|
||||||
@@ -16,11 +17,7 @@ export class GiteaSyncService {
|
|||||||
private readonly sprintSync: SprintSyncService,
|
private readonly sprintSync: SprintSyncService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async syncRepos(): Promise<{
|
async syncRepos(): Promise<{ synced: number; created: number; updated: number }> {
|
||||||
synced: number;
|
|
||||||
created: number;
|
|
||||||
updated: number;
|
|
||||||
}> {
|
|
||||||
const repos = await this.gitea.getOrgRepos();
|
const repos = await this.gitea.getOrgRepos();
|
||||||
|
|
||||||
if (!repos.length) {
|
if (!repos.length) {
|
||||||
@@ -74,14 +71,11 @@ export class GiteaSyncService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(
|
this.logger.log(`Gitea sync: ${repos.length} repos, ${created} new, ${updated} updated`);
|
||||||
`Gitea sync: ${repos.length} repos, ${created} new, ${updated} updated`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Sprint 동기화도 함께 수행
|
// Sprint 동기화도 함께 수행
|
||||||
await this.sprintSync.syncAllProjectSprints().catch((e: unknown) => {
|
await this.sprintSync.syncAllProjectSprints().catch((e) => {
|
||||||
const message = e instanceof Error ? e.message : String(e);
|
this.logger.warn(`Sprint sync failed: ${e.message}`);
|
||||||
this.logger.warn(`Sprint sync failed: ${message}`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { synced: repos.length, created, updated };
|
return { synced: repos.length, created, updated };
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export interface GiteaBranch {
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class GiteaService {
|
export class GiteaService {
|
||||||
private readonly logger = new Logger(GiteaService.name);
|
private readonly logger = new Logger(GiteaService.name);
|
||||||
private readonly client: AxiosInstance | null;
|
private readonly client: AxiosInstance;
|
||||||
private readonly org: string;
|
private readonly org: string;
|
||||||
|
|
||||||
constructor(private readonly config: ConfigService) {
|
constructor(private readonly config: ConfigService) {
|
||||||
@@ -54,10 +54,8 @@ export class GiteaService {
|
|||||||
this.org = config.get<string>('GITEA_ORG') ?? 'hanarang';
|
this.org = config.get<string>('GITEA_ORG') ?? 'hanarang';
|
||||||
|
|
||||||
if (!baseURL || !token) {
|
if (!baseURL || !token) {
|
||||||
this.logger.warn(
|
this.logger.warn('GITEA_BASE_URL or GITEA_TOKEN not set — Gitea features disabled');
|
||||||
'GITEA_BASE_URL or GITEA_TOKEN not set — Gitea features disabled',
|
this.client = null as any;
|
||||||
);
|
|
||||||
this.client = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,30 +66,27 @@ export class GiteaService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isAvailable(): boolean {
|
||||||
|
return this.client !== null;
|
||||||
|
}
|
||||||
|
|
||||||
async getOrgRepos(): Promise<GiteaRepo[]> {
|
async getOrgRepos(): Promise<GiteaRepo[]> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return [];
|
||||||
if (!client) return [];
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<GiteaRepo[]>(
|
const { data } = await this.client.get<GiteaRepo[]>(`/orgs/${this.org}/repos`, {
|
||||||
`/orgs/${this.org}/repos`,
|
|
||||||
{
|
|
||||||
params: { limit: 50 },
|
params: { limit: 50 },
|
||||||
},
|
});
|
||||||
);
|
|
||||||
return data;
|
return data;
|
||||||
} catch {
|
} catch (error) {
|
||||||
this.logger.warn('Failed to fetch Gitea repos');
|
this.logger.warn('Failed to fetch Gitea repos');
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRepo(repoName: string): Promise<GiteaRepo | null> {
|
async getRepo(repoName: string): Promise<GiteaRepo | null> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return null;
|
||||||
if (!client) return null;
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<GiteaRepo>(
|
const { data } = await this.client.get<GiteaRepo>(`/repos/${this.org}/${repoName}`);
|
||||||
`/repos/${this.org}/${repoName}`,
|
|
||||||
);
|
|
||||||
return data;
|
return data;
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
@@ -99,10 +94,9 @@ export class GiteaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOpenPRs(repoName: string): Promise<GiteaPR[]> {
|
async getOpenPRs(repoName: string): Promise<GiteaPR[]> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return [];
|
||||||
if (!client) return [];
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<GiteaPR[]>(
|
const { data } = await this.client.get<GiteaPR[]>(
|
||||||
`/repos/${this.org}/${repoName}/pulls`,
|
`/repos/${this.org}/${repoName}/pulls`,
|
||||||
{ params: { state: 'open', limit: 20 } },
|
{ params: { state: 'open', limit: 20 } },
|
||||||
);
|
);
|
||||||
@@ -113,10 +107,9 @@ export class GiteaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getCommits(repoName: string, limit = 20): Promise<GiteaCommit[]> {
|
async getCommits(repoName: string, limit = 20): Promise<GiteaCommit[]> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return [];
|
||||||
if (!client) return [];
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<GiteaCommit[]>(
|
const { data } = await this.client.get<GiteaCommit[]>(
|
||||||
`/repos/${this.org}/${repoName}/commits`,
|
`/repos/${this.org}/${repoName}/commits`,
|
||||||
{ params: { limit } },
|
{ params: { limit } },
|
||||||
);
|
);
|
||||||
@@ -128,10 +121,9 @@ export class GiteaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getBranches(repoName: string): Promise<GiteaBranch[]> {
|
async getBranches(repoName: string): Promise<GiteaBranch[]> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return [];
|
||||||
if (!client) return [];
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<GiteaBranch[]>(
|
const { data } = await this.client.get<GiteaBranch[]>(
|
||||||
`/repos/${this.org}/${repoName}/branches`,
|
`/repos/${this.org}/${repoName}/branches`,
|
||||||
{ params: { limit: 50 } },
|
{ params: { limit: 50 } },
|
||||||
);
|
);
|
||||||
@@ -141,14 +133,10 @@ export class GiteaService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPulls(
|
async getPulls(repoName: string, state: 'open' | 'closed' | 'all' = 'open'): Promise<GiteaPR[]> {
|
||||||
repoName: string,
|
if (!this.isAvailable()) return [];
|
||||||
state: 'open' | 'closed' | 'all' = 'open',
|
|
||||||
): Promise<GiteaPR[]> {
|
|
||||||
const client = this.client;
|
|
||||||
if (!client) return [];
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<GiteaPR[]>(
|
const { data } = await this.client.get<GiteaPR[]>(
|
||||||
`/repos/${this.org}/${repoName}/pulls`,
|
`/repos/${this.org}/${repoName}/pulls`,
|
||||||
{ params: { state, limit: 30, type: 'pulls' } },
|
{ params: { state, limit: 30, type: 'pulls' } },
|
||||||
);
|
);
|
||||||
@@ -159,27 +147,22 @@ export class GiteaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getRepoTree(repoName: string, treePath: string): Promise<string[]> {
|
async getRepoTree(repoName: string, treePath: string): Promise<string[]> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return [];
|
||||||
if (!client) return [];
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<{
|
const { data } = await this.client.get<{ tree: { path: string; type: string }[] }>(
|
||||||
tree: { path: string; type: string }[];
|
`/repos/${this.org}/${repoName}/git/trees/HEAD`,
|
||||||
}>(`/repos/${this.org}/${repoName}/git/trees/HEAD`, {
|
{ params: { recursive: true } },
|
||||||
params: { recursive: true },
|
);
|
||||||
});
|
return (data.tree ?? []).filter((e) => e.path.startsWith(treePath) && e.type === 'blob').map((e) => e.path);
|
||||||
return (data.tree ?? [])
|
|
||||||
.filter((e) => e.path.startsWith(treePath) && e.type === 'blob')
|
|
||||||
.map((e) => e.path);
|
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRawFile(repoName: string, filePath: string): Promise<string | null> {
|
async getRawFile(repoName: string, filePath: string): Promise<string | null> {
|
||||||
const client = this.client;
|
if (!this.isAvailable()) return null;
|
||||||
if (!client) return null;
|
|
||||||
try {
|
try {
|
||||||
const { data } = await client.get<string>(
|
const { data } = await this.client.get<string>(
|
||||||
`/repos/${this.org}/${repoName}/raw/${filePath}`,
|
`/repos/${this.org}/${repoName}/raw/${filePath}`,
|
||||||
{ params: { ref: 'main' }, responseType: 'text' },
|
{ params: { ref: 'main' }, responseType: 'text' },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,64 +1,20 @@
|
|||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { Logger, ValidationPipe } from '@nestjs/common';
|
import { Logger, ValidationPipe } from '@nestjs/common';
|
||||||
import type { NextFunction, Request, Response } from 'express';
|
|
||||||
import helmet from 'helmet';
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import {
|
import helmet from 'helmet';
|
||||||
ACCESS_TOKEN_COOKIE,
|
|
||||||
REFRESH_TOKEN_COOKIE,
|
|
||||||
getCookieValue,
|
|
||||||
hasValidCsrfToken,
|
|
||||||
} from './auth/auth-cookies';
|
|
||||||
|
|
||||||
function getAllowedOrigins() {
|
|
||||||
return (process.env.CORS_ORIGINS ?? 'http://localhost:3004')
|
|
||||||
.split(',')
|
|
||||||
.map((origin) => origin.trim())
|
|
||||||
.filter((origin): origin is string => origin.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldBypassCsrf(req: Request): boolean {
|
|
||||||
if (['GET', 'HEAD', 'OPTIONS'].includes(req.method.toUpperCase())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.path === '/api/auth/login') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasAuthorizationHeader = Boolean(req.headers.authorization);
|
|
||||||
if (hasAuthorizationHeader) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasAuthCookie = Boolean(
|
|
||||||
getCookieValue(req, ACCESS_TOKEN_COOKIE) ||
|
|
||||||
getCookieValue(req, REFRESH_TOKEN_COOKIE),
|
|
||||||
);
|
|
||||||
|
|
||||||
return !hasAuthCookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
|
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
|
||||||
if (shouldBypassCsrf(req) || hasValidCsrfToken(req)) {
|
|
||||||
next();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
res.status(403).json({ message: 'Invalid CSRF token' });
|
const allowedOrigins = (process.env.CORS_ORIGINS ?? 'http://localhost:3004')
|
||||||
});
|
.split(',')
|
||||||
|
.map((o) => o.trim())
|
||||||
const allowedOrigins = getAllowedOrigins();
|
.filter(Boolean);
|
||||||
|
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: (
|
origin: (origin, callback) => {
|
||||||
origin: string | undefined,
|
|
||||||
callback: (err: Error | null, allow?: boolean) => void,
|
|
||||||
) => {
|
|
||||||
if (!origin || allowedOrigins.includes(origin)) {
|
if (!origin || allowedOrigins.includes(origin)) {
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
@@ -66,26 +22,13 @@ async function bootstrap() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: ['GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'OPTIONS'],
|
methods: ['GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'OPTIONS'],
|
||||||
allowedHeaders: [
|
|
||||||
'Content-Type',
|
|
||||||
'Authorization',
|
|
||||||
'X-CSRF-Token',
|
|
||||||
'X-Refresh-Token',
|
|
||||||
],
|
|
||||||
credentials: true,
|
credentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
app.useGlobalPipes(
|
app.useGlobalPipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true }));
|
||||||
new ValidationPipe({
|
|
||||||
whitelist: true,
|
|
||||||
forbidNonWhitelisted: true,
|
|
||||||
transform: true,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const port = Number(process.env.BACKEND_PORT ?? 3005);
|
const port = process.env.BACKEND_PORT ?? 3005;
|
||||||
await app.listen(port);
|
await app.listen(port);
|
||||||
Logger.log(`🚀 Backend running on port ${port}`, 'Bootstrap');
|
Logger.log(`🚀 Backend running on port ${port}`, 'Bootstrap');
|
||||||
}
|
}
|
||||||
|
bootstrap();
|
||||||
void bootstrap();
|
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import { PrismaClient } from '@prisma/client';
|
|||||||
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
|
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PrismaService
|
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
||||||
extends PrismaClient
|
|
||||||
implements OnModuleInit, OnModuleDestroy
|
|
||||||
{
|
|
||||||
constructor(config: ConfigService) {
|
constructor(config: ConfigService) {
|
||||||
const dbUrl = config.get<string>('DATABASE_URL');
|
const dbUrl = config.get<string>('DATABASE_URL');
|
||||||
if (!dbUrl) {
|
if (!dbUrl) {
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
import {
|
import { Controller, Get, Param, Query, ParseIntPipe, UseGuards, Post } from '@nestjs/common';
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Param,
|
|
||||||
Query,
|
|
||||||
ParseIntPipe,
|
|
||||||
UseGuards,
|
|
||||||
Post,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ProjectsService } from './projects.service';
|
import { ProjectsService } from './projects.service';
|
||||||
import { SprintSyncService } from './sprint-sync.service';
|
import { SprintSyncService } from './sprint-sync.service';
|
||||||
import { JwtGuard } from '../auth/jwt.guard';
|
import { JwtGuard } from '../auth/jwt.guard';
|
||||||
|
|||||||
@@ -1,182 +1,7 @@
|
|||||||
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
|
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { GiteaService } from '../gitea/gitea.service';
|
import { GiteaService } from '../gitea/gitea.service';
|
||||||
|
import { ActivityService } from '../activity/activity.service';
|
||||||
type QaStatus = 'passed' | 'failed' | 'unknown';
|
|
||||||
type ProjectPhase =
|
|
||||||
| 'PLANNING'
|
|
||||||
| 'IMPLEMENT'
|
|
||||||
| 'QA'
|
|
||||||
| 'READY FOR DEPLOY'
|
|
||||||
| 'DEPLOYED';
|
|
||||||
|
|
||||||
export interface RepoDocumentMeta {
|
|
||||||
path: string;
|
|
||||||
label: string;
|
|
||||||
order: number;
|
|
||||||
kind: 'sprint' | 'hotfix' | 'qa';
|
|
||||||
summary: string | null;
|
|
||||||
description: string | null;
|
|
||||||
qaStatus?: QaStatus;
|
|
||||||
blockerCount?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProjectMetaSummary {
|
|
||||||
phase: ProjectPhase;
|
|
||||||
latestHotfix: string | null;
|
|
||||||
latestQaLabel: string | null;
|
|
||||||
latestQaStatus: QaStatus;
|
|
||||||
blockerCount: number;
|
|
||||||
deployStatus: 'DEPLOYED ON MAIN' | 'READY FOR DEPLOY' | 'REDEPLOY REQUIRED';
|
|
||||||
deployBranch: 'main';
|
|
||||||
redeployRequired: boolean;
|
|
||||||
latestDeployAt: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QA_PATH_CANDIDATES = ['.plans/qa/', '.qa/'];
|
|
||||||
const HOTFIX_PATH_CANDIDATES = ['.plans/hotfix/', '.plans/sprints/'];
|
|
||||||
const SPRINT_PATH = '.plans/sprints/';
|
|
||||||
|
|
||||||
function normalizeRepoName(repoUrl: string): string {
|
|
||||||
return repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractDocOrder(
|
|
||||||
path: string,
|
|
||||||
kind: 'sprint' | 'hotfix' | 'qa',
|
|
||||||
): number {
|
|
||||||
const name = path.split('/').pop() ?? '';
|
|
||||||
if (kind === 'hotfix') {
|
|
||||||
const hotfix = name.match(/HOTFIX-(\d+)/i);
|
|
||||||
return hotfix ? 1000 + parseInt(hotfix[1], 10) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sprint = name.match(/SPRINT-(\d+)/i);
|
|
||||||
return sprint ? parseInt(sprint[1], 10) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseGoalSummary(content: string): string | null {
|
|
||||||
const lines = content.split(/\r?\n/);
|
|
||||||
const goalIndex = lines.findIndex((line) => /^##\s*목표/.test(line.trim()));
|
|
||||||
if (goalIndex < 0) return null;
|
|
||||||
|
|
||||||
for (let index = goalIndex + 1; index < lines.length; index += 1) {
|
|
||||||
const line = lines[index].trim();
|
|
||||||
if (!line) continue;
|
|
||||||
if (/^##\s+/.test(line)) break;
|
|
||||||
return line.replace(/^-\s*/, '').trim() || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseTaskSummary(content: string): string | null {
|
|
||||||
const lines = content.split(/\r?\n/);
|
|
||||||
const taskIndex = lines.findIndex((line) => /^##\s*태스크/.test(line.trim()));
|
|
||||||
if (taskIndex < 0) return null;
|
|
||||||
|
|
||||||
for (let index = taskIndex + 1; index < lines.length; index += 1) {
|
|
||||||
const line = lines[index].trim();
|
|
||||||
if (!line) continue;
|
|
||||||
if (/^##\s+/.test(line)) break;
|
|
||||||
if (/^###\s+/.test(line)) return line.replace(/^###\s+/, '').trim();
|
|
||||||
if (/^-\s+/.test(line)) return line.replace(/^-\s+/, '').trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseQaStatus(content: string): QaStatus {
|
|
||||||
if (/passed\s*[:=]\s*true/i.test(content)) return 'passed';
|
|
||||||
if (/passed\s*[:=]\s*false/i.test(content)) return 'failed';
|
|
||||||
if (/\bPASSED\b/i.test(content) && !/\bFAILED\b/i.test(content))
|
|
||||||
return 'passed';
|
|
||||||
if (/\bFAILED\b/i.test(content)) return 'failed';
|
|
||||||
return 'unknown';
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseBlockerCount(content: string): number {
|
|
||||||
const jsonMatch = content.match(/"errors"\s*:\s*\[(.*?)\]/is);
|
|
||||||
if (jsonMatch) {
|
|
||||||
const items = jsonMatch[1]
|
|
||||||
.split(',')
|
|
||||||
.map((item) => item.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
if (items.length > 0) return items.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorLines = content
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter(
|
|
||||||
(line) =>
|
|
||||||
/^[-*]\s+/.test(line) && /(error|blocker|실패|문제)/i.test(line),
|
|
||||||
);
|
|
||||||
|
|
||||||
return errorLines.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isRepoDocumentMeta(
|
|
||||||
value: RepoDocumentMeta | null,
|
|
||||||
): value is RepoDocumentMeta {
|
|
||||||
return value !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildProjectMeta(params: {
|
|
||||||
totalSprints: number;
|
|
||||||
doneSprints: number;
|
|
||||||
hasActiveSprint: boolean;
|
|
||||||
openPRs: number;
|
|
||||||
latestHotfix: string | null;
|
|
||||||
latestQaLabel: string | null;
|
|
||||||
latestQaStatus: QaStatus;
|
|
||||||
blockerCount: number;
|
|
||||||
updatedAt: string;
|
|
||||||
}): ProjectMetaSummary {
|
|
||||||
const {
|
|
||||||
totalSprints,
|
|
||||||
doneSprints,
|
|
||||||
hasActiveSprint,
|
|
||||||
openPRs,
|
|
||||||
latestHotfix,
|
|
||||||
latestQaLabel,
|
|
||||||
latestQaStatus,
|
|
||||||
blockerCount,
|
|
||||||
updatedAt,
|
|
||||||
} = params;
|
|
||||||
|
|
||||||
let phase: ProjectPhase = 'PLANNING';
|
|
||||||
if (totalSprints === 0) {
|
|
||||||
phase = 'PLANNING';
|
|
||||||
} else if (latestQaStatus === 'passed' && doneSprints === totalSprints) {
|
|
||||||
phase = 'DEPLOYED';
|
|
||||||
} else if (latestQaStatus === 'passed') {
|
|
||||||
phase = 'READY FOR DEPLOY';
|
|
||||||
} else if (latestQaStatus === 'failed') {
|
|
||||||
phase = 'QA';
|
|
||||||
} else if (hasActiveSprint || openPRs > 0 || doneSprints < totalSprints) {
|
|
||||||
phase = 'IMPLEMENT';
|
|
||||||
}
|
|
||||||
|
|
||||||
const deployStatus =
|
|
||||||
phase === 'DEPLOYED'
|
|
||||||
? 'DEPLOYED ON MAIN'
|
|
||||||
: phase === 'READY FOR DEPLOY'
|
|
||||||
? 'READY FOR DEPLOY'
|
|
||||||
: 'REDEPLOY REQUIRED';
|
|
||||||
|
|
||||||
return {
|
|
||||||
phase,
|
|
||||||
latestHotfix,
|
|
||||||
latestQaLabel,
|
|
||||||
latestQaStatus,
|
|
||||||
blockerCount,
|
|
||||||
deployStatus,
|
|
||||||
deployBranch: 'main',
|
|
||||||
redeployRequired: deployStatus !== 'DEPLOYED ON MAIN',
|
|
||||||
latestDeployAt: latestQaStatus === 'passed' ? updatedAt : null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ProjectsService {
|
export class ProjectsService {
|
||||||
@@ -185,82 +10,54 @@ export class ProjectsService {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly gitea: GiteaService,
|
private readonly gitea: GiteaService,
|
||||||
|
private readonly activity: ActivityService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getProjects() {
|
async getProjects() {
|
||||||
|
// DB에 등록된 프로젝트 + Gitea 최신 정보 병합
|
||||||
const dbProjects = await this.prisma.project.findMany({
|
const dbProjects = await this.prisma.project.findMany({
|
||||||
include: { sprints: { include: { tasks: true } } },
|
include: { sprints: { include: { tasks: true } } },
|
||||||
orderBy: { updatedAt: 'desc' },
|
orderBy: { updatedAt: 'desc' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const [repoMetaMap, repoDocsMap] = await Promise.all([
|
let giteaRepos: Record<number, { openPRs: number; updatedAt: string }> = {};
|
||||||
this.getRepoMetaMap(),
|
try {
|
||||||
this.getRepoDocumentMap(
|
const repos = await this.gitea.getOrgRepos();
|
||||||
dbProjects.map((project) => normalizeRepoName(project.repoUrl)),
|
for (const repo of repos) {
|
||||||
),
|
giteaRepos[repo.id] = {
|
||||||
]);
|
openPRs: repo.open_pr_counter,
|
||||||
|
updatedAt: repo.updated_at,
|
||||||
return dbProjects.map((project) => {
|
|
||||||
const totalSprints = project.sprints.length;
|
|
||||||
const doneSprints = project.sprints.filter(
|
|
||||||
(sprint) => sprint.status === 'done',
|
|
||||||
).length;
|
|
||||||
const inProgressSprint = project.sprints.find(
|
|
||||||
(sprint) => sprint.status === 'in_progress',
|
|
||||||
);
|
|
||||||
const ownerSister =
|
|
||||||
project.sprints
|
|
||||||
.flatMap((sprint) => sprint.tasks)
|
|
||||||
.find((task) => task.assignee)?.assignee ?? 'narang';
|
|
||||||
const progress =
|
|
||||||
totalSprints > 0 ? Math.round((doneSprints / totalSprints) * 100) : 0;
|
|
||||||
const repoMeta = repoMetaMap[project.giteaId];
|
|
||||||
const docs = repoDocsMap.get(normalizeRepoName(project.repoUrl)) ?? {
|
|
||||||
hotfixes: [],
|
|
||||||
qas: [],
|
|
||||||
};
|
};
|
||||||
const latestHotfix = docs.hotfixes.at(-1) ?? null;
|
}
|
||||||
const latestQa = docs.qas.at(-1) ?? null;
|
} catch {
|
||||||
const meta = buildProjectMeta({
|
this.logger.warn('Gitea unavailable, using DB data only');
|
||||||
totalSprints,
|
}
|
||||||
doneSprints,
|
|
||||||
hasActiveSprint: Boolean(inProgressSprint),
|
return dbProjects.map((p) => {
|
||||||
openPRs: repoMeta?.openPRs ?? 0,
|
// Sprint 기반 진행률 (백엔드 task 없어도 동작)
|
||||||
latestHotfix: latestHotfix?.label ?? null,
|
const totalSprints = p.sprints.length;
|
||||||
latestQaLabel: latestQa?.label ?? null,
|
const doneSprints = p.sprints.filter((s) => s.status === 'done').length;
|
||||||
latestQaStatus: latestQa?.qaStatus ?? 'unknown',
|
const inProgressSprint = p.sprints.find((s) => s.status === 'in_progress');
|
||||||
blockerCount: latestQa?.blockerCount ?? 0,
|
const ownerSister = p.sprints.flatMap((s) => s.tasks).find((t) => t.assignee)?.assignee ?? 'narang';
|
||||||
updatedAt: repoMeta?.updatedAt ?? project.updatedAt.toISOString(),
|
|
||||||
});
|
const progress = totalSprints > 0 ? Math.round((doneSprints / totalSprints) * 100) : 0;
|
||||||
|
const gitea = giteaRepos[p.giteaId];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: project.id,
|
id: p.id,
|
||||||
giteaId: project.giteaId,
|
giteaId: p.giteaId,
|
||||||
name: project.name,
|
name: p.name,
|
||||||
repoUrl: project.repoUrl,
|
repoUrl: p.repoUrl,
|
||||||
description: project.description,
|
description: p.description,
|
||||||
status: project.status,
|
status: p.status,
|
||||||
progress,
|
progress,
|
||||||
totalSprints,
|
totalSprints,
|
||||||
doneSprints,
|
doneSprints,
|
||||||
sprintCount: totalSprints,
|
|
||||||
currentSprint:
|
|
||||||
inProgressSprint?.name ??
|
|
||||||
(doneSprints === totalSprints && totalSprints > 0
|
|
||||||
? 'COMPLETED'
|
|
||||||
: null),
|
|
||||||
ownerSister,
|
ownerSister,
|
||||||
openPRs: repoMeta?.openPRs ?? 0,
|
openPRs: gitea?.openPRs ?? 0,
|
||||||
updatedAt: repoMeta?.updatedAt ?? project.updatedAt.toISOString(),
|
updatedAt: gitea?.updatedAt ?? p.updatedAt.toISOString(),
|
||||||
latestHotfix: meta.latestHotfix,
|
sprintCount: totalSprints,
|
||||||
latestQaLabel: meta.latestQaLabel,
|
currentSprint: inProgressSprint?.name ?? (doneSprints === totalSprints && totalSprints > 0 ? 'COMPLETED' : null),
|
||||||
latestQaStatus: meta.latestQaStatus,
|
|
||||||
blockerCount: meta.blockerCount,
|
|
||||||
phase: meta.phase,
|
|
||||||
deployStatus: meta.deployStatus,
|
|
||||||
deployBranch: meta.deployBranch,
|
|
||||||
redeployRequired: meta.redeployRequired,
|
|
||||||
latestDeployAt: meta.latestDeployAt,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -278,198 +75,81 @@ export class ProjectsService {
|
|||||||
|
|
||||||
if (!project) throw new NotFoundException(`Project ${id} not found`);
|
if (!project) throw new NotFoundException(`Project ${id} not found`);
|
||||||
|
|
||||||
const repoName = normalizeRepoName(project.repoUrl);
|
let giteaPRs: ReturnType<typeof Array.prototype.map> = [];
|
||||||
const [openPRs, docs] = await Promise.all([
|
try {
|
||||||
this.gitea.getOpenPRs(repoName).catch(() => {
|
const repoName = project.repoUrl.split('/').pop() ?? '';
|
||||||
|
giteaPRs = await this.gitea.getOpenPRs(repoName);
|
||||||
|
} catch {
|
||||||
this.logger.warn(`Gitea PR fetch failed for project ${id}`);
|
this.logger.warn(`Gitea PR fetch failed for project ${id}`);
|
||||||
return [];
|
|
||||||
}),
|
|
||||||
this.collectRepoDocuments(repoName),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const totalSprints = project.sprints.length;
|
|
||||||
const doneSprints = project.sprints.filter(
|
|
||||||
(sprint) => sprint.status === 'done',
|
|
||||||
).length;
|
|
||||||
const activeSprint = project.sprints.find(
|
|
||||||
(sprint) => sprint.status === 'in_progress',
|
|
||||||
);
|
|
||||||
const meta = buildProjectMeta({
|
|
||||||
totalSprints,
|
|
||||||
doneSprints,
|
|
||||||
hasActiveSprint: Boolean(activeSprint),
|
|
||||||
openPRs: openPRs.length,
|
|
||||||
latestHotfix: docs.hotfixes.at(-1)?.label ?? null,
|
|
||||||
latestQaLabel: docs.qas.at(-1)?.label ?? null,
|
|
||||||
latestQaStatus: docs.qas.at(-1)?.qaStatus ?? 'unknown',
|
|
||||||
blockerCount: docs.qas.at(-1)?.blockerCount ?? 0,
|
|
||||||
updatedAt: project.updatedAt.toISOString(),
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
...project,
|
|
||||||
openPRs,
|
|
||||||
phase: meta.phase,
|
|
||||||
latestQa: docs.qas.at(-1)
|
|
||||||
? {
|
|
||||||
label: docs.qas.at(-1)?.label ?? null,
|
|
||||||
status: docs.qas.at(-1)?.qaStatus ?? 'unknown',
|
|
||||||
blockerCount: docs.qas.at(-1)?.blockerCount ?? 0,
|
|
||||||
summary:
|
|
||||||
docs.qas.at(-1)?.summary ?? docs.qas.at(-1)?.description ?? null,
|
|
||||||
}
|
}
|
||||||
: null,
|
|
||||||
deploy: {
|
return { ...project, openPRs: giteaPRs };
|
||||||
branch: 'main',
|
|
||||||
status: meta.deployStatus,
|
|
||||||
latestDeployAt: meta.latestDeployAt,
|
|
||||||
redeployRequired: meta.redeployRequired,
|
|
||||||
note: 'ERANG: LATEST MAIN REDEPLOY ONLY',
|
|
||||||
},
|
|
||||||
latestHotfix: docs.hotfixes.at(-1) ?? null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectCommits(id: number, limit = 20) {
|
async getProjectCommits(id: number, limit = 20) {
|
||||||
const project = await this.getProjectMeta(id);
|
const project = await this.getProjectMeta(id);
|
||||||
return this.gitea.getCommits(normalizeRepoName(project.repoUrl), limit);
|
const repoName = project.repoUrl.split('/').pop() ?? '';
|
||||||
|
return this.gitea.getCommits(repoName, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectBranches(id: number) {
|
async getProjectBranches(id: number) {
|
||||||
const project = await this.getProjectMeta(id);
|
const project = await this.getProjectMeta(id);
|
||||||
return this.gitea.getBranches(normalizeRepoName(project.repoUrl));
|
const repoName = project.repoUrl.split('/').pop() ?? '';
|
||||||
|
return this.gitea.getBranches(repoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectPulls(id: number, state: 'open' | 'closed' | 'all' = 'open') {
|
async getProjectPulls(id: number, state: 'open' | 'closed' | 'all' = 'open') {
|
||||||
const project = await this.getProjectMeta(id);
|
const project = await this.getProjectMeta(id);
|
||||||
return this.gitea.getPulls(normalizeRepoName(project.repoUrl), state);
|
const repoName = project.repoUrl.split('/').pop() ?? '';
|
||||||
|
return this.gitea.getPulls(repoName, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectHistory(id: number) {
|
async getProjectHistory(id: number) {
|
||||||
const project = await this.getProjectMeta(id);
|
const project = await this.getProjectMeta(id);
|
||||||
const repoName = normalizeRepoName(project.repoUrl);
|
const repoName = project.repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
||||||
const docs = await this.collectRepoDocuments(repoName);
|
const files = await this.gitea.getRepoTree(repoName, '.plans/sprints/');
|
||||||
|
return await Promise.all(
|
||||||
|
files
|
||||||
|
.filter((f) => /(SPRINT-\d+|HOTFIX-\d+)\.md$/i.test(f))
|
||||||
|
.map(async (f) => {
|
||||||
|
const name = f.split('/').pop() ?? '';
|
||||||
|
const sprint = name.match(/SPRINT-(\d+)/i);
|
||||||
|
const hotfix = name.match(/HOTFIX-(\d+)/i);
|
||||||
|
let summary: string | null = null;
|
||||||
|
let description: string | null = null;
|
||||||
|
|
||||||
return [...docs.sprints, ...docs.hotfixes]
|
try {
|
||||||
.filter(isRepoDocumentMeta)
|
const content = await this.gitea.getRawFile(repoName, f);
|
||||||
.sort((a, b) => a.order - b.order);
|
const lines = (content ?? '').split('\n');
|
||||||
|
const goalLine = lines.find((line) => line.startsWith('## 목표'));
|
||||||
|
summary = goalLine?.replace('## 목표', '').trim() || null;
|
||||||
|
|
||||||
|
const taskIdx = lines.findIndex((line) => line.startsWith('## 태스크'));
|
||||||
|
if (taskIdx >= 0) {
|
||||||
|
description = lines
|
||||||
|
.slice(taskIdx + 1)
|
||||||
|
.find((line) => line.trim().startsWith('- '))
|
||||||
|
?.replace(/^\s*-\s*/, '')
|
||||||
|
.trim() ?? null;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
this.logger.warn(`History content fetch failed for ${f}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
kind: sprint ? 'sprint' : 'hotfix',
|
||||||
|
order: sprint ? parseInt(sprint[1], 10) : 1000 + parseInt(hotfix?.[1] ?? '0', 10),
|
||||||
|
label: name.replace('.md', ''),
|
||||||
|
summary,
|
||||||
|
description,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
).then((items) => items.sort((a, b) => a.order - b.order));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getProjectMeta(id: number) {
|
private async getProjectMeta(id: number) {
|
||||||
const project = await this.prisma.project.findUnique({
|
const project = await this.prisma.project.findUnique({ where: { id }, select: { id: true, repoUrl: true } });
|
||||||
where: { id },
|
|
||||||
select: { id: true, repoUrl: true },
|
|
||||||
});
|
|
||||||
if (!project) throw new NotFoundException(`Project ${id} not found`);
|
if (!project) throw new NotFoundException(`Project ${id} not found`);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getRepoMetaMap() {
|
|
||||||
const repoMetaMap: Record<number, { openPRs: number; updatedAt: string }> =
|
|
||||||
{};
|
|
||||||
try {
|
|
||||||
const repos = await this.gitea.getOrgRepos();
|
|
||||||
for (const repo of repos) {
|
|
||||||
repoMetaMap[repo.id] = {
|
|
||||||
openPRs: repo.open_pr_counter,
|
|
||||||
updatedAt: repo.updated_at,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
this.logger.warn('Gitea unavailable, using DB data only');
|
|
||||||
}
|
|
||||||
return repoMetaMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getRepoDocumentMap(repoNames: string[]) {
|
|
||||||
const uniqueRepoNames = Array.from(new Set(repoNames.filter(Boolean)));
|
|
||||||
const entries = await Promise.all(
|
|
||||||
uniqueRepoNames.map(
|
|
||||||
async (repoName) =>
|
|
||||||
[repoName, await this.collectRepoDocuments(repoName)] as const,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return new Map(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async collectRepoDocuments(repoName: string) {
|
|
||||||
const [sprintPaths, hotfixPathGroups, qaPathGroups] = await Promise.all([
|
|
||||||
this.gitea.getRepoTree(repoName, SPRINT_PATH),
|
|
||||||
Promise.all(
|
|
||||||
HOTFIX_PATH_CANDIDATES.map((path) =>
|
|
||||||
this.gitea.getRepoTree(repoName, path),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Promise.all(
|
|
||||||
QA_PATH_CANDIDATES.map((path) =>
|
|
||||||
this.gitea.getRepoTree(repoName, path),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const sprintFiles = sprintPaths.filter((path) =>
|
|
||||||
/SPRINT-\d+\.md$/i.test(path),
|
|
||||||
);
|
|
||||||
const hotfixFiles = Array.from(
|
|
||||||
new Set(
|
|
||||||
hotfixPathGroups.flat().filter((path) => /HOTFIX-\d+\.md$/i.test(path)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const qaFiles = Array.from(
|
|
||||||
new Set(
|
|
||||||
qaPathGroups
|
|
||||||
.flat()
|
|
||||||
.filter((path) =>
|
|
||||||
/(?:SPRINT|HOTFIX)-\d+.*(?:review|qa).*\.md$/i.test(path),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
const [sprints, hotfixes, qas] = await Promise.all([
|
|
||||||
Promise.all(
|
|
||||||
sprintFiles.map((path) =>
|
|
||||||
this.readRepoDocument(repoName, path, 'sprint'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Promise.all(
|
|
||||||
hotfixFiles.map((path) =>
|
|
||||||
this.readRepoDocument(repoName, path, 'hotfix'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Promise.all(
|
|
||||||
qaFiles.map((path) => this.readRepoDocument(repoName, path, 'qa')),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
sprints: sprints
|
|
||||||
.filter(isRepoDocumentMeta)
|
|
||||||
.sort((a, b) => a.order - b.order),
|
|
||||||
hotfixes: hotfixes
|
|
||||||
.filter(isRepoDocumentMeta)
|
|
||||||
.sort((a, b) => a.order - b.order),
|
|
||||||
qas: qas.filter(isRepoDocumentMeta).sort((a, b) => a.order - b.order),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private async readRepoDocument(
|
|
||||||
repoName: string,
|
|
||||||
path: string,
|
|
||||||
kind: 'sprint' | 'hotfix' | 'qa',
|
|
||||||
): Promise<RepoDocumentMeta | null> {
|
|
||||||
const content = await this.gitea.getRawFile(repoName, path);
|
|
||||||
if (!content) return null;
|
|
||||||
|
|
||||||
const label = (path.split('/').pop() ?? '').replace('.md', '');
|
|
||||||
return {
|
|
||||||
path,
|
|
||||||
label,
|
|
||||||
order: extractDocOrder(path, kind),
|
|
||||||
kind,
|
|
||||||
summary: parseGoalSummary(content),
|
|
||||||
description: parseTaskSummary(content),
|
|
||||||
qaStatus: kind === 'qa' ? parseQaStatus(content) : undefined,
|
|
||||||
blockerCount: kind === 'qa' ? parseBlockerCount(content) : undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { SprintSyncService } from './sprint-sync.service';
|
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
|
||||||
import { GiteaService } from '../gitea/gitea.service';
|
|
||||||
|
|
||||||
describe('SprintSyncService', () => {
|
|
||||||
let service: SprintSyncService;
|
|
||||||
|
|
||||||
type TaskWriteArgs = {
|
|
||||||
data: {
|
|
||||||
taskId?: string;
|
|
||||||
assignee: string;
|
|
||||||
status: string;
|
|
||||||
};
|
|
||||||
where?: { id: number };
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockPrisma = {
|
|
||||||
project: { findUnique: jest.fn(), findMany: jest.fn() },
|
|
||||||
sprint: { findFirst: jest.fn(), create: jest.fn(), update: jest.fn() },
|
|
||||||
task: { findFirst: jest.fn(), create: jest.fn(), update: jest.fn() },
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockGitea = {
|
|
||||||
getRepoTree: jest.fn(),
|
|
||||||
getRawFile: jest.fn(),
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
providers: [
|
|
||||||
SprintSyncService,
|
|
||||||
{ provide: PrismaService, useValue: mockPrisma },
|
|
||||||
{ provide: GiteaService, useValue: mockGitea },
|
|
||||||
],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<SprintSyncService>(SprintSyncService);
|
|
||||||
jest.clearAllMocks();
|
|
||||||
|
|
||||||
mockPrisma.project.findUnique.mockResolvedValue({
|
|
||||||
id: 1,
|
|
||||||
repoUrl: 'https://gitea.example.com/hanarang/project-alpha',
|
|
||||||
});
|
|
||||||
mockPrisma.project.findMany.mockResolvedValue([
|
|
||||||
{ id: 1, repoUrl: 'https://gitea.example.com/hanarang/project-alpha' },
|
|
||||||
]);
|
|
||||||
mockPrisma.sprint.findFirst.mockResolvedValue(null);
|
|
||||||
mockPrisma.sprint.create.mockResolvedValue({ id: 101, status: 'pending' });
|
|
||||||
mockPrisma.sprint.update.mockResolvedValue({ id: 101, status: 'pending' });
|
|
||||||
mockPrisma.task.findFirst.mockResolvedValue(null);
|
|
||||||
mockPrisma.task.create.mockResolvedValue({});
|
|
||||||
mockPrisma.task.update.mockResolvedValue({});
|
|
||||||
|
|
||||||
mockGitea.getRepoTree.mockImplementation(
|
|
||||||
(_repoName: string, path: string) => {
|
|
||||||
if (path === '.plans/sprints/') {
|
|
||||||
return [
|
|
||||||
'.plans/sprints/SPRINT-005.md',
|
|
||||||
'.plans/sprints/HOTFIX-001.md',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
if (path === '.plans/qa/') {
|
|
||||||
return ['.plans/qa/SPRINT-005-review-darang.md'];
|
|
||||||
}
|
|
||||||
if (path === '.qa/') return [];
|
|
||||||
if (path === '.plans/hotfix/') return ['.plans/hotfix/HOTFIX-001.md'];
|
|
||||||
return [];
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('담당 라인을 읽어 assignee를 저장한다', async () => {
|
|
||||||
mockGitea.getRawFile.mockImplementation(
|
|
||||||
(_repoName: string, path: string) => {
|
|
||||||
if (path.includes('SPRINT-005.md')) {
|
|
||||||
return `# SPRINT-005: Infra\n\n## 목표\n테스트\n\n## 태스크\n\n### TASK-019: 인프라 배포\n- **담당:** 이랑이\n- **설명:** deploy\n\n### TASK-020: QA 자동화\n- **담당:** darang\n- **설명:** qa\n`;
|
|
||||||
}
|
|
||||||
if (path.includes('review')) return 'passed: true';
|
|
||||||
return '# HOTFIX-001: sample';
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
await service.syncProjectSprints(1);
|
|
||||||
|
|
||||||
const createCalls = mockPrisma.task.create.mock.calls as Array<
|
|
||||||
[TaskWriteArgs]
|
|
||||||
>;
|
|
||||||
|
|
||||||
expect(createCalls[0]?.[0]).toMatchObject({
|
|
||||||
data: {
|
|
||||||
taskId: 'TASK-019',
|
|
||||||
assignee: 'erang',
|
|
||||||
status: 'done',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
expect(createCalls[1]?.[0]).toMatchObject({
|
|
||||||
data: {
|
|
||||||
taskId: 'TASK-020',
|
|
||||||
assignee: 'darang',
|
|
||||||
status: 'done',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('기존 task도 assignee를 갱신한다', async () => {
|
|
||||||
mockPrisma.task.findFirst.mockResolvedValue({
|
|
||||||
id: 500,
|
|
||||||
assignee: 'narang',
|
|
||||||
status: 'pending',
|
|
||||||
});
|
|
||||||
mockGitea.getRawFile.mockImplementation(
|
|
||||||
(_repoName: string, path: string) => {
|
|
||||||
if (path.includes('SPRINT-005.md')) {
|
|
||||||
return `# SPRINT-005: Infra\n\n## 목표\n테스트\n\n## 태스크\n\n### TASK-019: 인프라 배포\n- **담당:** 하랑이\n`;
|
|
||||||
}
|
|
||||||
if (path.includes('review')) return 'passed: false';
|
|
||||||
return '# HOTFIX-001: sample';
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
await service.syncProjectSprints(1);
|
|
||||||
|
|
||||||
const updateCalls = mockPrisma.task.update.mock.calls as Array<
|
|
||||||
[TaskWriteArgs]
|
|
||||||
>;
|
|
||||||
|
|
||||||
expect(updateCalls[0]?.[0]).toMatchObject({
|
|
||||||
where: { id: 500 },
|
|
||||||
data: { assignee: 'harang' },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('담당 라인이 없으면 narang fallback', async () => {
|
|
||||||
mockGitea.getRawFile.mockImplementation(
|
|
||||||
(_repoName: string, path: string) => {
|
|
||||||
if (path.includes('SPRINT-005.md')) {
|
|
||||||
return `# SPRINT-005: Infra\n\n## 목표\n테스트\n\n## 태스크\n\n### TASK-019: 인프라 배포\n- 설명만 있음\n`;
|
|
||||||
}
|
|
||||||
if (path.includes('review')) return 'FAILED';
|
|
||||||
return '# HOTFIX-001: sample';
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
await service.syncProjectSprints(1);
|
|
||||||
|
|
||||||
const createCalls = mockPrisma.task.create.mock.calls as Array<
|
|
||||||
[TaskWriteArgs]
|
|
||||||
>;
|
|
||||||
|
|
||||||
expect(createCalls[0]?.[0]).toMatchObject({
|
|
||||||
data: {
|
|
||||||
assignee: 'narang',
|
|
||||||
status: 'pending',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -2,102 +2,69 @@ import { Injectable, Logger } from '@nestjs/common';
|
|||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { GiteaService } from '../gitea/gitea.service';
|
import { GiteaService } from '../gitea/gitea.service';
|
||||||
|
|
||||||
|
interface ParsedSprint {
|
||||||
|
number: number;
|
||||||
|
name: string;
|
||||||
|
status: 'pending' | 'in_progress' | 'done';
|
||||||
|
}
|
||||||
|
|
||||||
interface ParsedTask {
|
interface ParsedTask {
|
||||||
taskId: string;
|
taskId: string;
|
||||||
title: string;
|
title: string;
|
||||||
assignee: string;
|
|
||||||
status: 'pending' | 'done';
|
status: 'pending' | 'done';
|
||||||
}
|
}
|
||||||
|
|
||||||
const QA_PATH_CANDIDATES = ['.plans/qa/', '.qa/'];
|
function parseSprintName(content: string, filename: string, number: number): string {
|
||||||
const HOTFIX_PATH_CANDIDATES = ['.plans/hotfix/', '.plans/sprints/'];
|
// 첫 번째 heading에서 이름 추출: # Sprint XXX — 이름 / # SPRINT-XXX: 이름
|
||||||
const SISTER_NAME_MAP: Record<string, string> = {
|
const headingMatch = content.match(/^#\s+(?:SPRINT-\d+|Sprint\s+\d+)[:\s—\-]+(.+)/m);
|
||||||
harang: 'harang',
|
|
||||||
하랑: 'harang',
|
|
||||||
하랑이: 'harang',
|
|
||||||
narang: 'narang',
|
|
||||||
나랑: 'narang',
|
|
||||||
나랑이: 'narang',
|
|
||||||
darang: 'darang',
|
|
||||||
다랑: 'darang',
|
|
||||||
다랑이: 'darang',
|
|
||||||
erang: 'erang',
|
|
||||||
이랑: 'erang',
|
|
||||||
이랑이: 'erang',
|
|
||||||
};
|
|
||||||
|
|
||||||
function parseSprintName(
|
|
||||||
content: string,
|
|
||||||
filename: string,
|
|
||||||
number: number,
|
|
||||||
): string {
|
|
||||||
const headingMatch = content.match(
|
|
||||||
/^#\s+(?:SPRINT-\d+|Sprint\s+\d+)[:\s—-]+(.+)/m,
|
|
||||||
);
|
|
||||||
if (headingMatch) return headingMatch[1].trim();
|
if (headingMatch) return headingMatch[1].trim();
|
||||||
return (
|
return `SPRINT-${String(number).padStart(3, '0')}`;
|
||||||
filename.replace('.md', '') || `SPRINT-${String(number).padStart(3, '0')}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTaskAssignee(taskLines: string[]): string {
|
function inferStatusFromQaContent(qaContent: string): 'done' | null {
|
||||||
for (const rawLine of taskLines) {
|
// QA 파일에 "결과: ✅ PASSED" 또는 "PASSED" 포함 시 done
|
||||||
const line = rawLine.trim();
|
if (/PASSED/i.test(qaContent)) return 'done';
|
||||||
const match = line.match(
|
return null;
|
||||||
/^-\s*(?:\*\*)?(?:담당|assignee)\s*:(?:\*\*)?\s*(.+)$/i,
|
|
||||||
);
|
|
||||||
if (!match) continue;
|
|
||||||
|
|
||||||
const assignee = match[1]
|
|
||||||
.trim()
|
|
||||||
.replace(/[()[\],]/g, ' ')
|
|
||||||
.split(/\s+/)
|
|
||||||
.find(
|
|
||||||
(token) =>
|
|
||||||
SISTER_NAME_MAP[token.toLowerCase()] ?? SISTER_NAME_MAP[token],
|
|
||||||
);
|
|
||||||
|
|
||||||
if (assignee) {
|
|
||||||
return (
|
|
||||||
SISTER_NAME_MAP[assignee.toLowerCase()] ?? SISTER_NAME_MAP[assignee]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'narang';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTasks(
|
function parseTasks(content: string, sprintStatus: 'pending' | 'in_progress' | 'done'): ParsedTask[] {
|
||||||
content: string,
|
|
||||||
sprintStatus: 'pending' | 'done',
|
|
||||||
): ParsedTask[] {
|
|
||||||
const lines = content.split(/\r?\n/);
|
const lines = content.split(/\r?\n/);
|
||||||
const tasks: ParsedTask[] = [];
|
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
|
const tasks: ParsedTask[] = [];
|
||||||
|
|
||||||
for (let index = 0; index < lines.length; index += 1) {
|
for (const rawLine of lines) {
|
||||||
const line = lines[index].trim();
|
const line = rawLine.trim();
|
||||||
let match: RegExpMatchArray | null = null;
|
let match: RegExpMatchArray | null = null;
|
||||||
let status: 'pending' | 'done' | null = null;
|
let status: 'pending' | 'done' | null = null;
|
||||||
|
|
||||||
|
// ### TASK-001: title
|
||||||
match = line.match(/^#{2,6}\s+(TASK-\d+[A-Z]?)\s*:\s*(.+)$/i);
|
match = line.match(/^#{2,6}\s+(TASK-\d+[A-Z]?)\s*:\s*(.+)$/i);
|
||||||
if (match) status = sprintStatus;
|
if (match) {
|
||||||
|
status = sprintStatus === 'done' ? 'done' : 'pending';
|
||||||
if (!match) {
|
|
||||||
match = line.match(
|
|
||||||
/^-\s*\[([ xX])\]\s*(TASK-\d+[A-Z]?)\s*[:-]?\s*(.+)$/i,
|
|
||||||
);
|
|
||||||
if (match) status = /x/i.test(match[1]) ? 'done' : 'pending';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - [x] TASK-001 title / - [ ] TASK-001 title
|
||||||
|
if (!match) {
|
||||||
|
match = line.match(/^-\s*\[([ xX])\]\s*(TASK-\d+[A-Z]?)\s*[:\-]?\s*(.+)$/i);
|
||||||
|
if (match) {
|
||||||
|
status = /x/i.test(match[1]) ? 'done' : 'pending';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// - TASK-001: title
|
||||||
if (!match) {
|
if (!match) {
|
||||||
match = line.match(/^-\s*(TASK-\d+[A-Z]?)\s*:\s*(.+)$/i);
|
match = line.match(/^-\s*(TASK-\d+[A-Z]?)\s*:\s*(.+)$/i);
|
||||||
if (match) status = sprintStatus;
|
if (match) {
|
||||||
|
status = sprintStatus === 'done' ? 'done' : 'pending';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TASK-001: title
|
||||||
if (!match) {
|
if (!match) {
|
||||||
match = line.match(/^(TASK-\d+[A-Z]?)\s*:\s*(.+)$/i);
|
match = line.match(/^(TASK-\d+[A-Z]?)\s*:\s*(.+)$/i);
|
||||||
if (match) status = sprintStatus;
|
if (match) {
|
||||||
|
status = sprintStatus === 'done' ? 'done' : 'pending';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match || !status) continue;
|
if (!match || !status) continue;
|
||||||
@@ -105,42 +72,13 @@ function parseTasks(
|
|||||||
const taskId = (match[1] ?? match[2]).toUpperCase();
|
const taskId = (match[1] ?? match[2]).toUpperCase();
|
||||||
const title = (match[2] ?? match[3] ?? '').trim();
|
const title = (match[2] ?? match[3] ?? '').trim();
|
||||||
if (!taskId || seen.has(taskId)) continue;
|
if (!taskId || seen.has(taskId)) continue;
|
||||||
|
|
||||||
const taskBlock: string[] = [];
|
|
||||||
for (let lookahead = index + 1; lookahead < lines.length; lookahead += 1) {
|
|
||||||
const nextLine = lines[lookahead].trim();
|
|
||||||
if (
|
|
||||||
/^#{2,6}\s+TASK-\d+[A-Z]?\s*:/i.test(nextLine) ||
|
|
||||||
/^-\s*\[?[ xX]?\]?\s*TASK-\d+[A-Z]?\s*[:-]?/i.test(nextLine) ||
|
|
||||||
/^TASK-\d+[A-Z]?\s*:/i.test(nextLine)
|
|
||||||
) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (/^##\s+/.test(nextLine) && !/^##\s+목표/.test(nextLine)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
taskBlock.push(lines[lookahead]);
|
|
||||||
}
|
|
||||||
|
|
||||||
seen.add(taskId);
|
seen.add(taskId);
|
||||||
tasks.push({
|
tasks.push({ taskId, title: title || taskId, status });
|
||||||
taskId,
|
|
||||||
title: title || taskId,
|
|
||||||
assignee: parseTaskAssignee(taskBlock),
|
|
||||||
status,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
function inferPassed(content: string | null): boolean {
|
|
||||||
if (!content) return false;
|
|
||||||
if (/passed\s*[:=]\s*true/i.test(content)) return true;
|
|
||||||
if (/passed\s*[:=]\s*false/i.test(content)) return false;
|
|
||||||
return /\bPASSED\b/i.test(content) && !/\bFAILED\b/i.test(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SprintSyncService {
|
export class SprintSyncService {
|
||||||
private readonly logger = new Logger(SprintSyncService.name);
|
private readonly logger = new Logger(SprintSyncService.name);
|
||||||
@@ -150,12 +88,8 @@ export class SprintSyncService {
|
|||||||
private readonly gitea: GiteaService,
|
private readonly gitea: GiteaService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async syncProjectSprints(
|
async syncProjectSprints(projectId: number): Promise<{ synced: number; created: number; updated: number }> {
|
||||||
projectId: number,
|
const project = await this.prisma.project.findUnique({ where: { id: projectId } });
|
||||||
): Promise<{ synced: number; created: number; updated: number }> {
|
|
||||||
const project = await this.prisma.project.findUnique({
|
|
||||||
where: { id: projectId },
|
|
||||||
});
|
|
||||||
if (!project) return { synced: 0, created: 0, updated: 0 };
|
if (!project) return { synced: 0, created: 0, updated: 0 };
|
||||||
|
|
||||||
const repoName = project.repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
const repoName = project.repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
||||||
@@ -163,68 +97,45 @@ export class SprintSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async syncAllProjectSprints(): Promise<{ projects: number; synced: number }> {
|
async syncAllProjectSprints(): Promise<{ projects: number; synced: number }> {
|
||||||
const projects = await this.prisma.project.findMany({
|
const projects = await this.prisma.project.findMany({ select: { id: true, repoUrl: true } });
|
||||||
select: { id: true, repoUrl: true },
|
|
||||||
});
|
|
||||||
let totalSynced = 0;
|
let totalSynced = 0;
|
||||||
|
|
||||||
for (const project of projects) {
|
for (const project of projects) {
|
||||||
const repoName =
|
const repoName = project.repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
||||||
project.repoUrl.replace(/\/+$/, '').split('/').pop() ?? '';
|
const r = await this.syncRepo(project.id, repoName);
|
||||||
const result = await this.syncRepo(project.id, repoName);
|
totalSynced += r.synced;
|
||||||
totalSynced += result.synced;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { projects: projects.length, synced: totalSynced };
|
return { projects: projects.length, synced: totalSynced };
|
||||||
}
|
}
|
||||||
|
|
||||||
private async syncRepo(
|
private async syncRepo(projectId: number, repoName: string): Promise<{ synced: number; created: number; updated: number }> {
|
||||||
projectId: number,
|
const [sprintFilePaths, qaFilePaths] = await Promise.all([
|
||||||
repoName: string,
|
|
||||||
): Promise<{ synced: number; created: number; updated: number }> {
|
|
||||||
const [sprintFilePaths, qaGroups, hotfixGroups] = await Promise.all([
|
|
||||||
this.gitea.getRepoTree(repoName, '.plans/sprints/'),
|
this.gitea.getRepoTree(repoName, '.plans/sprints/'),
|
||||||
Promise.all(
|
this.gitea.getRepoTree(repoName, '.qa/'),
|
||||||
QA_PATH_CANDIDATES.map((path) =>
|
|
||||||
this.gitea.getRepoTree(repoName, path),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Promise.all(
|
|
||||||
HOTFIX_PATH_CANDIDATES.map((path) =>
|
|
||||||
this.gitea.getRepoTree(repoName, path),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const sprintFiles = sprintFilePaths.filter((path) =>
|
const sprintFiles = sprintFilePaths.filter((f) => /SPRINT-\d+\.md$/i.test(f));
|
||||||
/SPRINT-\d+\.md$/i.test(path),
|
const qaFiles = qaFilePaths.filter((f) => /SPRINT-\d+-review-.*\.md$/i.test(f));
|
||||||
);
|
|
||||||
const qaFiles = Array.from(
|
|
||||||
new Set(
|
|
||||||
qaGroups
|
|
||||||
.flat()
|
|
||||||
.filter((path) => /SPRINT-\d+.*(?:review|qa).*\.md$/i.test(path)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const hotfixFiles = Array.from(
|
|
||||||
new Set(
|
|
||||||
hotfixGroups.flat().filter((path) => /HOTFIX-\d+\.md$/i.test(path)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!sprintFiles.length) {
|
if (!sprintFiles.length) {
|
||||||
this.logger.warn(`No sprint files found in ${repoName}/.plans/sprints/`);
|
this.logger.warn(`No sprint files found in ${repoName}/.plans/sprints/`);
|
||||||
return { synced: 0, created: 0, updated: 0 };
|
return { synced: 0, created: 0, updated: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QA 파일에서 PASSED 여부 수집: number → boolean
|
||||||
const passedMap = new Map<number, boolean>();
|
const passedMap = new Map<number, boolean>();
|
||||||
for (const qaPath of qaFiles) {
|
for (const qaPath of qaFiles) {
|
||||||
const numberMatch = qaPath.match(/SPRINT-(\d+)/i);
|
const numMatch = qaPath.match(/SPRINT-(\d+)-review/i);
|
||||||
if (!numberMatch) continue;
|
if (!numMatch) continue;
|
||||||
const sprintNumber = parseInt(numberMatch[1], 10);
|
const num = parseInt(numMatch[1], 10);
|
||||||
if (passedMap.get(sprintNumber)) continue;
|
if (passedMap.get(num)) continue; // 이미 통과 확인됨
|
||||||
|
|
||||||
const qaContent = await this.gitea.getRawFile(repoName, qaPath);
|
const qaContent = await this.gitea.getRawFile(repoName, qaPath);
|
||||||
if (inferPassed(qaContent)) passedMap.set(sprintNumber, true);
|
if (!qaContent) continue;
|
||||||
|
if (inferStatusFromQaContent(qaContent)) {
|
||||||
|
passedMap.set(num, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let created = 0;
|
let created = 0;
|
||||||
@@ -235,50 +146,51 @@ export class SprintSyncService {
|
|||||||
if (!content) continue;
|
if (!content) continue;
|
||||||
|
|
||||||
const filename = filePath.split('/').pop() ?? '';
|
const filename = filePath.split('/').pop() ?? '';
|
||||||
const numberMatch = filename.match(/SPRINT-(\d+)/i);
|
const numMatch = filename.match(/SPRINT-(\d+)/i);
|
||||||
if (!numberMatch) continue;
|
if (!numMatch) continue;
|
||||||
|
const number = parseInt(numMatch[1], 10);
|
||||||
const number = parseInt(numberMatch[1], 10);
|
|
||||||
const name = parseSprintName(content, filename, number);
|
const name = parseSprintName(content, filename, number);
|
||||||
const status: 'pending' | 'done' = passedMap.get(number)
|
|
||||||
? 'done'
|
// QA 통과 여부로 status 결정 (본문 전체 키워드 검색 금지)
|
||||||
: 'pending';
|
const status: 'pending' | 'done' = passedMap.get(number) ? 'done' : 'pending';
|
||||||
const parsedTasks = parseTasks(content, status);
|
const parsedTasks = parseTasks(content, status);
|
||||||
|
|
||||||
const existingSprint = await this.prisma.sprint.findFirst({
|
const existing = await this.prisma.sprint.findFirst({
|
||||||
where: { projectId, number },
|
where: { projectId, number },
|
||||||
});
|
});
|
||||||
let sprintId = existingSprint?.id ?? 0;
|
|
||||||
|
|
||||||
if (!existingSprint) {
|
let sprintId: number;
|
||||||
|
if (!existing) {
|
||||||
const createdSprint = await this.prisma.sprint.create({
|
const createdSprint = await this.prisma.sprint.create({
|
||||||
data: { projectId, number, name, status },
|
data: { projectId, number, name, status },
|
||||||
});
|
});
|
||||||
sprintId = createdSprint.id;
|
sprintId = createdSprint.id;
|
||||||
created += 1;
|
created++;
|
||||||
} else {
|
} else {
|
||||||
const updatedSprint = await this.prisma.sprint.update({
|
const updatedSprint = await this.prisma.sprint.update({
|
||||||
where: { id: existingSprint.id },
|
where: { id: existing.id },
|
||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
status: existingSprint.status === 'done' ? 'done' : status,
|
status: existing.status === 'done' ? 'done' : status,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
sprintId = updatedSprint.id;
|
sprintId = updatedSprint.id;
|
||||||
updated += 1;
|
updated++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sprint 문서 기준 Task upsert
|
||||||
for (const task of parsedTasks) {
|
for (const task of parsedTasks) {
|
||||||
const existingTask = await this.prisma.task.findFirst({
|
const existingTask = await this.prisma.task.findFirst({
|
||||||
where: { sprintId, taskId: task.taskId },
|
where: { sprintId, taskId: task.taskId },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existingTask) {
|
if (!existingTask) {
|
||||||
await this.prisma.task.create({
|
await this.prisma.task.create({
|
||||||
data: {
|
data: {
|
||||||
sprintId,
|
sprintId,
|
||||||
taskId: task.taskId,
|
taskId: task.taskId,
|
||||||
title: task.title,
|
title: task.title,
|
||||||
assignee: task.assignee,
|
assignee: 'narang',
|
||||||
status: task.status,
|
status: task.status,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -287,7 +199,6 @@ export class SprintSyncService {
|
|||||||
where: { id: existingTask.id },
|
where: { id: existingTask.id },
|
||||||
data: {
|
data: {
|
||||||
title: task.title,
|
title: task.title,
|
||||||
assignee: task.assignee,
|
|
||||||
status: existingTask.status === 'done' ? 'done' : task.status,
|
status: existingTask.status === 'done' ? 'done' : task.status,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -295,9 +206,7 @@ export class SprintSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(
|
this.logger.log(`${repoName}: ${sprintFiles.length} sprints, ${passedMap.size} QA passed → ${created} created, ${updated} updated`);
|
||||||
`${repoName}: ${sprintFiles.length} sprints, ${hotfixFiles.length} hotfix docs, ${passedMap.size} QA passed → ${created} created, ${updated} updated`,
|
|
||||||
);
|
|
||||||
return { synced: sprintFiles.length, created, updated };
|
return { synced: sprintFiles.length, created, updated };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ export class SettingsService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getAll() {
|
async getAll() {
|
||||||
const rows = await this.prisma.systemSettings.findMany({
|
const rows = await this.prisma.systemSettings.findMany({ orderBy: { key: 'asc' } });
|
||||||
orderBy: { key: 'asc' },
|
|
||||||
});
|
|
||||||
const merged = { ...DEFAULT_SETTINGS };
|
const merged = { ...DEFAULT_SETTINGS };
|
||||||
for (const row of rows) merged[row.key] = row.value;
|
for (const row of rows) merged[row.key] = row.value;
|
||||||
return merged;
|
return merged;
|
||||||
@@ -35,9 +33,7 @@ export class SettingsService {
|
|||||||
async saveAll(payload: Record<string, string>) {
|
async saveAll(payload: Record<string, string>) {
|
||||||
// DEFAULT_SETTINGS에 있는 키만 허용
|
// DEFAULT_SETTINGS에 있는 키만 허용
|
||||||
const allowed = Object.keys(DEFAULT_SETTINGS);
|
const allowed = Object.keys(DEFAULT_SETTINGS);
|
||||||
const entries = Object.entries(payload).filter(([key]) =>
|
const entries = Object.entries(payload).filter(([key]) => allowed.includes(key));
|
||||||
allowed.includes(key),
|
|
||||||
);
|
|
||||||
await this.prisma.$transaction(
|
await this.prisma.$transaction(
|
||||||
entries.map(([key, value]) =>
|
entries.map(([key, value]) =>
|
||||||
this.prisma.systemSettings.upsert({
|
this.prisma.systemSettings.upsert({
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ export class AvatarService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const files = [
|
const files = [
|
||||||
{ path: '~/.hermes/avatar.png', type: 'image/png' },
|
|
||||||
{ path: '~/.hermes/avatar.jpg', type: 'image/jpeg' },
|
|
||||||
{ path: '~/.hermes/avatar.jpeg', type: 'image/jpeg' },
|
|
||||||
{ path: '~/.hermes/avatar.webp', type: 'image/webp' },
|
|
||||||
{ path: '~/.openclaw/avatar.png', type: 'image/png' },
|
{ path: '~/.openclaw/avatar.png', type: 'image/png' },
|
||||||
{ path: '~/.openclaw/avatar.jpg', type: 'image/jpeg' },
|
{ path: '~/.openclaw/avatar.jpg', type: 'image/jpeg' },
|
||||||
{ path: '~/.openclaw/avatar.jpeg', type: 'image/jpeg' },
|
{ path: '~/.openclaw/avatar.jpeg', type: 'image/jpeg' },
|
||||||
|
|||||||
@@ -9,16 +9,9 @@ describe('SisterDetailService', () => {
|
|||||||
let service: SisterDetailService;
|
let service: SisterDetailService;
|
||||||
|
|
||||||
const mockSister = {
|
const mockSister = {
|
||||||
id: 2,
|
id: 2, name: 'narang', ip: '10.10.10.216', user: 'narang',
|
||||||
name: 'narang',
|
lxcId: 105, status: 'online', lastSeen: new Date(),
|
||||||
ip: '10.10.10.216',
|
sshKeyPath: null, createdAt: new Date(), updatedAt: new Date(),
|
||||||
user: 'narang',
|
|
||||||
lxcId: 105,
|
|
||||||
status: 'online',
|
|
||||||
lastSeen: new Date(),
|
|
||||||
sshKeyPath: null,
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockPrisma = {
|
const mockPrisma = {
|
||||||
@@ -42,9 +35,7 @@ describe('SisterDetailService', () => {
|
|||||||
{ provide: PrismaService, useValue: mockPrisma },
|
{ provide: PrismaService, useValue: mockPrisma },
|
||||||
{
|
{
|
||||||
provide: ConfigService,
|
provide: ConfigService,
|
||||||
useValue: {
|
useValue: { get: jest.fn().mockReturnValue('/home/narang/.ssh/id_rsa') },
|
||||||
get: jest.fn().mockReturnValue('/home/narang/.ssh/id_rsa'),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
@@ -67,9 +58,7 @@ describe('SisterDetailService', () => {
|
|||||||
it('getSisterConfig: sister 없으면 NotFoundException', async () => {
|
it('getSisterConfig: sister 없으면 NotFoundException', async () => {
|
||||||
mockPrisma.sisterConfig.findUnique.mockResolvedValue(null);
|
mockPrisma.sisterConfig.findUnique.mockResolvedValue(null);
|
||||||
|
|
||||||
await expect(service.getSisterConfig('narang')).rejects.toThrow(
|
await expect(service.getSisterConfig('narang')).rejects.toThrow(NotFoundException);
|
||||||
NotFoundException,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getSisterSessions: SSH 실패 시 빈 배열', async () => {
|
it('getSisterSessions: SSH 실패 시 빈 배열', async () => {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
|
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { SshService } from './ssh.service';
|
import { SshService } from './ssh.service';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
|
||||||
type SisterName = 'harang' | 'narang' | 'darang' | 'erang';
|
const SISTER_NAMES = ['harang', 'narang', 'darang', 'erang'] as const;
|
||||||
|
type SisterName = (typeof SISTER_NAMES)[number];
|
||||||
|
|
||||||
const SISTER_ROLES: Record<SisterName, string> = {
|
const SISTER_ROLES: Record<SisterName, string> = {
|
||||||
harang: 'Orchestrator',
|
harang: 'Orchestrator',
|
||||||
@@ -13,22 +14,12 @@ const SISTER_ROLES: Record<SisterName, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const SISTER_DESCRIPTIONS: Record<SisterName, string> = {
|
const SISTER_DESCRIPTIONS: Record<SisterName, string> = {
|
||||||
harang:
|
harang: '기획과 오케스트레이션. 스프린트를 설계하고 자매들에게 작업을 배분한다.',
|
||||||
'기획과 오케스트레이션. 스프린트를 설계하고 자매들에게 작업을 배분한다.',
|
|
||||||
narang: '코드 생성과 개발. 스프린트를 구현하고 PR을 만든다.',
|
narang: '코드 생성과 개발. 스프린트를 구현하고 PR을 만든다.',
|
||||||
darang: '품질 검증. 코드 리뷰와 보안 감사를 수행한다.',
|
darang: '품질 검증. 코드 리뷰와 보안 감사를 수행한다.',
|
||||||
erang: '인프라와 배포. 서버 관리, merge, 프로덕션 배포를 담당한다.',
|
erang: '인프라와 배포. 서버 관리, merge, 프로덕션 배포를 담당한다.',
|
||||||
};
|
};
|
||||||
|
|
||||||
function summarizeText(value?: string | null, maxLength = 120): string | null {
|
|
||||||
if (!value) return null;
|
|
||||||
|
|
||||||
const compact = value.replace(/\s+/g, ' ').trim();
|
|
||||||
if (!compact) return null;
|
|
||||||
if (compact.length <= maxLength) return compact;
|
|
||||||
return `${compact.slice(0, maxLength - 1)}…`;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SisterDetailService {
|
export class SisterDetailService {
|
||||||
private readonly logger = new Logger(SisterDetailService.name);
|
private readonly logger = new Logger(SisterDetailService.name);
|
||||||
@@ -48,36 +39,21 @@ export class SisterDetailService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
sshKeyPath,
|
sshKeyPath,
|
||||||
'WORKSPACE=~/.hermes/workspace; [ -d "$WORKSPACE" ] || WORKSPACE=~/.openclaw/workspace; for FILE in SOUL.md AGENTS.md; do if [ -f "$WORKSPACE/$FILE" ]; then printf "%s|present|%s\n" "$FILE" "$(wc -l < "$WORKSPACE/$FILE" 2>/dev/null || echo 0)"; else printf "%s|missing|0\n" "$FILE"; fi; done',
|
'cat ~/.openclaw/workspace/SOUL.md 2>/dev/null | head -60; echo "---AGENTS---"; cat ~/.openclaw/workspace/AGENTS.md 2>/dev/null | head -40',
|
||||||
);
|
);
|
||||||
|
|
||||||
const files = result.stdout
|
|
||||||
.split('\n')
|
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter((line) => line.length > 0)
|
|
||||||
.map((line) => {
|
|
||||||
const [file, status, lineCount] = line.split('|');
|
|
||||||
return {
|
|
||||||
file,
|
|
||||||
status,
|
|
||||||
lineCount: Number.parseInt(lineCount ?? '0', 10) || 0,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
role: SISTER_ROLES[name],
|
role: SISTER_ROLES[name],
|
||||||
description: SISTER_DESCRIPTIONS[name],
|
description: SISTER_DESCRIPTIONS[name],
|
||||||
files,
|
raw: result.stdout || '(설정 파일 없음)',
|
||||||
summary: `${files.filter((file) => file.status === 'present').length}/${files.length} protected config files detected`,
|
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
role: SISTER_ROLES[name],
|
role: SISTER_ROLES[name],
|
||||||
description: SISTER_DESCRIPTIONS[name],
|
description: SISTER_DESCRIPTIONS[name],
|
||||||
files: [],
|
raw: '(SSH 연결 불가)',
|
||||||
summary: '(SSH 연결 불가)',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,37 +67,20 @@ export class SisterDetailService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
sshKeyPath,
|
sshKeyPath,
|
||||||
'SESSION_DIR=~/.hermes/agents/main/sessions; [ -d "$SESSION_DIR" ] || SESSION_DIR=~/.openclaw/agents/main/sessions; ls -lt "$SESSION_DIR"/ 2>/dev/null | head -20 || echo ""',
|
'ls -lt ~/.openclaw/sessions/ 2>/dev/null | head -20 || echo ""',
|
||||||
);
|
);
|
||||||
|
|
||||||
const sessions = result.stdout
|
const lines = result.stdout.split('\n').filter((l) => l && !l.startsWith('total'));
|
||||||
.split('\n')
|
return lines.map((line) => {
|
||||||
.filter((line) => line && !line.startsWith('total'))
|
|
||||||
.map((line) => {
|
|
||||||
const parts = line.trim().split(/\s+/);
|
const parts = line.trim().split(/\s+/);
|
||||||
const label = parts[parts.length - 1] ?? '';
|
|
||||||
const modified = parts.slice(5, 8).join(' ');
|
|
||||||
const size = parts[4] ?? '0';
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: label,
|
name: parts[parts.length - 1] ?? '',
|
||||||
label,
|
modified: parts.slice(5, 8).join(' '),
|
||||||
status: [modified, size !== '0' ? `${size}B` : null]
|
size: parts[4] ?? '0',
|
||||||
.filter((part): part is string => Boolean(part))
|
|
||||||
.join(' · '),
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.filter((session) => session.label.length > 0);
|
|
||||||
|
|
||||||
return {
|
|
||||||
sessions,
|
|
||||||
total: sessions.length,
|
|
||||||
};
|
};
|
||||||
|
}).filter((s) => s.name && s.name !== '');
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return [];
|
||||||
sessions: [],
|
|
||||||
total: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,28 +93,13 @@ export class SisterDetailService {
|
|||||||
sister.ip,
|
sister.ip,
|
||||||
sister.user,
|
sister.user,
|
||||||
sshKeyPath,
|
sshKeyPath,
|
||||||
'AGENT_DIR=~/.hermes/workspace/agents; [ -d "$AGENT_DIR" ] || AGENT_DIR=~/.openclaw/workspace/agents; ls "$AGENT_DIR"/ 2>/dev/null || echo ""',
|
'ls ~/.openclaw/workspace/agents/ 2>/dev/null || echo ""',
|
||||||
);
|
);
|
||||||
|
|
||||||
const items = result.stdout
|
const agents = result.stdout.split('\n').filter((l) => l.trim().endsWith('.md'));
|
||||||
.split('\n')
|
return agents.map((a) => ({ name: a.trim().replace('.md', ''), file: a.trim() }));
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter((line) => line.endsWith('.md'))
|
|
||||||
.map((file) => ({
|
|
||||||
id: file.replace('.md', ''),
|
|
||||||
label: file.replace('.md', ''),
|
|
||||||
file,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return {
|
|
||||||
items,
|
|
||||||
total: items.length,
|
|
||||||
};
|
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return [];
|
||||||
items: [],
|
|
||||||
total: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,16 +113,7 @@ export class SisterDetailService {
|
|||||||
}),
|
}),
|
||||||
this.prisma.activityLog.count({ where: { sisterId: sister.id } }),
|
this.prisma.activityLog.count({ where: { sisterId: sister.id } }),
|
||||||
]);
|
]);
|
||||||
|
return { items: logs, total };
|
||||||
return {
|
|
||||||
items: logs.map((log) => ({
|
|
||||||
id: log.id,
|
|
||||||
action: log.action,
|
|
||||||
detail: summarizeText(log.detail),
|
|
||||||
createdAt: log.createdAt,
|
|
||||||
})),
|
|
||||||
total,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOrgData() {
|
async getOrgData() {
|
||||||
@@ -205,16 +140,14 @@ export class SisterDetailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getSisterRecord(name: SisterName) {
|
private async getSisterRecord(name: SisterName) {
|
||||||
const sister = await this.prisma.sisterConfig.findUnique({
|
const sister = await this.prisma.sisterConfig.findUnique({ where: { name } });
|
||||||
where: { name },
|
|
||||||
});
|
|
||||||
if (!sister) throw new NotFoundException(`Sister ${name} not found`);
|
if (!sister) throw new NotFoundException(`Sister ${name} not found`);
|
||||||
return sister;
|
return sister;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getKeyPath(): string {
|
private getKeyPath(): string {
|
||||||
const path = this.config.get<string>('SSH_KEY_PATH');
|
const p = this.config.get<string>('SSH_KEY_PATH');
|
||||||
if (!path) throw new Error('SSH_KEY_PATH is not set');
|
if (!p) throw new Error('SSH_KEY_PATH is not set');
|
||||||
return path;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,12 @@
|
|||||||
import {
|
import { Controller, Get, Param, Res } from '@nestjs/common';
|
||||||
Body,
|
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Param,
|
|
||||||
Post,
|
|
||||||
Res,
|
|
||||||
UseGuards,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import { JwtGuard } from '../auth/jwt.guard';
|
import { SistersService } from './sisters.service';
|
||||||
import { RoleGuard, Roles } from '../auth/role.guard';
|
import { SisterDetailService } from './sister-detail.service';
|
||||||
import { SisterNamePipe } from '../common/sister-name.pipe';
|
import { SisterNamePipe } from '../common/sister-name.pipe';
|
||||||
import type { SisterName } from '../common/sister-name.pipe';
|
import type { SisterName } from '../common/sister-name.pipe';
|
||||||
import { AvatarService } from './avatar.service';
|
import { AvatarService } from './avatar.service';
|
||||||
import { SisterDetailService } from './sister-detail.service';
|
|
||||||
import { SistersService } from './sisters.service';
|
|
||||||
|
|
||||||
@Controller('api/sisters')
|
@Controller('api/sisters')
|
||||||
@UseGuards(JwtGuard, RoleGuard)
|
|
||||||
@Roles('admin', 'viewer')
|
|
||||||
export class SistersController {
|
export class SistersController {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly sistersService: SistersService,
|
private readonly sistersService: SistersService,
|
||||||
@@ -26,51 +14,14 @@ export class SistersController {
|
|||||||
private readonly avatarService: AvatarService,
|
private readonly avatarService: AvatarService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get('runtime')
|
|
||||||
async getSistersRuntime() {
|
|
||||||
return this.sistersService.getAllSistersRuntime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async getSistersStatus() {
|
async getSistersStatus() {
|
||||||
const sisters = await this.sistersService.getAllSistersStatus();
|
return this.sistersService.getAllSistersStatus();
|
||||||
|
|
||||||
return sisters.map(({ id, name, lxcId, role, status, lastSeen, currentTask }) => ({
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
lxcId,
|
|
||||||
role,
|
|
||||||
status,
|
|
||||||
lastSeen,
|
|
||||||
currentTask,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get(':name/runtime')
|
|
||||||
async getSisterRuntime(@Param('name', SisterNamePipe) name: SisterName) {
|
|
||||||
return this.sistersService.getSisterRuntime(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@UseGuards(JwtGuard)
|
|
||||||
@Post(':name/chat')
|
|
||||||
async chatWithSister(
|
|
||||||
@Param('name', SisterNamePipe) name: SisterName,
|
|
||||||
@Body('message') message: string,
|
|
||||||
) {
|
|
||||||
return this.sistersService.sendChatMessage(name, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':name/system')
|
@Get(':name/system')
|
||||||
async getSystemInfo(@Param('name', SisterNamePipe) name: SisterName) {
|
async getSystemInfo(@Param('name', SisterNamePipe) name: SisterName) {
|
||||||
const system = await this.sistersService.getSystemInfo(name);
|
return this.sistersService.getSystemInfo(name as SisterName);
|
||||||
if (!system) return null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
uptime: system.uptime,
|
|
||||||
cpu: system.cpu,
|
|
||||||
memory: system.memory,
|
|
||||||
disk: system.disk,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':name/avatar')
|
@Get(':name/avatar')
|
||||||
@@ -78,38 +29,34 @@ export class SistersController {
|
|||||||
@Param('name', SisterNamePipe) name: SisterName,
|
@Param('name', SisterNamePipe) name: SisterName,
|
||||||
@Res() res: Response,
|
@Res() res: Response,
|
||||||
) {
|
) {
|
||||||
const sister = await this.sistersService.findByName(name);
|
const sister = await this.sistersService.findByName(name as SisterName);
|
||||||
if (!sister) {
|
if (!sister) {
|
||||||
return res.status(404).json({ message: 'Sister not found' });
|
return res.status(404).json({ message: 'Sister not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const avatar = await this.avatarService.getAvatar(sister);
|
const avatar = await this.avatarService.getAvatar(sister);
|
||||||
res.setHeader('Content-Type', avatar.contentType);
|
res.setHeader('Content-Type', avatar.contentType);
|
||||||
res.setHeader('Cache-Control', 'private, max-age=300');
|
res.setHeader('Cache-Control', 'public, max-age=300');
|
||||||
return res.send(avatar.data);
|
return res.send(avatar.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles('admin')
|
|
||||||
@Get(':name/config')
|
@Get(':name/config')
|
||||||
async getSisterConfig(@Param('name', SisterNamePipe) name: SisterName) {
|
async getSisterConfig(@Param('name', SisterNamePipe) name: SisterName) {
|
||||||
return this.sisterDetail.getSisterConfig(name);
|
return this.sisterDetail.getSisterConfig(name as SisterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles('admin')
|
|
||||||
@Get(':name/sessions')
|
@Get(':name/sessions')
|
||||||
async getSisterSessions(@Param('name', SisterNamePipe) name: SisterName) {
|
async getSisterSessions(@Param('name', SisterNamePipe) name: SisterName) {
|
||||||
return this.sisterDetail.getSisterSessions(name);
|
return this.sisterDetail.getSisterSessions(name as SisterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles('admin')
|
|
||||||
@Get(':name/subagents')
|
@Get(':name/subagents')
|
||||||
async getSisterSubagents(@Param('name', SisterNamePipe) name: SisterName) {
|
async getSisterSubagents(@Param('name', SisterNamePipe) name: SisterName) {
|
||||||
return this.sisterDetail.getSisterSubagents(name);
|
return this.sisterDetail.getSisterSubagents(name as SisterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles('admin')
|
|
||||||
@Get(':name/activity')
|
@Get(':name/activity')
|
||||||
async getSisterActivity(@Param('name', SisterNamePipe) name: SisterName) {
|
async getSisterActivity(@Param('name', SisterNamePipe) name: SisterName) {
|
||||||
return this.sisterDetail.getSisterActivityLog(name);
|
return this.sisterDetail.getSisterActivityLog(name as SisterName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { SistersController } from './sisters.controller';
|
import { SistersController } from './sisters.controller';
|
||||||
import { SistersService } from './sisters.service';
|
import { SistersService } from './sisters.service';
|
||||||
|
import { SisterDetailService } from './sister-detail.service';
|
||||||
import { SshService } from './ssh.service';
|
import { SshService } from './ssh.service';
|
||||||
import { PrismaModule } from '../prisma/prisma.module';
|
import { PrismaModule } from '../prisma/prisma.module';
|
||||||
import { SisterDetailService } from './sister-detail.service';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { AvatarService } from './avatar.service';
|
import { AvatarService } from './avatar.service';
|
||||||
import { ActivityModule } from '../activity/activity.module';
|
|
||||||
import { AuthModule } from '../auth/auth.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [PrismaModule, ActivityModule, AuthModule],
|
imports: [PrismaModule, ConfigModule],
|
||||||
controllers: [SistersController],
|
controllers: [SistersController],
|
||||||
providers: [SistersService, SshService, SisterDetailService, AvatarService],
|
providers: [SistersService, SisterDetailService, SshService, AvatarService],
|
||||||
exports: [SistersService, SshService, SisterDetailService, AvatarService],
|
exports: [SistersService, SisterDetailService, SshService, AvatarService],
|
||||||
})
|
})
|
||||||
export class SistersModule {}
|
export class SistersModule {}
|
||||||
|
|||||||
@@ -7,56 +7,13 @@ import { ConfigService } from '@nestjs/config';
|
|||||||
describe('SistersService', () => {
|
describe('SistersService', () => {
|
||||||
let service: SistersService;
|
let service: SistersService;
|
||||||
let sshService: jest.Mocked<SshService>;
|
let sshService: jest.Mocked<SshService>;
|
||||||
|
let prismaService: jest.Mocked<PrismaService>;
|
||||||
|
|
||||||
const mockSisters = [
|
const mockSisters = [
|
||||||
{
|
{ id: 1, name: 'harang', ip: '10.10.10.112', user: 'harang', lxcId: 104, sshKeyPath: null, lastSeen: null, status: 'unknown', createdAt: new Date(), updatedAt: new Date() },
|
||||||
id: 1,
|
{ id: 2, name: 'narang', ip: '10.10.10.216', user: 'narang', lxcId: 105, sshKeyPath: null, lastSeen: null, status: 'unknown', createdAt: new Date(), updatedAt: new Date() },
|
||||||
name: 'harang',
|
{ id: 3, name: 'darang', ip: '10.10.10.136', user: 'darang', lxcId: 106, sshKeyPath: null, lastSeen: null, status: 'unknown', createdAt: new Date(), updatedAt: new Date() },
|
||||||
ip: '10.10.10.112',
|
{ id: 4, name: 'erang', ip: '10.10.10.163', user: 'erang', lxcId: 107, sshKeyPath: null, lastSeen: null, status: 'unknown', createdAt: new Date(), updatedAt: new Date() },
|
||||||
user: 'harang',
|
|
||||||
lxcId: 104,
|
|
||||||
sshKeyPath: null,
|
|
||||||
lastSeen: null,
|
|
||||||
status: 'unknown',
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: 'narang',
|
|
||||||
ip: '10.10.10.216',
|
|
||||||
user: 'narang',
|
|
||||||
lxcId: 105,
|
|
||||||
sshKeyPath: null,
|
|
||||||
lastSeen: null,
|
|
||||||
status: 'unknown',
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
name: 'darang',
|
|
||||||
ip: '10.10.10.136',
|
|
||||||
user: 'darang',
|
|
||||||
lxcId: 106,
|
|
||||||
sshKeyPath: null,
|
|
||||||
lastSeen: null,
|
|
||||||
status: 'unknown',
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
name: 'erang',
|
|
||||||
ip: '10.10.10.163',
|
|
||||||
user: 'erang',
|
|
||||||
lxcId: 107,
|
|
||||||
sshKeyPath: null,
|
|
||||||
lastSeen: null,
|
|
||||||
status: 'unknown',
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -78,28 +35,22 @@ describe('SistersService', () => {
|
|||||||
{ provide: PrismaService, useValue: mockPrisma },
|
{ provide: PrismaService, useValue: mockPrisma },
|
||||||
{
|
{
|
||||||
provide: ConfigService,
|
provide: ConfigService,
|
||||||
useValue: {
|
useValue: { get: jest.fn().mockImplementation((key: string) => {
|
||||||
get: jest.fn().mockImplementation((key: string) => {
|
|
||||||
if (key === 'SSH_KEY_PATH') return '/home/narang/.ssh/id_rsa';
|
if (key === 'SSH_KEY_PATH') return '/home/narang/.ssh/id_rsa';
|
||||||
if (key === 'DATABASE_URL')
|
if (key === 'DATABASE_URL') return 'mysql://test:test@localhost:3306/test';
|
||||||
return 'mysql://test:test@localhost:3306/test';
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}),
|
}) },
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<SistersService>(SistersService);
|
service = module.get<SistersService>(SistersService);
|
||||||
sshService = module.get(SshService);
|
sshService = module.get(SshService);
|
||||||
|
prismaService = module.get(PrismaService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('SSH 성공 시 online 상태 반환', async () => {
|
it('SSH 성공 시 online 상태 반환', async () => {
|
||||||
sshService.executeCommand.mockResolvedValue({
|
sshService.executeCommand.mockResolvedValue({ stdout: 'active', stderr: '', code: 0 });
|
||||||
stdout: 'active',
|
|
||||||
stderr: '',
|
|
||||||
code: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await service.getAllSistersStatus();
|
const result = await service.getAllSistersStatus();
|
||||||
|
|
||||||
@@ -107,13 +58,11 @@ describe('SistersService', () => {
|
|||||||
expect(result[0].status).toBe('online');
|
expect(result[0].status).toBe('online');
|
||||||
expect(result[0].name).toBe('harang');
|
expect(result[0].name).toBe('harang');
|
||||||
expect(result[0].role).toBe('Orchestrator');
|
expect(result[0].role).toBe('Orchestrator');
|
||||||
expect(result[0]).not.toHaveProperty('ip'); // IP 노출 제거 확인
|
expect((result[0] as any).ip).toBeUndefined(); // IP 노출 제거 확인
|
||||||
});
|
});
|
||||||
|
|
||||||
it('SSH 실패 시 offline graceful fallback', async () => {
|
it('SSH 실패 시 offline graceful fallback', async () => {
|
||||||
sshService.executeCommand.mockRejectedValue(
|
sshService.executeCommand.mockRejectedValue(new Error('Connection refused'));
|
||||||
new Error('Connection refused'),
|
|
||||||
);
|
|
||||||
|
|
||||||
const result = await service.getAllSistersStatus();
|
const result = await service.getAllSistersStatus();
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +1,9 @@
|
|||||||
import {
|
import { Injectable, Logger, Optional } from '@nestjs/common';
|
||||||
BadRequestException,
|
|
||||||
Injectable,
|
|
||||||
Logger,
|
|
||||||
Optional,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { SshService } from './ssh.service';
|
import { SshService } from './ssh.service';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { ActivityService } from '../activity/activity.service';
|
import { ActivityService } from '../activity/activity.service';
|
||||||
|
|
||||||
export type RuntimeState =
|
|
||||||
| 'idle'
|
|
||||||
| 'thinking'
|
|
||||||
| 'tool_calling'
|
|
||||||
| 'speaking'
|
|
||||||
| 'error';
|
|
||||||
|
|
||||||
export interface RuntimeMessage {
|
|
||||||
id: string;
|
|
||||||
role: 'user' | 'assistant' | 'tool';
|
|
||||||
content: string;
|
|
||||||
ts: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RuntimeSubagent {
|
|
||||||
name: string;
|
|
||||||
state: RuntimeState;
|
|
||||||
updatedAt: number | null;
|
|
||||||
currentTask: string | null;
|
|
||||||
sessionLabel: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SisterRuntimeSnapshot {
|
|
||||||
name: string;
|
|
||||||
gatewayConnected: boolean;
|
|
||||||
mainState: RuntimeState;
|
|
||||||
currentTask: string | null;
|
|
||||||
activeSessionLabel: string | null;
|
|
||||||
activeSessionUpdatedAt: number | null;
|
|
||||||
controlSessionKey: string | null;
|
|
||||||
recentMessages: RuntimeMessage[];
|
|
||||||
subagents: RuntimeSubagent[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SisterConnectionState {
|
|
||||||
gateway: 'connected' | 'disconnected' | 'unknown';
|
|
||||||
runtime: 'connected' | 'disconnected' | 'unknown';
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SisterActivityState {
|
|
||||||
state: 'active' | 'idle' | 'unknown';
|
|
||||||
label: string | null;
|
|
||||||
lastActiveAt: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SisterWorkingState {
|
|
||||||
state: 'active' | 'idle' | 'unknown';
|
|
||||||
confidence: 'confirmed' | 'inferred' | 'none';
|
|
||||||
reason: string | null;
|
|
||||||
label: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SisterFreshness {
|
|
||||||
lastSnapshotAt: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SisterSource = 'live' | 'snapshot' | 'fallback';
|
|
||||||
|
|
||||||
export interface SisterStatus {
|
export interface SisterStatus {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -76,33 +13,6 @@ export interface SisterStatus {
|
|||||||
status: 'online' | 'offline' | 'working' | 'unknown';
|
status: 'online' | 'offline' | 'working' | 'unknown';
|
||||||
lastSeen: Date | null;
|
lastSeen: Date | null;
|
||||||
currentTask: string | null;
|
currentTask: string | null;
|
||||||
liveState: RuntimeState;
|
|
||||||
activeSessionLabel: string | null;
|
|
||||||
gatewayConnected: boolean;
|
|
||||||
subagents: RuntimeSubagent[];
|
|
||||||
connection: SisterConnectionState;
|
|
||||||
activity: SisterActivityState;
|
|
||||||
working: SisterWorkingState;
|
|
||||||
source: SisterSource;
|
|
||||||
freshness: SisterFreshness;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RuntimeProbeResult {
|
|
||||||
gatewayConnected?: boolean;
|
|
||||||
mainState?: RuntimeState;
|
|
||||||
currentTask?: string | null;
|
|
||||||
activeSessionLabel?: string | null;
|
|
||||||
activeSessionUpdatedAt?: number | null;
|
|
||||||
controlSessionKey?: string | null;
|
|
||||||
recentMessages?: RuntimeMessage[];
|
|
||||||
subagents?: RuntimeSubagent[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ChatSendResult {
|
|
||||||
ok: boolean;
|
|
||||||
status: string;
|
|
||||||
reply: string;
|
|
||||||
raw?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SISTER_ROLES: Record<string, string> = {
|
const SISTER_ROLES: Record<string, string> = {
|
||||||
@@ -112,17 +22,6 @@ const SISTER_ROLES: Record<string, string> = {
|
|||||||
erang: 'Infra Manager',
|
erang: 'Infra Manager',
|
||||||
};
|
};
|
||||||
|
|
||||||
function runtimeStateToStatus(
|
|
||||||
state: RuntimeState,
|
|
||||||
connected: boolean,
|
|
||||||
): 'online' | 'offline' | 'working' {
|
|
||||||
if (!connected || state === 'error') return 'offline';
|
|
||||||
if (state === 'thinking' || state === 'tool_calling' || state === 'speaking') {
|
|
||||||
return 'working';
|
|
||||||
}
|
|
||||||
return 'online';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SistersService {
|
export class SistersService {
|
||||||
private readonly logger = new Logger(SistersService.name);
|
private readonly logger = new Logger(SistersService.name);
|
||||||
@@ -135,7 +34,7 @@ export class SistersService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getAllSistersStatus(): Promise<SisterStatus[]> {
|
async getAllSistersStatus(): Promise<SisterStatus[]> {
|
||||||
const sisters = await this.prisma.sisterConfig.findMany({ orderBy: { id: 'asc' } });
|
const sisters = await this.prisma.sisterConfig.findMany();
|
||||||
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
||||||
if (!sshKeyPath) {
|
if (!sshKeyPath) {
|
||||||
throw new Error('SSH_KEY_PATH is not set. Check your .env file.');
|
throw new Error('SSH_KEY_PATH is not set. Check your .env file.');
|
||||||
@@ -150,83 +49,17 @@ export class SistersService {
|
|||||||
return result.value;
|
return result.value;
|
||||||
}
|
}
|
||||||
const sister = sisters[index];
|
const sister = sisters[index];
|
||||||
return this.buildOfflineStatus(sister);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAllSistersRuntime(): Promise<SisterRuntimeSnapshot[]> {
|
|
||||||
const sisters = await this.prisma.sisterConfig.findMany({ orderBy: { id: 'asc' } });
|
|
||||||
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
|
||||||
if (!sshKeyPath) {
|
|
||||||
throw new Error('SSH_KEY_PATH is not set. Check your .env file.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const results = await Promise.allSettled(
|
|
||||||
sisters.map(async (sister) => {
|
|
||||||
const runtime = await this.probeRuntime(sister, sshKeyPath, true);
|
|
||||||
return this.withRuntimeName(sister.name, runtime);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return results.map((result, index) => {
|
|
||||||
if (result.status === 'fulfilled') return result.value;
|
|
||||||
return this.buildRuntimeFallback(sisters[index].name);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getSisterRuntime(name: string): Promise<SisterRuntimeSnapshot> {
|
|
||||||
const sister = await this.findByName(name);
|
|
||||||
if (!sister) throw new Error(`Sister ${name} not found`);
|
|
||||||
|
|
||||||
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
|
||||||
if (!sshKeyPath) {
|
|
||||||
throw new Error('SSH_KEY_PATH is not set. Check your .env file.');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const runtime = await this.probeRuntime(sister, sshKeyPath, true);
|
|
||||||
return this.withRuntimeName(sister.name, runtime);
|
|
||||||
} catch {
|
|
||||||
return this.buildRuntimeFallback(sister.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async sendChatMessage(name: string, message: string) {
|
|
||||||
const trimmed = message.trim();
|
|
||||||
if (!trimmed) {
|
|
||||||
throw new BadRequestException('message is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
const sister = await this.findByName(name);
|
|
||||||
if (!sister) throw new Error(`Sister ${name} not found`);
|
|
||||||
|
|
||||||
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
|
||||||
if (!sshKeyPath) {
|
|
||||||
throw new Error('SSH_KEY_PATH is not set. Check your .env file.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const sendResult = await this.ssh.executeCommand(
|
|
||||||
sister.ip,
|
|
||||||
sister.user,
|
|
||||||
sshKeyPath,
|
|
||||||
this.buildAgentSendCommand(trimmed),
|
|
||||||
);
|
|
||||||
|
|
||||||
const parsed = this.parseRemoteJson<ChatSendResult>(sendResult.stdout);
|
|
||||||
if (!parsed?.ok) {
|
|
||||||
throw new Error(parsed?.raw || 'Failed to send message to sister runtime');
|
|
||||||
}
|
|
||||||
|
|
||||||
const runtime = await this.getSisterRuntime(name).catch(() =>
|
|
||||||
this.buildRuntimeFallback(name),
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ok: true,
|
id: sister.id,
|
||||||
reply: parsed.reply,
|
name: sister.name,
|
||||||
status: parsed.status,
|
user: sister.user,
|
||||||
runtime,
|
lxcId: sister.lxcId,
|
||||||
|
role: SISTER_ROLES[sister.name] ?? 'Unknown',
|
||||||
|
status: 'offline' as const,
|
||||||
|
lastSeen: sister.lastSeen,
|
||||||
|
currentTask: null,
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByName(name: string) {
|
async findByName(name: string) {
|
||||||
@@ -234,54 +67,16 @@ export class SistersService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSystemInfo(name: string) {
|
async getSystemInfo(name: string) {
|
||||||
const sister = await this.prisma.sisterConfig.findUnique({
|
const sister = await this.prisma.sisterConfig.findUnique({ where: { name } });
|
||||||
where: { name },
|
|
||||||
});
|
|
||||||
if (!sister) return null;
|
if (!sister) return null;
|
||||||
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
const sshKeyPath = this.config.get<string>('SSH_KEY_PATH');
|
||||||
if (!sshKeyPath) return null;
|
if (!sshKeyPath) return null;
|
||||||
|
|
||||||
const [uptimeRes, cpuRes, memRes, diskRes] = await Promise.all([
|
const [uptimeRes, cpuRes, memRes, diskRes] = await Promise.all([
|
||||||
this.ssh
|
this.ssh.executeCommand(sister.ip, sister.user, sshKeyPath, 'cat /proc/uptime 2>/dev/null || echo "0 0"').catch(() => ({ stdout: '0 0', stderr: '', code: 0 })),
|
||||||
.executeCommand(
|
this.ssh.executeCommand(sister.ip, sister.user, sshKeyPath, "top -bn1 | grep Cpu || echo '%Cpu(s): 0.0 us, 0.0 sy, 100.0 id'").catch(() => ({ stdout: '%Cpu(s): 0.0 us, 0.0 sy, 100.0 id', stderr: '', code: 0 })),
|
||||||
sister.ip,
|
this.ssh.executeCommand(sister.ip, sister.user, sshKeyPath, 'free -m | grep Mem || echo "Mem: 0 0 0 0 0 0"').catch(() => ({ stdout: 'Mem: 0 0 0 0 0 0', stderr: '', code: 0 })),
|
||||||
sister.user,
|
this.ssh.executeCommand(sister.ip, sister.user, sshKeyPath, "df -h / | tail -1 || echo '/dev/root 0G 0G 0G 0% /'").catch(() => ({ stdout: '/dev/root 0G 0G 0G 0% /', stderr: '', code: 0 })),
|
||||||
sshKeyPath,
|
|
||||||
'cat /proc/uptime 2>/dev/null || echo "0 0"',
|
|
||||||
)
|
|
||||||
.catch(() => ({ stdout: '0 0', stderr: '', code: 0 })),
|
|
||||||
this.ssh
|
|
||||||
.executeCommand(
|
|
||||||
sister.ip,
|
|
||||||
sister.user,
|
|
||||||
sshKeyPath,
|
|
||||||
"top -bn1 | grep Cpu || echo '%Cpu(s): 0.0 us, 0.0 sy, 100.0 id'",
|
|
||||||
)
|
|
||||||
.catch(() => ({
|
|
||||||
stdout: '%Cpu(s): 0.0 us, 0.0 sy, 100.0 id',
|
|
||||||
stderr: '',
|
|
||||||
code: 0,
|
|
||||||
})),
|
|
||||||
this.ssh
|
|
||||||
.executeCommand(
|
|
||||||
sister.ip,
|
|
||||||
sister.user,
|
|
||||||
sshKeyPath,
|
|
||||||
'free -m | grep Mem || echo "Mem: 0 0 0 0 0 0"',
|
|
||||||
)
|
|
||||||
.catch(() => ({ stdout: 'Mem: 0 0 0 0 0 0', stderr: '', code: 0 })),
|
|
||||||
this.ssh
|
|
||||||
.executeCommand(
|
|
||||||
sister.ip,
|
|
||||||
sister.user,
|
|
||||||
sshKeyPath,
|
|
||||||
"df -h / | tail -1 || echo '/dev/root 0G 0G 0G 0% /'",
|
|
||||||
)
|
|
||||||
.catch(() => ({
|
|
||||||
stdout: '/dev/root 0G 0G 0G 0% /',
|
|
||||||
stderr: '',
|
|
||||||
code: 0,
|
|
||||||
})),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -293,43 +88,35 @@ export class SistersService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async checkSisterStatus(
|
private async checkSisterStatus(
|
||||||
sister: {
|
sister: { id: number; name: string; ip: string; user: string; lxcId: number; lastSeen: Date | null; status: string },
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
ip: string;
|
|
||||||
user: string;
|
|
||||||
lxcId: number;
|
|
||||||
lastSeen: Date | null;
|
|
||||||
status: string;
|
|
||||||
},
|
|
||||||
sshKeyPath: string,
|
sshKeyPath: string,
|
||||||
): Promise<SisterStatus> {
|
): Promise<SisterStatus> {
|
||||||
try {
|
try {
|
||||||
const runtime = await this.probeRuntime(sister, sshKeyPath, false);
|
const result = await this.ssh.executeCommand(
|
||||||
const gatewayConnected = Boolean(runtime.gatewayConnected);
|
sister.ip,
|
||||||
const liveState = runtime.mainState ?? (gatewayConnected ? 'idle' : 'error');
|
sister.user,
|
||||||
const status = runtimeStateToStatus(liveState, gatewayConnected);
|
sshKeyPath,
|
||||||
|
'systemctl --user is-active openclaw-gateway 2>/dev/null || echo "inactive"',
|
||||||
|
);
|
||||||
|
|
||||||
|
const isActive = result.stdout.trim() === 'active';
|
||||||
|
const status: 'online' | 'offline' = isActive ? 'online' : 'offline';
|
||||||
const prevStatus = sister.status;
|
const prevStatus = sister.status;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const lastSeen = gatewayConnected ? now : sister.lastSeen;
|
|
||||||
|
|
||||||
await this.prisma.sisterConfig.update({
|
await this.prisma.sisterConfig.update({
|
||||||
where: { id: sister.id },
|
where: { id: sister.id },
|
||||||
data: { lastSeen, status },
|
data: { lastSeen: isActive ? now : sister.lastSeen, status },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (prevStatus !== status && this.activity) {
|
if (prevStatus !== status && this.activity) {
|
||||||
await this.activity
|
await this.activity.log({
|
||||||
.log({
|
|
||||||
sisterId: sister.id,
|
sisterId: sister.id,
|
||||||
action: 'status_changed',
|
action: 'status_changed',
|
||||||
detail: `[${sister.name}] status: ${prevStatus} → ${status}`,
|
detail: `[${sister.name}] status: ${prevStatus} → ${status}`,
|
||||||
})
|
}).catch(() => {});
|
||||||
.catch(() => {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const isActive = liveState === 'thinking' || liveState === 'tool_calling' || liveState === 'speaking';
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: sister.id,
|
id: sister.id,
|
||||||
name: sister.name,
|
name: sister.name,
|
||||||
@@ -337,87 +124,11 @@ export class SistersService {
|
|||||||
lxcId: sister.lxcId,
|
lxcId: sister.lxcId,
|
||||||
role: SISTER_ROLES[sister.name] ?? 'Unknown',
|
role: SISTER_ROLES[sister.name] ?? 'Unknown',
|
||||||
status,
|
status,
|
||||||
lastSeen,
|
lastSeen: isActive ? now : sister.lastSeen,
|
||||||
currentTask: runtime.currentTask ?? null,
|
currentTask: null,
|
||||||
liveState,
|
|
||||||
activeSessionLabel: runtime.activeSessionLabel ?? null,
|
|
||||||
gatewayConnected,
|
|
||||||
subagents: runtime.subagents ?? [],
|
|
||||||
connection: {
|
|
||||||
gateway: gatewayConnected ? 'connected' : 'disconnected',
|
|
||||||
runtime: gatewayConnected ? 'connected' : 'disconnected',
|
|
||||||
},
|
|
||||||
activity: {
|
|
||||||
state: isActive ? 'active' : 'idle',
|
|
||||||
label: runtime.activeSessionLabel ?? (isActive ? 'Active session' : 'No recent operator event'),
|
|
||||||
lastActiveAt: now.toISOString(),
|
|
||||||
},
|
|
||||||
working: {
|
|
||||||
state: isActive ? 'active' : 'idle',
|
|
||||||
confidence: isActive ? 'confirmed' : 'none',
|
|
||||||
reason: isActive ? 'active_session' : null,
|
|
||||||
label: runtime.currentTask ?? null,
|
|
||||||
},
|
|
||||||
source: 'live' as SisterSource,
|
|
||||||
freshness: {
|
|
||||||
lastSnapshotAt: now.toISOString(),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
this.logger.warn(`Failed to check status for ${sister.name}`);
|
this.logger.warn(`Failed to check status for ${sister.name}`);
|
||||||
return this.buildOfflineStatus(sister);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async probeRuntime(
|
|
||||||
sister: { name: string; ip: string; user: string },
|
|
||||||
sshKeyPath: string,
|
|
||||||
includeMessages: boolean,
|
|
||||||
): Promise<RuntimeProbeResult> {
|
|
||||||
const result = await this.ssh.executeCommand(
|
|
||||||
sister.ip,
|
|
||||||
sister.user,
|
|
||||||
sshKeyPath,
|
|
||||||
this.buildRuntimeProbeCommand(includeMessages),
|
|
||||||
);
|
|
||||||
|
|
||||||
const parsed = this.parseRemoteJson<RuntimeProbeResult>(result.stdout);
|
|
||||||
if (parsed) {
|
|
||||||
return parsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
const legacy = this.parseLegacyRuntimeResult(result.stdout);
|
|
||||||
if (legacy) {
|
|
||||||
return legacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(`Runtime probe returned invalid JSON for ${sister.name}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
private withRuntimeName(
|
|
||||||
name: string,
|
|
||||||
runtime: RuntimeProbeResult,
|
|
||||||
): SisterRuntimeSnapshot {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
gatewayConnected: Boolean(runtime.gatewayConnected),
|
|
||||||
mainState: runtime.mainState ?? 'error',
|
|
||||||
currentTask: runtime.currentTask ?? null,
|
|
||||||
activeSessionLabel: runtime.activeSessionLabel ?? null,
|
|
||||||
activeSessionUpdatedAt: runtime.activeSessionUpdatedAt ?? null,
|
|
||||||
controlSessionKey: runtime.controlSessionKey ?? null,
|
|
||||||
recentMessages: runtime.recentMessages ?? [],
|
|
||||||
subagents: runtime.subagents ?? [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildOfflineStatus(sister: {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
user: string;
|
|
||||||
lxcId: number;
|
|
||||||
lastSeen: Date | null;
|
|
||||||
}): SisterStatus {
|
|
||||||
return {
|
return {
|
||||||
id: sister.id,
|
id: sister.id,
|
||||||
name: sister.name,
|
name: sister.name,
|
||||||
@@ -427,396 +138,8 @@ export class SistersService {
|
|||||||
status: 'offline',
|
status: 'offline',
|
||||||
lastSeen: sister.lastSeen,
|
lastSeen: sister.lastSeen,
|
||||||
currentTask: null,
|
currentTask: null,
|
||||||
liveState: 'error',
|
|
||||||
activeSessionLabel: null,
|
|
||||||
gatewayConnected: false,
|
|
||||||
subagents: [],
|
|
||||||
connection: {
|
|
||||||
gateway: 'disconnected',
|
|
||||||
runtime: 'disconnected',
|
|
||||||
},
|
|
||||||
activity: {
|
|
||||||
state: 'unknown',
|
|
||||||
label: null,
|
|
||||||
lastActiveAt: sister.lastSeen?.toISOString() ?? null,
|
|
||||||
},
|
|
||||||
working: {
|
|
||||||
state: 'unknown',
|
|
||||||
confidence: 'none',
|
|
||||||
reason: null,
|
|
||||||
label: null,
|
|
||||||
},
|
|
||||||
source: 'snapshot' as SisterSource,
|
|
||||||
freshness: {
|
|
||||||
lastSnapshotAt: sister.lastSeen?.toISOString() ?? null,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildRuntimeFallback(name: string): SisterRuntimeSnapshot {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
gatewayConnected: false,
|
|
||||||
mainState: 'error',
|
|
||||||
currentTask: null,
|
|
||||||
activeSessionLabel: null,
|
|
||||||
activeSessionUpdatedAt: null,
|
|
||||||
controlSessionKey: null,
|
|
||||||
recentMessages: [],
|
|
||||||
subagents: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private parseRemoteJson<T>(stdout: string): T | null {
|
|
||||||
const trimmed = stdout.trim();
|
|
||||||
const start = trimmed.indexOf('{');
|
|
||||||
const end = trimmed.lastIndexOf('}');
|
|
||||||
if (start === -1 || end === -1 || end <= start) return null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return JSON.parse(trimmed.slice(start, end + 1)) as T;
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private parseLegacyRuntimeResult(stdout: string): RuntimeProbeResult | null {
|
|
||||||
const trimmed = stdout.trim();
|
|
||||||
if (trimmed === 'active') {
|
|
||||||
return {
|
|
||||||
gatewayConnected: true,
|
|
||||||
mainState: 'idle',
|
|
||||||
currentTask: null,
|
|
||||||
activeSessionLabel: null,
|
|
||||||
activeSessionUpdatedAt: null,
|
|
||||||
controlSessionKey: null,
|
|
||||||
recentMessages: [],
|
|
||||||
subagents: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trimmed === 'inactive') {
|
|
||||||
return {
|
|
||||||
gatewayConnected: false,
|
|
||||||
mainState: 'error',
|
|
||||||
currentTask: null,
|
|
||||||
activeSessionLabel: null,
|
|
||||||
activeSessionUpdatedAt: null,
|
|
||||||
controlSessionKey: null,
|
|
||||||
recentMessages: [],
|
|
||||||
subagents: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildRuntimeProbeCommand(includeMessages: boolean): string {
|
|
||||||
return `
|
|
||||||
GATEWAY_CONNECTED=0
|
|
||||||
if systemctl --user is-active hermes-agent >/dev/null 2>&1; then GATEWAY_CONNECTED=1; \
|
|
||||||
elif systemctl --user is-active hermes-gateway >/dev/null 2>&1; then GATEWAY_CONNECTED=1; \
|
|
||||||
elif pgrep -f "hermes.*gateway|hermes.*agent" >/dev/null 2>&1; then GATEWAY_CONNECTED=1; \
|
|
||||||
elif systemctl --user is-active openclaw-gateway >/dev/null 2>&1; then GATEWAY_CONNECTED=1; \
|
|
||||||
elif pgrep -f "openclaw.*gateway|openclaw.*agent" >/dev/null 2>&1; then GATEWAY_CONNECTED=1; fi
|
|
||||||
export GATEWAY_CONNECTED
|
|
||||||
if command -v python3 >/dev/null 2>&1; then
|
|
||||||
python3 - <<'PY'
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
INCLUDE_MESSAGES = ${includeMessages ? 'True' : 'False'}
|
|
||||||
MESSAGE_LIMIT = ${includeMessages ? '12' : '0'}
|
|
||||||
|
|
||||||
|
|
||||||
def pick_base():
|
|
||||||
for name in ('.hermes', '.openclaw'):
|
|
||||||
candidate = Path.home() / name
|
|
||||||
if candidate.exists():
|
|
||||||
return candidate
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def load_json(path: Path):
|
|
||||||
if not path.exists():
|
|
||||||
return {}
|
|
||||||
try:
|
|
||||||
return json.loads(path.read_text(errors='ignore'))
|
|
||||||
except Exception:
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_role(role):
|
|
||||||
if role in ('user', 'assistant'):
|
|
||||||
return role
|
|
||||||
if role in ('tool', 'toolResult'):
|
|
||||||
return 'tool'
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def extract_text(content):
|
|
||||||
if isinstance(content, str):
|
|
||||||
return content.strip()
|
|
||||||
parts = []
|
|
||||||
if isinstance(content, list):
|
|
||||||
for item in content:
|
|
||||||
if not isinstance(item, dict):
|
|
||||||
continue
|
|
||||||
item_type = item.get('type')
|
|
||||||
text = item.get('text') or item.get('input') or item.get('content') or ''
|
|
||||||
if item_type in ('text', 'input_text', 'output_text') and text:
|
|
||||||
parts.append(str(text).strip())
|
|
||||||
elif item_type == 'tool_call':
|
|
||||||
tool_name = item.get('name') or item.get('toolName') or 'tool'
|
|
||||||
parts.append(f'[{tool_name}]')
|
|
||||||
return ' '.join(part for part in parts if part).strip()
|
|
||||||
|
|
||||||
|
|
||||||
def compact(text, limit=160):
|
|
||||||
normalized = ' '.join((text or '').split())
|
|
||||||
if not normalized:
|
|
||||||
return ''
|
|
||||||
if normalized.startswith('A new session was started via /new or /reset.'):
|
|
||||||
return ''
|
|
||||||
if len(normalized) <= limit:
|
|
||||||
return normalized
|
|
||||||
return normalized[: limit - 1] + '…'
|
|
||||||
|
|
||||||
|
|
||||||
def read_recent_messages(session_file, limit):
|
|
||||||
if not session_file or limit <= 0:
|
|
||||||
return []
|
|
||||||
path = Path(session_file)
|
|
||||||
if not path.exists():
|
|
||||||
return []
|
|
||||||
|
|
||||||
out = []
|
|
||||||
try:
|
|
||||||
lines = path.read_text(errors='ignore').splitlines()
|
|
||||||
except Exception:
|
|
||||||
return []
|
|
||||||
|
|
||||||
for line in reversed(lines):
|
|
||||||
try:
|
|
||||||
payload = json.loads(line)
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
if payload.get('type') != 'message':
|
|
||||||
continue
|
|
||||||
message = payload.get('message') or {}
|
|
||||||
role = normalize_role(message.get('role'))
|
|
||||||
if not role:
|
|
||||||
continue
|
|
||||||
content = compact(extract_text(message.get('content')))
|
|
||||||
if not content:
|
|
||||||
continue
|
|
||||||
out.append(
|
|
||||||
{
|
|
||||||
'id': str(payload.get('id') or ''),
|
|
||||||
'role': role,
|
|
||||||
'content': content,
|
|
||||||
'ts': payload.get('timestamp') or message.get('timestamp'),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if len(out) >= limit:
|
|
||||||
break
|
|
||||||
|
|
||||||
out.reverse()
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
def pick_session(index, prefer_key=None):
|
|
||||||
if not isinstance(index, dict) or not index:
|
|
||||||
return None, None
|
|
||||||
if prefer_key and prefer_key in index:
|
|
||||||
return prefer_key, index.get(prefer_key)
|
|
||||||
items = sorted(index.items(), key=lambda item: item[1].get('updatedAt') or 0, reverse=True)
|
|
||||||
return items[0]
|
|
||||||
|
|
||||||
|
|
||||||
def get_label(entry):
|
|
||||||
if not isinstance(entry, dict):
|
|
||||||
return None
|
|
||||||
return entry.get('displayName') or (entry.get('origin') or {}).get('label') or entry.get('lastTo')
|
|
||||||
|
|
||||||
|
|
||||||
def latest_user_text(messages):
|
|
||||||
for item in reversed(messages):
|
|
||||||
if item.get('role') == 'user':
|
|
||||||
return item.get('content')
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def age_minutes(updated_at):
|
|
||||||
if not updated_at:
|
|
||||||
return 10 ** 9
|
|
||||||
return max(0, (int(__import__('time').time() * 1000) - int(updated_at)) // 60000)
|
|
||||||
|
|
||||||
|
|
||||||
def state_from(entry, messages, connected):
|
|
||||||
if not connected:
|
|
||||||
return 'error'
|
|
||||||
if not isinstance(entry, dict):
|
|
||||||
return 'idle'
|
|
||||||
|
|
||||||
status = entry.get('status') or ''
|
|
||||||
last_role = messages[-1]['role'] if messages else None
|
|
||||||
age_min = age_minutes(entry.get('updatedAt'))
|
|
||||||
|
|
||||||
if status == 'running':
|
|
||||||
if last_role == 'tool':
|
|
||||||
return 'tool_calling'
|
|
||||||
if last_role == 'assistant':
|
|
||||||
return 'speaking'
|
|
||||||
return 'thinking'
|
|
||||||
|
|
||||||
if age_min <= 2:
|
|
||||||
if last_role == 'assistant':
|
|
||||||
return 'speaking'
|
|
||||||
if last_role == 'tool':
|
|
||||||
return 'tool_calling'
|
|
||||||
if last_role == 'user':
|
|
||||||
return 'thinking'
|
|
||||||
|
|
||||||
if age_min <= 15 and last_role == 'assistant':
|
|
||||||
return 'speaking'
|
|
||||||
|
|
||||||
return 'idle'
|
|
||||||
|
|
||||||
|
|
||||||
payload = {
|
|
||||||
'gatewayConnected': os.environ.get('GATEWAY_CONNECTED') == '1',
|
|
||||||
'mainState': 'error',
|
|
||||||
'currentTask': None,
|
|
||||||
'activeSessionLabel': None,
|
|
||||||
'activeSessionUpdatedAt': None,
|
|
||||||
'controlSessionKey': None,
|
|
||||||
'recentMessages': [],
|
|
||||||
'subagents': [],
|
|
||||||
}
|
|
||||||
|
|
||||||
base = pick_base()
|
|
||||||
if not base:
|
|
||||||
print(json.dumps(payload, ensure_ascii=False))
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
agents_root = base / 'agents'
|
|
||||||
main_index = load_json(agents_root / 'main' / 'sessions' / 'sessions.json')
|
|
||||||
active_key, active_entry = pick_session(main_index)
|
|
||||||
control_key, control_entry = pick_session(main_index, 'agent:main:main')
|
|
||||||
active_messages = read_recent_messages((active_entry or {}).get('sessionFile'), 8)
|
|
||||||
control_messages = read_recent_messages(
|
|
||||||
(control_entry or active_entry or {}).get('sessionFile'),
|
|
||||||
MESSAGE_LIMIT if INCLUDE_MESSAGES else 0,
|
|
||||||
)
|
|
||||||
|
|
||||||
payload['mainState'] = state_from(active_entry, active_messages, payload['gatewayConnected'])
|
|
||||||
payload['currentTask'] = latest_user_text(active_messages) or get_label(active_entry)
|
|
||||||
payload['activeSessionLabel'] = get_label(active_entry)
|
|
||||||
payload['activeSessionUpdatedAt'] = (active_entry or {}).get('updatedAt')
|
|
||||||
payload['controlSessionKey'] = control_key or active_key
|
|
||||||
payload['recentMessages'] = control_messages
|
|
||||||
|
|
||||||
subagent_names = set()
|
|
||||||
workspace_agents = base / 'workspace' / 'agents'
|
|
||||||
if workspace_agents.exists():
|
|
||||||
subagent_names.update(path.stem for path in workspace_agents.glob('*.md'))
|
|
||||||
if agents_root.exists():
|
|
||||||
subagent_names.update(
|
|
||||||
path.name for path in agents_root.iterdir() if path.is_dir() and path.name != 'main'
|
|
||||||
)
|
|
||||||
|
|
||||||
for subagent in sorted(subagent_names):
|
|
||||||
sub_index = load_json(agents_root / subagent / 'sessions' / 'sessions.json')
|
|
||||||
_, sub_entry = pick_session(sub_index)
|
|
||||||
sub_messages = read_recent_messages((sub_entry or {}).get('sessionFile'), 4)
|
|
||||||
payload['subagents'].append(
|
|
||||||
{
|
|
||||||
'name': subagent,
|
|
||||||
'state': state_from(sub_entry, sub_messages, payload['gatewayConnected']),
|
|
||||||
'updatedAt': (sub_entry or {}).get('updatedAt'),
|
|
||||||
'currentTask': latest_user_text(sub_messages) or get_label(sub_entry),
|
|
||||||
'sessionLabel': get_label(sub_entry),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
print(json.dumps(payload, ensure_ascii=False))
|
|
||||||
PY
|
|
||||||
else
|
|
||||||
printf '%s' '{"gatewayConnected":false,"mainState":"error","currentTask":null,"activeSessionLabel":null,"activeSessionUpdatedAt":null,"controlSessionKey":null,"recentMessages":[],"subagents":[]}'
|
|
||||||
fi`.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildAgentSendCommand(message: string): string {
|
|
||||||
const messageB64 = Buffer.from(message, 'utf8').toString('base64');
|
|
||||||
|
|
||||||
return `
|
|
||||||
export MSG_B64='${messageB64}'
|
|
||||||
if command -v python3 >/dev/null 2>&1 && command -v openclaw >/dev/null 2>&1; then
|
|
||||||
python3 - <<'PY'
|
|
||||||
import base64
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
message = base64.b64decode(os.environ['MSG_B64']).decode('utf-8')
|
|
||||||
proc = subprocess.run(
|
|
||||||
[
|
|
||||||
'openclaw',
|
|
||||||
'agent',
|
|
||||||
'--agent',
|
|
||||||
'main',
|
|
||||||
'--message',
|
|
||||||
message,
|
|
||||||
'--json',
|
|
||||||
'--timeout',
|
|
||||||
'120',
|
|
||||||
],
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.STDOUT,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
out = proc.stdout or ''
|
|
||||||
|
|
||||||
start = out.find('{')
|
|
||||||
end = out.rfind('}')
|
|
||||||
payload = {}
|
|
||||||
if start != -1 and end != -1 and end > start:
|
|
||||||
try:
|
|
||||||
payload = json.loads(out[start : end + 1])
|
|
||||||
except Exception:
|
|
||||||
payload = {}
|
|
||||||
|
|
||||||
result = payload.get('result') if isinstance(payload.get('result'), dict) else {}
|
|
||||||
payloads = result.get('payloads') if isinstance(result.get('payloads'), list) else []
|
|
||||||
texts = []
|
|
||||||
for item in payloads:
|
|
||||||
if not isinstance(item, dict):
|
|
||||||
continue
|
|
||||||
text = item.get('text') or item.get('message') or item.get('content')
|
|
||||||
if isinstance(text, str) and text.strip():
|
|
||||||
texts.append(text.strip())
|
|
||||||
|
|
||||||
reply = '\n\n'.join(texts).strip()
|
|
||||||
if not reply and proc.returncode == 0:
|
|
||||||
reply = str(payload.get('summary') or '응답 완료').strip()
|
|
||||||
|
|
||||||
print(
|
|
||||||
json.dumps(
|
|
||||||
{
|
|
||||||
'ok': proc.returncode == 0,
|
|
||||||
'status': payload.get('status') or ('completed' if proc.returncode == 0 else 'failed'),
|
|
||||||
'reply': reply,
|
|
||||||
'raw': out[-4000:],
|
|
||||||
},
|
|
||||||
ensure_ascii=False,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
PY
|
|
||||||
else
|
|
||||||
printf '%s' '{"ok":false,"status":"failed","reply":"","raw":"openclaw runtime unavailable"}'
|
|
||||||
fi`.trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseUptime(stdout: string) {
|
private parseUptime(stdout: string) {
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
import {
|
import { Controller, Get, Post, Patch, Param, Body, ParseIntPipe } from '@nestjs/common';
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Patch,
|
|
||||||
Param,
|
|
||||||
Body,
|
|
||||||
ParseIntPipe,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { TasksService, CreateSprintDto, UpdateTaskDto } from './tasks.service';
|
import { TasksService, CreateSprintDto, UpdateTaskDto } from './tasks.service';
|
||||||
|
|
||||||
@Controller('api')
|
@Controller('api')
|
||||||
|
|||||||
@@ -8,27 +8,15 @@ describe('TasksService', () => {
|
|||||||
let service: TasksService;
|
let service: TasksService;
|
||||||
|
|
||||||
const mockTask = {
|
const mockTask = {
|
||||||
id: 1,
|
id: 1, taskId: 'TASK-001', title: 'Test', assignee: 'narang',
|
||||||
taskId: 'TASK-001',
|
status: 'pending', iteration: 0, sprintId: 1,
|
||||||
title: 'Test',
|
createdAt: new Date(), updatedAt: new Date(),
|
||||||
assignee: 'narang',
|
|
||||||
status: 'pending',
|
|
||||||
iteration: 0,
|
|
||||||
sprintId: 1,
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockSprint = {
|
const mockSprint = {
|
||||||
id: 1,
|
id: 1, projectId: 1, number: 1, name: 'Sprint 001',
|
||||||
projectId: 1,
|
status: 'in_progress', startedAt: null, completedAt: null,
|
||||||
number: 1,
|
createdAt: new Date(), updatedAt: new Date(),
|
||||||
name: 'Sprint 001',
|
|
||||||
status: 'in_progress',
|
|
||||||
startedAt: null,
|
|
||||||
completedAt: null,
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
tasks: [mockTask],
|
tasks: [mockTask],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,9 +57,7 @@ describe('TasksService', () => {
|
|||||||
it('getTaskLedger: sprint + task + progress 반환', async () => {
|
it('getTaskLedger: sprint + task + progress 반환', async () => {
|
||||||
mockPrisma.project.findUnique.mockResolvedValue({
|
mockPrisma.project.findUnique.mockResolvedValue({
|
||||||
id: 1,
|
id: 1,
|
||||||
sprints: [
|
sprints: [{ ...mockSprint, tasks: [{ ...mockTask, status: 'done' }, mockTask] }],
|
||||||
{ ...mockSprint, tasks: [{ ...mockTask, status: 'done' }, mockTask] },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await service.getTaskLedger(1);
|
const result = await service.getTaskLedger(1);
|
||||||
@@ -81,15 +67,8 @@ describe('TasksService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('updateTask: 상태 변경 시 ActivityLog 기록', async () => {
|
it('updateTask: 상태 변경 시 ActivityLog 기록', async () => {
|
||||||
mockPrisma.task.findUnique.mockResolvedValue({
|
mockPrisma.task.findUnique.mockResolvedValue({ ...mockTask, status: 'in_progress' });
|
||||||
...mockTask,
|
mockPrisma.task.update.mockResolvedValue({ ...mockTask, status: 'done', sprintId: 1 });
|
||||||
status: 'in_progress',
|
|
||||||
});
|
|
||||||
mockPrisma.task.update.mockResolvedValue({
|
|
||||||
...mockTask,
|
|
||||||
status: 'done',
|
|
||||||
sprintId: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
await service.updateTask(1, { status: 'done' });
|
await service.updateTask(1, { status: 'done' });
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,7 @@ export class CreateSprintDto {
|
|||||||
name!: string;
|
name!: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VALID_STATUSES = [
|
const VALID_STATUSES = ['pending', 'in_progress', 'review', 'done', 'failed', 'blocked', 'escalated'] as const;
|
||||||
'pending',
|
|
||||||
'in_progress',
|
|
||||||
'review',
|
|
||||||
'done',
|
|
||||||
'failed',
|
|
||||||
'blocked',
|
|
||||||
'escalated',
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export class UpdateTaskDto {
|
export class UpdateTaskDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@@ -66,21 +58,14 @@ export class TasksService {
|
|||||||
startedAt: sprint.startedAt,
|
startedAt: sprint.startedAt,
|
||||||
completedAt: sprint.completedAt,
|
completedAt: sprint.completedAt,
|
||||||
tasks: sprint.tasks,
|
tasks: sprint.tasks,
|
||||||
progress:
|
progress: sprint.tasks.length > 0
|
||||||
sprint.tasks.length > 0
|
? Math.round(sprint.tasks.filter((t) => t.status === 'done').length / sprint.tasks.length * 100)
|
||||||
? Math.round(
|
|
||||||
(sprint.tasks.filter((t) => t.status === 'done').length /
|
|
||||||
sprint.tasks.length) *
|
|
||||||
100,
|
|
||||||
)
|
|
||||||
: 0,
|
: 0,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async createSprint(projectId: number, dto: CreateSprintDto) {
|
async createSprint(projectId: number, dto: CreateSprintDto) {
|
||||||
const project = await this.prisma.project.findUnique({
|
const project = await this.prisma.project.findUnique({ where: { id: projectId } });
|
||||||
where: { id: projectId },
|
|
||||||
});
|
|
||||||
if (!project) throw new NotFoundException(`Project ${projectId} not found`);
|
if (!project) throw new NotFoundException(`Project ${projectId} not found`);
|
||||||
|
|
||||||
const sprint = await this.prisma.sprint.create({
|
const sprint = await this.prisma.sprint.create({
|
||||||
@@ -105,8 +90,7 @@ export class TasksService {
|
|||||||
where: { id: taskId },
|
where: { id: taskId },
|
||||||
data: {
|
data: {
|
||||||
...dto,
|
...dto,
|
||||||
iteration:
|
iteration: dto.status && dto.status !== prevStatus && prevStatus !== 'pending'
|
||||||
dto.status && dto.status !== prevStatus && prevStatus !== 'pending'
|
|
||||||
? { increment: 1 }
|
? { increment: 1 }
|
||||||
: undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# QUALITY SCORE
|
|
||||||
|
|
||||||
## 현재 기준
|
|
||||||
- 문서 선작성/선push: 필수
|
|
||||||
- 나랑 구현 브랜치 분리: 필수
|
|
||||||
- 다랑 QA 문서화: 필수
|
|
||||||
- 검증 후 main merge: 필수
|
|
||||||
- main 배포 가능 상태 유지: 필수
|
|
||||||
|
|
||||||
## Sprint 014 집중 항목
|
|
||||||
- Hermes 경로 반영 정확도
|
|
||||||
- 프로젝트 진행률 계산 정확도
|
|
||||||
- 모바일 프로젝트/자매 페이지 가독성
|
|
||||||
- 아바타 fallback 안정성
|
|
||||||
- 배포 플로우 표현 일관성
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
# 하나랑 오피스 대시보드 PRD
|
|
||||||
|
|
||||||
## 제품명
|
|
||||||
하나랑 오피스 대시보드
|
|
||||||
|
|
||||||
## 한 줄 정의
|
|
||||||
OpenClaw 4자매와 서브에이전트 협업을 2D 등축 투영 오피스로 시각화하고, 채팅/파이프라인/서버 헬스를 함께 운영하는 멀티에이전트 관제 프론트엔드.
|
|
||||||
|
|
||||||
## 배경
|
|
||||||
기존 하나랑 대시보드는 운영 정보는 잘 보여주지만, 4자매와 서브에이전트가 실제로 어떻게 협업하는지 한눈에 느끼기엔 한계가 있어.
|
|
||||||
|
|
||||||
자기야가 원하는 건 단순 상태 카드가 아니라:
|
|
||||||
- 누가 자기 자리에서 대기 중인지
|
|
||||||
- 누가 회의실로 이동했는지
|
|
||||||
- 어떤 서브에이전트가 어떤 워크플로우에서 일하고 있는지
|
|
||||||
- 지금 QA 루프인지 배포 직전인지
|
|
||||||
를 `오피스`라는 직관적인 은유로 읽는 화면이야.
|
|
||||||
|
|
||||||
## 제품 목표
|
|
||||||
1. 4자매 메인 에이전트와 17개 서브에이전트, 총 21개 에이전트를 하나의 세계관 안에서 시각화한다.
|
|
||||||
2. 4자매 독립 Gateway WebSocket을 통해 실시간 상태를 반영한다.
|
|
||||||
3. Lobster 워크플로우와 Discord handoff를 자연스럽게 한 화면에 묶는다.
|
|
||||||
4. 직접 채팅, 파이프라인 현황, 서버 헬스까지 운영 도구를 통합한다.
|
|
||||||
|
|
||||||
## 핵심 사용자
|
|
||||||
- 자기야: 전체 파이프라인 운영 책임자
|
|
||||||
- 하랑이: Planning / handoff orchestration
|
|
||||||
- 나랑이: 구현 상태 추적
|
|
||||||
- 다랑이: QA 루프 / blocker 판단
|
|
||||||
- 이랑이: 배포 / 인프라 점검
|
|
||||||
|
|
||||||
## 핵심 시나리오
|
|
||||||
### 시나리오 1: 현재 누가 일하고 있는지 한눈에 보기
|
|
||||||
자기야가 메인 화면에 들어오면, 하랑/나랑/다랑/이랑 좌석과 주변 서브에이전트 상태를 보고 즉시 현재 국면을 판단한다.
|
|
||||||
|
|
||||||
### 시나리오 2: 구현 → QA → 배포 흐름 확인
|
|
||||||
나랑이 쪽 서브에이전트가 활발히 움직이다가, 다랑이 회의실로 연결선이 넘어가고, 승인되면 이랑이 인프라 영역으로 흐름이 넘어가는 걸 본다.
|
|
||||||
|
|
||||||
### 시나리오 3: 특정 자매와 직접 대화
|
|
||||||
자기야가 하랑이나 나랑이를 선택해서 direct chat을 열고 작업을 지시한다.
|
|
||||||
|
|
||||||
### 시나리오 4: 서버/헬스 이상 감지
|
|
||||||
대시보드 한쪽 패널에서 Gateway 연결, Dev 서버, Docker 상태 이상을 바로 감지한다.
|
|
||||||
|
|
||||||
## 기능 요구사항
|
|
||||||
### 필수
|
|
||||||
1. 4자매 Gateway WebSocket 연결
|
|
||||||
2. 2D 등축 투영 오피스 메인 화면
|
|
||||||
3. 메인 에이전트 4명 고정 좌석
|
|
||||||
4. 서브에이전트 동적 이동/상태 표시
|
|
||||||
5. 상태: `idle`, `thinking`, `tool_calling`, `speaking`, `error`
|
|
||||||
6. 협업 연결선 / 회의실 이동 시각화
|
|
||||||
7. 자매 선택 직접 채팅 인터페이스
|
|
||||||
8. Lobster 워크플로우 / 스프린트 / 사이클 패널
|
|
||||||
9. 서버 상태 패널 (4자매 + Dev + Docker)
|
|
||||||
|
|
||||||
### 중요
|
|
||||||
10. live / snapshot / fallback 구분
|
|
||||||
11. 실브라우저/모바일 대응
|
|
||||||
12. 기존 하나랑 대시보드 운영 패널과의 연속성 유지
|
|
||||||
|
|
||||||
## 정보 구조
|
|
||||||
### 메인 오피스 화면
|
|
||||||
- 좌측 또는 중앙: 오피스 씬
|
|
||||||
- 우측: 선택 에이전트 detail / chat / workflow
|
|
||||||
- 하단 또는 보조 패널: 서버 헬스 / 최근 handoff / sprint state
|
|
||||||
|
|
||||||
### 오피스 씬 요소
|
|
||||||
- 하랑이 데스크
|
|
||||||
- 나랑이 데스크
|
|
||||||
- 다랑이 데스크
|
|
||||||
- 이랑이 데스크
|
|
||||||
- 회의실
|
|
||||||
- 임시 작업석
|
|
||||||
- 인프라/서버 존
|
|
||||||
- 서브에이전트 이동 경로
|
|
||||||
|
|
||||||
### 채팅
|
|
||||||
- 자매 선택 탭
|
|
||||||
- 메시지 히스토리
|
|
||||||
- 입력창
|
|
||||||
- tool call 상태 / streaming 표시
|
|
||||||
|
|
||||||
### 운영 패널
|
|
||||||
- active workflow
|
|
||||||
- current sprint
|
|
||||||
- review loop
|
|
||||||
- deploy gate
|
|
||||||
- server health
|
|
||||||
|
|
||||||
## 데이터 소스
|
|
||||||
- 4자매 Gateway WebSocket
|
|
||||||
- activity log
|
|
||||||
- workflow state
|
|
||||||
- session/chat API
|
|
||||||
- admin/system/health API
|
|
||||||
|
|
||||||
## 기술 원칙
|
|
||||||
- 기존 Next.js + styled-components 유지
|
|
||||||
- Backend는 기존 Nest.js + Prisma 유지
|
|
||||||
- WebSocket은 OpenClaw Gateway 기준
|
|
||||||
- 필요 시 polling reconciliation 허용
|
|
||||||
- fake 데이터 하드코딩 금지
|
|
||||||
|
|
||||||
## 비기능 요구사항
|
|
||||||
- 첫 화면에서 현재 협업 구조 이해 가능
|
|
||||||
- 과한 애니메이션 금지
|
|
||||||
- 모바일에서도 핵심 흐름 유지
|
|
||||||
- 데이터 소스 구분이 명확해야 함
|
|
||||||
|
|
||||||
## 성공 기준
|
|
||||||
- 자기야가 메인 화면만 보고 현재 상태를 설명할 수 있음
|
|
||||||
- 4자매/서브에이전트 구조가 카드보다 더 직관적으로 읽힘
|
|
||||||
- 채팅/워크플로우/서버 패널이 따로 놀지 않음
|
|
||||||
- live / snapshot / fallback 구분이 사용자에게 정직하게 보임
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
# Project Information Architecture
|
|
||||||
|
|
||||||
## 목적
|
|
||||||
프로젝트 화면은 단순 repo 목록이 아니라, 하나랑 파이프라인의 상태를 읽는 운영 화면이어야 해.
|
|
||||||
|
|
||||||
## 프로젝트 정보 구조
|
|
||||||
1. Overview
|
|
||||||
- 프로젝트명 / 상태 / repo 링크 / 마지막 업데이트
|
|
||||||
2. Delivery Flow
|
|
||||||
- Planning → Implementation → QA → Merge → Deploy
|
|
||||||
3. Sprint Ledger
|
|
||||||
- Sprint별 진행률 / 태스크 수 / 완료 수 / 현재 단계
|
|
||||||
4. Hotfix History
|
|
||||||
- Hotfix 번호 / 요약 / 반영 상태 / 적용 시점
|
|
||||||
5. QA State
|
|
||||||
- latest passed/failed / blocker 수 / 최근 QA 문서 링크
|
|
||||||
6. Deployment State
|
|
||||||
- `main` 배포 여부 / 마지막 배포 시각 / 재배포 필요 여부
|
|
||||||
|
|
||||||
## UX 원칙
|
|
||||||
- 숫자보다 상태 전이가 먼저 읽혀야 함
|
|
||||||
- Sprint와 Hotfix는 같은 영역에 섞지 말고, 관계는 보여주되 리스트는 분리
|
|
||||||
- 모바일에서도 단계 흐름이 먼저 보이게 구성
|
|
||||||
- 프로젝트 목록은 카드보다 운영 row에 가깝게 유지
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# Repo Structure Reference
|
|
||||||
|
|
||||||
## 현재 표준
|
|
||||||
- 루트 문서: `README.md`, `ARCHITECTURE.md`, `AGENTS.md`
|
|
||||||
- 실행 문서: `.plans/`
|
|
||||||
- 장기 문서: `docs/`
|
|
||||||
|
|
||||||
## 문서 역할
|
|
||||||
- `.plans/OVERVIEW.md`: 현재 활성 Sprint/Hotfix와 전체 진행 개요
|
|
||||||
- `.plans/design/`: 시스템/도메인/페이지 디자인
|
|
||||||
- `.plans/sprints/`: Sprint 단위 실행 계획
|
|
||||||
- `.plans/hotfix/`: Hotfix 단위 실행 계획
|
|
||||||
- `.plans/qa/`: 다랑이 QA 결과와 체크리스트
|
|
||||||
- `.plans/deploy/`: 배포/롤백/운영 플로우
|
|
||||||
- `docs/product-specs/`: 제품 기능 정책과 IA
|
|
||||||
- `docs/references/`: 구조/규칙/참고 자료
|
|
||||||
|
|
||||||
## 호환성 메모
|
|
||||||
Sprint 014 이전 데이터는 일부가 `.qa/`, `.plans/sprints/HOTFIX-xxx.md`, `.openclaw/...` 기반이야.
|
|
||||||
이번 작업에서는 기존 데이터를 읽을 수 있게 유지하면서 신규 입력은 새 구조로 정렬하는 걸 기본 원칙으로 둬.
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Tech Debt Tracker
|
|
||||||
|
|
||||||
## Sprint 014 이전 누적 부채
|
|
||||||
- OpenClaw 전용 경로 하드코딩 잔존
|
|
||||||
- `.qa/`와 `.plans/qa/` 이중 구조
|
|
||||||
- Hotfix 문서가 `.plans/sprints/`에 섞여 있음
|
|
||||||
- 프로젝트 진행률 계산이 Sprint 완료 비율 중심이라 Hotfix/QA/배포 상태를 충분히 반영하지 못함
|
|
||||||
- 자매 아바타 탐색 경로가 실제 운영 파일 위치와 어긋날 수 있음
|
|
||||||
|
|
||||||
## Sprint 014 목표
|
|
||||||
- Hermes 우선 + OpenClaw fallback 이행
|
|
||||||
- 프로젝트 문서 구조를 신규 표준으로 정렬
|
|
||||||
- 프로젝트 페이지 정보 구조 재설계
|
|
||||||
- main deployable / erang redeploy-only 흐름 명문화
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { PageTitle, BtnToggle } from '@/components/ui/base';
|
import { PageTitle, LabelMeta, BtnToggle } from '@/components/ui/base';
|
||||||
import { API_URL } from '@/lib/config';
|
import { API_URL } from '@/lib/config';
|
||||||
|
|
||||||
// ─── Styled ───
|
// ─── Styled ───
|
||||||
@@ -179,17 +179,8 @@ function formatDetail(detail: string | null, action: string): React.ReactNode {
|
|||||||
const PAGE_SIZE = 20;
|
const PAGE_SIZE = 20;
|
||||||
const ALL_TYPES = ['ALL', 'SYSTEM', 'SECURITY', 'ORG', 'BACKUP'];
|
const ALL_TYPES = ['ALL', 'SYSTEM', 'SECURITY', 'ORG', 'BACKUP'];
|
||||||
|
|
||||||
interface ActivityItem {
|
|
||||||
id: number;
|
|
||||||
action: string;
|
|
||||||
detail: string | null;
|
|
||||||
createdAt: string;
|
|
||||||
sister?: { name: string } | null;
|
|
||||||
project?: { name: string } | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ActivitiesPage() {
|
export default function ActivitiesPage() {
|
||||||
const [items, setItems] = useState<ActivityItem[]>([]);
|
const [items, setItems] = useState<any[]>([]);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [filter, setFilter] = useState('ALL');
|
const [filter, setFilter] = useState('ALL');
|
||||||
@@ -226,6 +217,7 @@ export default function ActivitiesPage() {
|
|||||||
const paged = filtered.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
|
const paged = filtered.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
|
||||||
|
|
||||||
const runtimeStr = (() => {
|
const runtimeStr = (() => {
|
||||||
|
const h = Math.floor(total * 0.5);
|
||||||
return `SYS_LOG_V.4.2 // ENTRIES: ${total}`;
|
return `SYS_LOG_V.4.2 // ENTRIES: ${total}`;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ export default function CostsPage() {
|
|||||||
) : !data || data.summary.recordCount === 0 ? (
|
) : !data || data.summary.recordCount === 0 ? (
|
||||||
<EmptyNote>
|
<EmptyNote>
|
||||||
아직 비용 데이터가 없어.<br />
|
아직 비용 데이터가 없어.<br />
|
||||||
위 "토큰 수집" 버튼으로 자매들의 세션 토큰을 수집해.
|
위 "토큰 수집" 버튼으로 자매들의 세션 토큰을 수집해.
|
||||||
</EmptyNote>
|
</EmptyNote>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -17,12 +17,6 @@ interface ActionResult {
|
|||||||
error: string | null;
|
error: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SisterAdminItem {
|
|
||||||
id?: number;
|
|
||||||
name: string;
|
|
||||||
status: Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Table = styled.div`display:flex;flex-direction:column;gap:8px;user-select:none;`;
|
const Table = styled.div`display:flex;flex-direction:column;gap:8px;user-select:none;`;
|
||||||
const Row = styled.div`background:var(--bg-surface);border:1px solid var(--border-color);border-radius:10px;padding:16px 20px;display:flex;align-items:center;gap:16px;`;
|
const Row = styled.div`background:var(--bg-surface);border:1px solid var(--border-color);border-radius:10px;padding:16px 20px;display:flex;align-items:center;gap:16px;`;
|
||||||
const SisterInfo = styled.div`display:flex;align-items:center;gap:10px;flex:1;`;
|
const SisterInfo = styled.div`display:flex;align-items:center;gap:10px;flex:1;`;
|
||||||
@@ -32,7 +26,7 @@ const ActionBtn = styled.button<{ $danger?: boolean }>`padding:6px 14px;border-r
|
|||||||
const ResultBanner = styled.div<{ $success: boolean }>`margin-top:8px;padding:8px 12px;background:${({ $success }) => $success ? 'rgba(0,230,118,0.08)' : 'rgba(255,23,68,0.08)'};border:1px solid ${({ $success }) => $success ? 'rgba(0,230,118,0.3)' : 'rgba(255,23,68,0.3)'};border-radius:6px;font-size:12px;color:${({ $success }) => $success ? '#00FF00' : '#FF1744'};font-family:monospace;white-space:pre-wrap;`;
|
const ResultBanner = styled.div<{ $success: boolean }>`margin-top:8px;padding:8px 12px;background:${({ $success }) => $success ? 'rgba(0,230,118,0.08)' : 'rgba(255,23,68,0.08)'};border:1px solid ${({ $success }) => $success ? 'rgba(0,230,118,0.3)' : 'rgba(255,23,68,0.3)'};border-radius:6px;font-size:12px;color:${({ $success }) => $success ? '#00FF00' : '#FF1744'};font-family:monospace;white-space:pre-wrap;`;
|
||||||
|
|
||||||
export default function AdminSistersPage() {
|
export default function AdminSistersPage() {
|
||||||
const [sisters, setSisters] = useState<SisterAdminItem[]>([]);
|
const [sisters, setSisters] = useState<any[]>([]);
|
||||||
const [modal, setModal] = useState<{ action: 'restart' | 'reset'; name: string } | null>(null);
|
const [modal, setModal] = useState<{ action: 'restart' | 'reset'; name: string } | null>(null);
|
||||||
const [results, setResults] = useState<Record<string, ActionResult>>({});
|
const [results, setResults] = useState<Record<string, ActionResult>>({});
|
||||||
const [loading, setLoading] = useState<Record<string, boolean>>({});
|
const [loading, setLoading] = useState<Record<string, boolean>>({});
|
||||||
|
|||||||
@@ -67,18 +67,8 @@ const NoProjects = styled.div`
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface RepoProjectItem {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
description: string | null;
|
|
||||||
repoUrl: string;
|
|
||||||
openPRs: number;
|
|
||||||
sprintCount: number;
|
|
||||||
progress: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ReposPage() {
|
export default function ReposPage() {
|
||||||
const [projects, setProjects] = useState<RepoProjectItem[]>([]);
|
const [projects, setProjects] = useState<any[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,954 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { API_URL, POLL_INTERVAL_MS } from '@/lib/config';
|
|
||||||
import { useSocket } from '@/lib/useSocket';
|
|
||||||
import SisterAvatar from '@/components/common/SisterAvatar';
|
|
||||||
import OfficeScene, {
|
|
||||||
type AgentState,
|
|
||||||
type SisterName,
|
|
||||||
type SisterNode,
|
|
||||||
type SubAgent,
|
|
||||||
type SelectedAgent,
|
|
||||||
} from '@/components/office/OfficeScene';
|
|
||||||
import ContextPanel from '@/components/office/ContextPanel';
|
|
||||||
import ChatWorkspace from '@/components/office/ChatWorkspace';
|
|
||||||
import PipelinePanel from '@/components/office/PipelinePanel';
|
|
||||||
import ServerHealthPanel, { type ServerEntry } from '@/components/office/ServerHealthPanel';
|
|
||||||
import type { PipelineNode } from '@/components/dashboard/ActivePipeline';
|
|
||||||
|
|
||||||
interface RuntimeSubagentItem {
|
|
||||||
name: string;
|
|
||||||
state: AgentState;
|
|
||||||
updatedAt: number | null;
|
|
||||||
currentTask: string | null;
|
|
||||||
sessionLabel: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SisterRuntimeItem {
|
|
||||||
name: SisterName;
|
|
||||||
gatewayConnected: boolean;
|
|
||||||
mainState: AgentState;
|
|
||||||
currentTask: string | null;
|
|
||||||
activeSessionLabel: string | null;
|
|
||||||
activeSessionUpdatedAt: number | null;
|
|
||||||
controlSessionKey: string | null;
|
|
||||||
recentMessages: Array<{
|
|
||||||
id: string;
|
|
||||||
role: 'user' | 'assistant' | 'tool';
|
|
||||||
content: string;
|
|
||||||
ts: string | null;
|
|
||||||
}>;
|
|
||||||
subagents: RuntimeSubagentItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SisterApiItem {
|
|
||||||
id?: number;
|
|
||||||
name: SisterName;
|
|
||||||
status: 'online' | 'offline' | 'working' | 'unknown';
|
|
||||||
role?: string;
|
|
||||||
currentTask?: string | null;
|
|
||||||
lastSeen?: string | null;
|
|
||||||
cpu?: number;
|
|
||||||
memory?: { used?: number; total?: number };
|
|
||||||
liveState?: AgentState;
|
|
||||||
activeSessionLabel?: string | null;
|
|
||||||
gatewayConnected?: boolean;
|
|
||||||
subagents?: RuntimeSubagentItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DashboardOpsData {
|
|
||||||
focusProject: {
|
|
||||||
name: string;
|
|
||||||
phase: string;
|
|
||||||
progress: number;
|
|
||||||
deployStatus: string;
|
|
||||||
currentSprint?: string | null;
|
|
||||||
ownerSister?: string | null;
|
|
||||||
} | null;
|
|
||||||
pipeline: {
|
|
||||||
activeTask: string;
|
|
||||||
focus: string;
|
|
||||||
reviewLoopCount: number;
|
|
||||||
escalationCount: number;
|
|
||||||
deployState: string;
|
|
||||||
nodes: PipelineNode[];
|
|
||||||
};
|
|
||||||
freshness: {
|
|
||||||
generatedAt: string;
|
|
||||||
activityLatestAt: string | null;
|
|
||||||
sistersLatestAt: string | null;
|
|
||||||
qaDocLatestAt: string | null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const SUBAGENT_DEFS: Record<SisterName, { id: string; name: string; label: string }[]> = {
|
|
||||||
harang: [
|
|
||||||
{ id: 'harang-planner', name: 'planner', label: 'planner' },
|
|
||||||
{ id: 'harang-task-tracker', name: 'task-tracker', label: 'task-tracker' },
|
|
||||||
{ id: 'harang-prd-writer', name: 'prd-writer', label: 'prd-writer' },
|
|
||||||
],
|
|
||||||
narang: [
|
|
||||||
{ id: 'narang-worker', name: 'worker', label: 'worker' },
|
|
||||||
{ id: 'narang-db-designer', name: 'db-designer', label: 'db-designer' },
|
|
||||||
{ id: 'narang-test-writer', name: 'test-writer', label: 'test-writer' },
|
|
||||||
{ id: 'narang-refactorer', name: 'refactorer', label: 'refactorer' },
|
|
||||||
],
|
|
||||||
darang: [
|
|
||||||
{ id: 'darang-reviewer', name: 'reviewer', label: 'reviewer' },
|
|
||||||
{ id: 'darang-code-reviewer', name: 'code-reviewer', label: 'code-reviewer' },
|
|
||||||
{ id: 'darang-qa-tester', name: 'qa-tester', label: 'qa-tester' },
|
|
||||||
{ id: 'darang-security-auditor', name: 'security-auditor', label: 'security-auditor' },
|
|
||||||
{ id: 'darang-ux-reviewer', name: 'ux-reviewer', label: 'ux-reviewer' },
|
|
||||||
],
|
|
||||||
erang: [
|
|
||||||
{ id: 'erang-deploy-manager', name: 'deploy-manager', label: 'deploy-manager' },
|
|
||||||
{ id: 'erang-db-manager', name: 'db-manager', label: 'db-manager' },
|
|
||||||
{ id: 'erang-nginx-manager', name: 'nginx-manager', label: 'nginx-manager' },
|
|
||||||
{ id: 'erang-monitoring', name: 'monitoring', label: 'monitoring' },
|
|
||||||
{ id: 'erang-dns-manager', name: 'dns-manager', label: 'dns-manager' },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const SISTER_DISPLAY: Record<SisterName, string> = {
|
|
||||||
harang: '하랑이',
|
|
||||||
narang: '나랑이',
|
|
||||||
darang: '다랑이',
|
|
||||||
erang: '이랑이',
|
|
||||||
};
|
|
||||||
|
|
||||||
const SISTER_ROLES: Record<SisterName, string> = {
|
|
||||||
harang: 'Planning & Orchestration',
|
|
||||||
narang: 'Development',
|
|
||||||
darang: 'QA & Review',
|
|
||||||
erang: 'Infra & Deploy',
|
|
||||||
};
|
|
||||||
|
|
||||||
const SISTER_ORDER: SisterName[] = ['harang', 'narang', 'darang', 'erang'];
|
|
||||||
const SUBAGENT_COUNT = Object.values(SUBAGENT_DEFS).reduce((total, defs) => total + defs.length, 0);
|
|
||||||
|
|
||||||
const GROUP_DEFS: { id: string; label: string; members: SisterName[]; description: string }[] = [
|
|
||||||
{ id: 'planning', label: 'Planning', members: ['harang'], description: 'Orchestration & Planning' },
|
|
||||||
{ id: 'delivery', label: 'Delivery', members: ['narang'], description: 'Implementation' },
|
|
||||||
{ id: 'review', label: 'Review', members: ['darang'], description: 'QA & Review' },
|
|
||||||
{ id: 'deploy', label: 'Deploy', members: ['erang'], description: 'Infra & Deploy' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const FALLBACK_SISTERS: SisterApiItem[] = [
|
|
||||||
{ name: 'harang', status: 'unknown', role: SISTER_ROLES.harang, currentTask: null },
|
|
||||||
{ name: 'narang', status: 'unknown', role: SISTER_ROLES.narang, currentTask: null },
|
|
||||||
{ name: 'darang', status: 'unknown', role: SISTER_ROLES.darang, currentTask: null },
|
|
||||||
{ name: 'erang', status: 'unknown', role: SISTER_ROLES.erang, currentTask: null },
|
|
||||||
];
|
|
||||||
|
|
||||||
function truthfulStateLabel(state: AgentState, source: 'live' | 'snapshot' | 'fallback'): string {
|
|
||||||
if (source === 'fallback') return 'fallback';
|
|
||||||
if (state === 'error') return 'offline';
|
|
||||||
if (state === 'tool_calling' || state === 'thinking' || state === 'speaking') return 'active working';
|
|
||||||
if (source === 'snapshot') return 'snapshot only';
|
|
||||||
return 'connected idle';
|
|
||||||
}
|
|
||||||
|
|
||||||
function statusToAgentState(status: SisterApiItem['status'], hasTask: boolean): AgentState {
|
|
||||||
if (status === 'offline') return 'error';
|
|
||||||
if (status === 'working') return hasTask ? 'tool_calling' : 'thinking';
|
|
||||||
if (status === 'online') return hasTask ? 'speaking' : 'idle';
|
|
||||||
return 'idle';
|
|
||||||
}
|
|
||||||
|
|
||||||
function derivedSubagentState(parentState: AgentState, index: number): AgentState {
|
|
||||||
if (parentState === 'error') return 'idle';
|
|
||||||
if (parentState === 'tool_calling' && index === 0) return 'thinking';
|
|
||||||
if (parentState === 'speaking' && index <= 1) return 'thinking';
|
|
||||||
return 'idle';
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeSubagentState(state?: AgentState): AgentState {
|
|
||||||
if (state === 'thinking' || state === 'tool_calling' || state === 'speaking' || state === 'error') {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
return 'idle';
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeSisterData(
|
|
||||||
statuses: SisterApiItem[],
|
|
||||||
runtime: SisterRuntimeItem[],
|
|
||||||
previous: SisterApiItem[] = [],
|
|
||||||
): SisterApiItem[] {
|
|
||||||
const previousMap = new Map(previous.map((item) => [item.name, item]));
|
|
||||||
const statusMap = new Map(statuses.map((item) => [item.name, item]));
|
|
||||||
const runtimeMap = new Map(runtime.map((item) => [item.name, item]));
|
|
||||||
|
|
||||||
return SISTER_ORDER.map((name) => {
|
|
||||||
const prev = previousMap.get(name);
|
|
||||||
const status = statusMap.get(name) ?? prev;
|
|
||||||
const live = runtimeMap.get(name);
|
|
||||||
|
|
||||||
// If we have no data at all for this sister, build a minimal honest entry
|
|
||||||
if (!status) {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
status: 'unknown' as const,
|
|
||||||
role: SISTER_ROLES[name],
|
|
||||||
currentTask: live?.currentTask ?? null,
|
|
||||||
liveState: live?.mainState,
|
|
||||||
activeSessionLabel: live?.activeSessionLabel ?? null,
|
|
||||||
gatewayConnected: live?.gatewayConnected ?? false,
|
|
||||||
subagents: live?.subagents ?? [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
...status,
|
|
||||||
name,
|
|
||||||
role: status.role ?? prev?.role ?? SISTER_ROLES[name],
|
|
||||||
currentTask: live?.currentTask ?? status.currentTask ?? prev?.currentTask ?? null,
|
|
||||||
liveState: live?.mainState ?? prev?.liveState,
|
|
||||||
activeSessionLabel: live?.activeSessionLabel ?? prev?.activeSessionLabel ?? null,
|
|
||||||
gatewayConnected: live?.gatewayConnected ?? prev?.gatewayConnected ?? false,
|
|
||||||
subagents: live?.subagents ?? prev?.subagents ?? [],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildSisterNodes(sisters: SisterApiItem[]): SisterNode[] {
|
|
||||||
return SISTER_ORDER.map((name) => {
|
|
||||||
const item = sisters.find((s) => s.name === name);
|
|
||||||
const fallbackState = statusToAgentState(item?.status ?? 'unknown', Boolean(item?.currentTask));
|
|
||||||
const state = item?.gatewayConnected ? item.liveState ?? fallbackState : fallbackState;
|
|
||||||
|
|
||||||
const runtimeSubagents = item?.subagents ?? [];
|
|
||||||
const runtimeMap = new Map(runtimeSubagents.map((sub) => [sub.name, sub]));
|
|
||||||
|
|
||||||
const subagents: SubAgent[] = SUBAGENT_DEFS[name].map((def, index) => {
|
|
||||||
const runtime = runtimeMap.get(def.name);
|
|
||||||
return {
|
|
||||||
id: def.id,
|
|
||||||
name: def.name,
|
|
||||||
label: def.label,
|
|
||||||
sister: name,
|
|
||||||
state: runtime ? normalizeSubagentState(runtime.state) : derivedSubagentState(state, index),
|
|
||||||
currentTask: runtime?.currentTask ?? null,
|
|
||||||
updatedAt: runtime?.updatedAt ?? null,
|
|
||||||
sessionLabel: runtime?.sessionLabel ?? null,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
displayName: SISTER_DISPLAY[name],
|
|
||||||
role: item?.role ?? SISTER_ROLES[name],
|
|
||||||
state,
|
|
||||||
currentTask: item?.currentTask ?? null,
|
|
||||||
activeSessionLabel: item?.activeSessionLabel ?? null,
|
|
||||||
subagents,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildServerEntries(sisters: SisterApiItem[], sisterSource: 'live' | 'snapshot' | 'fallback'): ServerEntry[] {
|
|
||||||
const sisterEntries: ServerEntry[] = SISTER_ORDER.map((name) => {
|
|
||||||
const sister = sisters.find((item) => item.name === name);
|
|
||||||
return {
|
|
||||||
id: `server-${name}`,
|
|
||||||
label: SISTER_DISPLAY[name],
|
|
||||||
type: 'sister' as const,
|
|
||||||
status: sister?.status ?? 'unknown',
|
|
||||||
detail: sister?.currentTask ?? sister?.activeSessionLabel ?? null,
|
|
||||||
source: sister ? sisterSource : 'fallback',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const extraEntries: ServerEntry[] = [
|
|
||||||
{ id: 'server-dev', label: 'Dev Server', type: 'dev', status: 'unknown', detail: null, source: 'fallback' },
|
|
||||||
{ id: 'server-docker', label: 'Docker / Infra', type: 'docker', status: 'unknown', detail: null, source: 'fallback' },
|
|
||||||
];
|
|
||||||
|
|
||||||
return [...sisterEntries, ...extraEntries];
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatGeneratedAt(ts: string): string {
|
|
||||||
try {
|
|
||||||
return new Date(ts).toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
||||||
} catch {
|
|
||||||
return ts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Shell = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
min-height: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PageHeader = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PageTitle = styled.h1`
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PageMeta = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
|
|
||||||
@media (max-width: 1279px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FreshnessBar = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-md);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-left: auto;
|
|
||||||
|
|
||||||
@media (max-width: 1279px) {
|
|
||||||
margin-left: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FreshnessBadge = styled.span<{ $type: 'live' | 'snapshot' | 'fallback' }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
color: ${({ $type }) => ($type === 'live' ? '#00BFA5' : $type === 'snapshot' ? '#FF9800' : '#777')};
|
|
||||||
border: 1px solid currentColor;
|
|
||||||
padding: 2px 6px;
|
|
||||||
opacity: 0.8;
|
|
||||||
`;
|
|
||||||
|
|
||||||
/* ─── Desktop layout (≥1280px): scene + context side-by-side ─── */
|
|
||||||
const DesktopMain = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: 0;
|
|
||||||
min-height: 0;
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
@media (max-width: 1279px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SceneColumn = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
min-width: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ChatArea = styled.div`
|
|
||||||
height: 520px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
@media (max-width: 1279px) {
|
|
||||||
height: 400px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const BottomPanels = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
|
|
||||||
@media (max-width: 1279px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const LoadingOverlay = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 400px;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
/* ─── Mobile layout (<1280px) ─── */
|
|
||||||
const MobileFlow = styled.div`
|
|
||||||
display: none;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
|
|
||||||
@media (max-width: 1279px) {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileSisterGrid = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const STATE_CARD_COLORS: Record<AgentState, string> = {
|
|
||||||
idle: '#444',
|
|
||||||
thinking: '#2979FF',
|
|
||||||
tool_calling: '#FF9800',
|
|
||||||
speaking: '#00BFA5',
|
|
||||||
error: '#FF1744',
|
|
||||||
};
|
|
||||||
|
|
||||||
const MobileSisterCard = styled.button<{ $state: AgentState; $selected: boolean }>`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
border: 1px solid ${({ $state }) => STATE_CARD_COLORS[$state]};
|
|
||||||
background: ${({ $selected }) => ($selected ? 'rgba(255,255,255,0.04)' : 'var(--bg-surface)')};
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: left;
|
|
||||||
font-family: inherit;
|
|
||||||
color: var(--text-primary);
|
|
||||||
outline: ${({ $selected }) => ($selected ? '1px solid var(--text-primary)' : 'none')};
|
|
||||||
outline-offset: -1px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileCardMeta = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 2px;
|
|
||||||
min-width: 0;
|
|
||||||
flex: 1;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileCardName = styled.div`
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileCardState = styled.div<{ $state: AgentState }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
color: ${({ $state }) => STATE_CARD_COLORS[$state]};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileCardTask = styled.div`
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileFocusSection = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
padding: var(--space-md) var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileSectionEyebrow = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileFocusTitle = styled.div`
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileFocusDetail = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileHealthRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileHealthChip = styled.div<{ $ok: boolean }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
padding: 2px 8px;
|
|
||||||
border: 1px solid ${({ $ok }) => ($ok ? '#00BFA5' : '#555')};
|
|
||||||
color: ${({ $ok }) => ($ok ? '#00BFA5' : '#777')};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileQuickActions = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileActionBtn = styled.button`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: transparent;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
padding: var(--space-xs) var(--space-sm);
|
|
||||||
cursor: pointer;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileGroupBlock = styled.button<{ $hasActive: boolean; $expanded: boolean }>`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
padding: var(--space-md);
|
|
||||||
border: 1px solid ${({ $hasActive }) => ($hasActive ? '#2979FF' : 'var(--border-color)')};
|
|
||||||
background: ${({ $expanded }) => ($expanded ? 'rgba(255,255,255,0.04)' : 'var(--bg-surface)')};
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: left;
|
|
||||||
font-family: inherit;
|
|
||||||
color: var(--text-primary);
|
|
||||||
width: 100%;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileGroupHeader = styled.div`
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
min-width: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileGroupLabel = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileGroupMeta = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-xs);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileGroupChip = styled.span<{ $tone: 'active' | 'idle' | 'offline' | 'fallback' }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 9px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
padding: 2px 6px;
|
|
||||||
border: 1px solid ${({ $tone }) =>
|
|
||||||
$tone === 'active' ? '#2979FF' : $tone === 'idle' ? '#00BFA5' : $tone === 'offline' ? '#FF1744' : '#555'};
|
|
||||||
color: ${({ $tone }) =>
|
|
||||||
$tone === 'active' ? '#2979FF' : $tone === 'idle' ? '#00BFA5' : $tone === 'offline' ? '#FF1744' : '#777'};
|
|
||||||
white-space: nowrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileGroupDetail = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
padding-top: var(--space-sm);
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileOpsSummary = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
padding: var(--space-md);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileContextInline = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
padding: var(--space-md) var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-md);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileContextHeader = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileContextTitle = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileCloseBtn = styled.button`
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0;
|
|
||||||
line-height: 1;
|
|
||||||
|
|
||||||
&:hover { color: var(--text-primary); }
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileSelectedSummary = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileSelectedMeta = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 2px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileSelectedName = styled.div`
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileSelectedRole = styled.div`
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileTaskBox = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: #58A6FF;
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
background: rgba(88, 166, 255, 0.06);
|
|
||||||
border-left: 2px solid #58A6FF;
|
|
||||||
line-height: 1.5;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MobileChatArea = styled.div`
|
|
||||||
height: 400px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
@media (max-width: 389px) {
|
|
||||||
height: 360px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default function OfficePage() {
|
|
||||||
const [sisters, setSisters] = useState<SisterApiItem[]>([]);
|
|
||||||
const [opsData, setOpsData] = useState<DashboardOpsData | null>(null);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const [selected, setSelected] = useState<SelectedAgent | null>(null);
|
|
||||||
const [chatSister, setChatSister] = useState<SisterName | null>(null);
|
|
||||||
|
|
||||||
const { connected } = useSocket<SisterApiItem>({
|
|
||||||
onSistersUpdate: (updated) => {
|
|
||||||
setSisters((prev) => mergeSisterData(updated, [], prev));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const fetchAll = useCallback(async () => {
|
|
||||||
const [sistersRes, opsRes, runtimeRes] = await Promise.allSettled([
|
|
||||||
fetch(`${API_URL}/api/sisters`).then((r) => r.json()),
|
|
||||||
fetch(`${API_URL}/api/dashboard/ops`).then((r) => r.json()),
|
|
||||||
fetch(`${API_URL}/api/sisters/runtime`).then((r) => r.json()),
|
|
||||||
]);
|
|
||||||
|
|
||||||
setSisters((prev) => {
|
|
||||||
const base = sistersRes.status === 'fulfilled' && Array.isArray(sistersRes.value) ? sistersRes.value as SisterApiItem[] : prev;
|
|
||||||
const runtime = runtimeRes.status === 'fulfilled' && Array.isArray(runtimeRes.value) ? runtimeRes.value as SisterRuntimeItem[] : [];
|
|
||||||
return mergeSisterData(base, runtime, prev);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (opsRes.status === 'fulfilled') {
|
|
||||||
setOpsData(opsRes.value as DashboardOpsData);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const boot = async () => {
|
|
||||||
try {
|
|
||||||
await fetchAll();
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void boot();
|
|
||||||
|
|
||||||
// Polling fallback — only when socket is disconnected
|
|
||||||
// Socket handles live updates; polling is a disconnected fallback
|
|
||||||
return () => {};
|
|
||||||
}, [fetchAll]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (connected) return; // socket is live, no polling needed
|
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
void fetchAll();
|
|
||||||
}, POLL_INTERVAL_MS);
|
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, [connected, fetchAll]);
|
|
||||||
|
|
||||||
const hasSisterSnapshot = sisters.length > 0;
|
|
||||||
const sisterDataMode: 'live' | 'snapshot' | 'fallback' = connected ? 'live' : hasSisterSnapshot ? 'snapshot' : 'fallback';
|
|
||||||
const effectiveSisters = hasSisterSnapshot ? sisters : FALLBACK_SISTERS;
|
|
||||||
const sisterNodes = useMemo(() => buildSisterNodes(effectiveSisters), [effectiveSisters]);
|
|
||||||
const serverEntries = useMemo(() => buildServerEntries(effectiveSisters, sisterDataMode), [effectiveSisters, sisterDataMode]);
|
|
||||||
|
|
||||||
const subagentMode: 'live' | 'fallback' = useMemo(() => {
|
|
||||||
return effectiveSisters.some((item) => (item.subagents?.length ?? 0) > 0) ? 'live' : 'fallback';
|
|
||||||
}, [effectiveSisters]);
|
|
||||||
|
|
||||||
const handleSelectSister = useCallback((name: SisterName) => {
|
|
||||||
setSelected({ type: 'sister', name });
|
|
||||||
setChatSister(null);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleSelectSubagent = useCallback((id: string, sister: SisterName) => {
|
|
||||||
setSelected({ type: 'subagent', id, sister });
|
|
||||||
setChatSister(null);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleOpenChat = useCallback((sisterName: SisterName) => {
|
|
||||||
setChatSister(sisterName);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const pipeline = opsData?.pipeline ?? {
|
|
||||||
activeTask: 'SPRINT-016',
|
|
||||||
focus: 'Office runtime sync',
|
|
||||||
reviewLoopCount: 0,
|
|
||||||
escalationCount: 0,
|
|
||||||
deployState: '—',
|
|
||||||
nodes: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const freshness = opsData?.freshness ?? {
|
|
||||||
generatedAt: new Date().toISOString(),
|
|
||||||
activityLatestAt: null,
|
|
||||||
sistersLatestAt: null,
|
|
||||||
qaDocLatestAt: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedSisterNode = useMemo(() => {
|
|
||||||
if (!selected) return null;
|
|
||||||
if (selected.type === 'sister') return sisterNodes.find((s) => s.name === selected.name) ?? null;
|
|
||||||
if (selected.type === 'subagent') return sisterNodes.find((s) => s.name === selected.sister) ?? null;
|
|
||||||
return null;
|
|
||||||
}, [selected, sisterNodes]);
|
|
||||||
|
|
||||||
const selectedSubagent = useMemo(() => {
|
|
||||||
if (selected?.type !== 'subagent') return null;
|
|
||||||
return selectedSisterNode?.subagents.find((sub) => sub.id === selected.id) ?? null;
|
|
||||||
}, [selected, selectedSisterNode]);
|
|
||||||
|
|
||||||
const onlineCount = useMemo(
|
|
||||||
() => effectiveSisters.filter((s) => s.status === 'online' || s.status === 'working').length,
|
|
||||||
[effectiveSisters],
|
|
||||||
);
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return <LoadingOverlay>오피스 데이터 로딩 중...</LoadingOverlay>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Shell>
|
|
||||||
<PageHeader>
|
|
||||||
<PageTitle>🏢 오피스 대시보드</PageTitle>
|
|
||||||
<PageMeta>4자매 · {SUBAGENT_COUNT} 서브에이전트 · 협업 관제</PageMeta>
|
|
||||||
<FreshnessBar>
|
|
||||||
<FreshnessBadge $type={sisterDataMode}>
|
|
||||||
source: {sisterDataMode}
|
|
||||||
</FreshnessBadge>
|
|
||||||
<FreshnessBadge $type={subagentMode === 'live' ? 'live' : 'fallback'}>
|
|
||||||
agents: {subagentMode}
|
|
||||||
</FreshnessBadge>
|
|
||||||
<FreshnessBadge $type="snapshot">pipeline: snapshot</FreshnessBadge>
|
|
||||||
</FreshnessBar>
|
|
||||||
</PageHeader>
|
|
||||||
|
|
||||||
{/* ─── Desktop layout (≥1280px) ─── */}
|
|
||||||
<DesktopMain>
|
|
||||||
<SceneColumn>
|
|
||||||
<OfficeScene
|
|
||||||
sisters={sisterNodes}
|
|
||||||
selected={selected}
|
|
||||||
onSelectSister={handleSelectSister}
|
|
||||||
onSelectSubagent={handleSelectSubagent}
|
|
||||||
dataMode={sisterDataMode}
|
|
||||||
subagentMode={subagentMode}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{chatSister && (
|
|
||||||
<ChatArea>
|
|
||||||
<ChatWorkspace initialSister={chatSister} onClose={() => setChatSister(null)} />
|
|
||||||
</ChatArea>
|
|
||||||
)}
|
|
||||||
</SceneColumn>
|
|
||||||
|
|
||||||
<ContextPanel
|
|
||||||
selected={selected}
|
|
||||||
sisters={sisterNodes}
|
|
||||||
onOpenChat={handleOpenChat}
|
|
||||||
onClear={() => setSelected(null)}
|
|
||||||
/>
|
|
||||||
</DesktopMain>
|
|
||||||
|
|
||||||
{/* ─── Mobile layout (<1280px) ─── */}
|
|
||||||
<MobileFlow>
|
|
||||||
{/* 1. Operational summary — always first */}
|
|
||||||
<MobileOpsSummary>
|
|
||||||
<MobileSectionEyebrow>운영 요약</MobileSectionEyebrow>
|
|
||||||
<MobileFocusTitle>{pipeline.activeTask}</MobileFocusTitle>
|
|
||||||
<MobileFocusDetail>{pipeline.focus}</MobileFocusDetail>
|
|
||||||
<MobileHealthRow>
|
|
||||||
<MobileHealthChip $ok={sisterDataMode === 'live'}>
|
|
||||||
{sisterDataMode === 'live' ? 'live' : sisterDataMode === 'snapshot' ? 'snapshot' : 'fallback'}
|
|
||||||
</MobileHealthChip>
|
|
||||||
<MobileHealthChip $ok={onlineCount >= 3}>
|
|
||||||
{onlineCount}/{SISTER_ORDER.length} connected
|
|
||||||
</MobileHealthChip>
|
|
||||||
<MobileHealthChip $ok={pipeline.deployState !== 'blocked'}>
|
|
||||||
deploy: {pipeline.deployState}
|
|
||||||
</MobileHealthChip>
|
|
||||||
</MobileHealthRow>
|
|
||||||
<MobileQuickActions>
|
|
||||||
{SISTER_ORDER.map((name) => (
|
|
||||||
<MobileActionBtn key={name} onClick={() => handleOpenChat(name)}>
|
|
||||||
{SISTER_DISPLAY[name]}
|
|
||||||
</MobileActionBtn>
|
|
||||||
))}
|
|
||||||
</MobileQuickActions>
|
|
||||||
</MobileOpsSummary>
|
|
||||||
|
|
||||||
{/* 2. Group blocks — group mental model, not 4 individual cards */}
|
|
||||||
<MobileSisterGrid>
|
|
||||||
{GROUP_DEFS.map((group) => {
|
|
||||||
const groupSisters = group.members.map((m) => sisterNodes.find((s) => s.name === m)).filter(Boolean) as typeof sisterNodes;
|
|
||||||
const hasActive = groupSisters.some((s) => s.state === 'tool_calling' || s.state === 'thinking' || s.state === 'speaking');
|
|
||||||
const workingCount = groupSisters.filter((s) => s.state === 'tool_calling' || s.state === 'thinking' || s.state === 'speaking').length;
|
|
||||||
const connectedCount = groupSisters.filter((s) => s.state !== 'error').length;
|
|
||||||
const isExpanded = selected?.type === 'sister' && group.members.includes(selected.name);
|
|
||||||
const groupState = truthfulStateLabel(
|
|
||||||
groupSisters[0]?.state ?? 'idle',
|
|
||||||
sisterDataMode,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<MobileGroupBlock
|
|
||||||
key={group.id}
|
|
||||||
$hasActive={hasActive}
|
|
||||||
$expanded={isExpanded}
|
|
||||||
onClick={() => handleSelectSister(group.members[0])}
|
|
||||||
>
|
|
||||||
<MobileGroupHeader>
|
|
||||||
<MobileGroupLabel>{group.label}</MobileGroupLabel>
|
|
||||||
<MobileGroupMeta>
|
|
||||||
<MobileGroupChip $tone={hasActive ? 'active' : connectedCount > 0 ? 'idle' : sisterDataMode === 'fallback' ? 'fallback' : 'offline'}>
|
|
||||||
{groupState}
|
|
||||||
</MobileGroupChip>
|
|
||||||
{workingCount > 0 && <MobileGroupChip $tone="active">{workingCount} working</MobileGroupChip>}
|
|
||||||
</MobileGroupMeta>
|
|
||||||
</MobileGroupHeader>
|
|
||||||
<MobileFocusDetail>{group.description}</MobileFocusDetail>
|
|
||||||
{isExpanded && (
|
|
||||||
<MobileGroupDetail>
|
|
||||||
{groupSisters.map((sister) => (
|
|
||||||
<MobileSelectedSummary key={sister.name}>
|
|
||||||
<SisterAvatar name={sister.name} size={28} />
|
|
||||||
<MobileSelectedMeta>
|
|
||||||
<MobileSelectedName>{sister.displayName}</MobileSelectedName>
|
|
||||||
<MobileSelectedRole>
|
|
||||||
{truthfulStateLabel(sister.state, sisterDataMode)}
|
|
||||||
{sister.currentTask ? ` · ${sister.currentTask}` : ''}
|
|
||||||
</MobileSelectedRole>
|
|
||||||
</MobileSelectedMeta>
|
|
||||||
</MobileSelectedSummary>
|
|
||||||
))}
|
|
||||||
<MobileQuickActions>
|
|
||||||
<MobileActionBtn onClick={(e) => { e.stopPropagation(); handleOpenChat(group.members[0]); }}>채팅</MobileActionBtn>
|
|
||||||
</MobileQuickActions>
|
|
||||||
</MobileGroupDetail>
|
|
||||||
)}
|
|
||||||
</MobileGroupBlock>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</MobileSisterGrid>
|
|
||||||
|
|
||||||
{/* 3. Chat (if open) */}
|
|
||||||
{chatSister && (
|
|
||||||
<MobileChatArea>
|
|
||||||
<ChatWorkspace initialSister={chatSister} onClose={() => setChatSister(null)} />
|
|
||||||
</MobileChatArea>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 4. Pipeline panel */}
|
|
||||||
<PipelinePanel
|
|
||||||
activeTask={pipeline.activeTask}
|
|
||||||
focus={pipeline.focus}
|
|
||||||
reviewLoopCount={pipeline.reviewLoopCount}
|
|
||||||
escalationCount={pipeline.escalationCount}
|
|
||||||
deployState={pipeline.deployState}
|
|
||||||
nodes={pipeline.nodes}
|
|
||||||
freshness={`generated ${formatGeneratedAt(freshness.generatedAt)}`}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 5. Server health */}
|
|
||||||
<ServerHealthPanel
|
|
||||||
servers={serverEntries}
|
|
||||||
dataMode={sisterDataMode}
|
|
||||||
generatedAt={freshness.generatedAt}
|
|
||||||
/>
|
|
||||||
</MobileFlow>
|
|
||||||
|
|
||||||
{/* ─── Desktop bottom panels ─── */}
|
|
||||||
<BottomPanels>
|
|
||||||
<PipelinePanel
|
|
||||||
activeTask={pipeline.activeTask}
|
|
||||||
focus={pipeline.focus}
|
|
||||||
reviewLoopCount={pipeline.reviewLoopCount}
|
|
||||||
escalationCount={pipeline.escalationCount}
|
|
||||||
deployState={pipeline.deployState}
|
|
||||||
nodes={pipeline.nodes}
|
|
||||||
freshness={`generated ${formatGeneratedAt(freshness.generatedAt)}`}
|
|
||||||
/>
|
|
||||||
<ServerHealthPanel
|
|
||||||
servers={serverEntries}
|
|
||||||
dataMode={sisterDataMode}
|
|
||||||
generatedAt={freshness.generatedAt}
|
|
||||||
/>
|
|
||||||
</BottomPanels>
|
|
||||||
</Shell>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -3,329 +3,137 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { API_URL } from '@/lib/config';
|
import { API_URL } from '@/lib/config';
|
||||||
import SisterAvatar from '@/components/common/SisterAvatar';
|
|
||||||
|
|
||||||
// ─── Types ───
|
// ─── Styled ───
|
||||||
|
const MainViewport = styled.div`
|
||||||
interface OrgUnit {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
kind: 'hq' | 'functional_team';
|
|
||||||
lead: string | null;
|
|
||||||
memberIds: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OrgMember {
|
|
||||||
id: string;
|
|
||||||
type: 'sister' | 'agent';
|
|
||||||
role: string;
|
|
||||||
status: { connection: string; working: string };
|
|
||||||
source: string;
|
|
||||||
freshness: { lastSnapshotAt: string | null };
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IndependentAgent {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
ownerSister: string | null;
|
|
||||||
source: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OrgApiData {
|
|
||||||
owner?: { name: string; role: string };
|
|
||||||
sisters?: Array<{
|
|
||||||
name: string;
|
|
||||||
role: string;
|
|
||||||
status?: string;
|
|
||||||
}>;
|
|
||||||
orgUnits?: OrgUnit[];
|
|
||||||
members?: OrgMember[];
|
|
||||||
reportingLines?: Array<{ from: string; to: string; kind: string }>;
|
|
||||||
independentAgents?: IndependentAgent[];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Fallback org structure (data-driven, not hardcoded tree) ───
|
|
||||||
|
|
||||||
const FALLBACK_ORG_UNITS: OrgUnit[] = [
|
|
||||||
{ id: 'hq', name: '하나랑 HQ', kind: 'hq', lead: 'harang', memberIds: ['harang'] },
|
|
||||||
{ id: 'delivery', name: 'Delivery', kind: 'functional_team', lead: 'narang', memberIds: ['narang'] },
|
|
||||||
{ id: 'review', name: 'QA / Review', kind: 'functional_team', lead: 'darang', memberIds: ['darang'] },
|
|
||||||
{ id: 'infra', name: 'Infra / Deploy', kind: 'functional_team', lead: 'erang', memberIds: ['erang'] },
|
|
||||||
];
|
|
||||||
|
|
||||||
const FALLBACK_MEMBERS: OrgMember[] = [
|
|
||||||
{ id: 'harang', type: 'sister', role: 'Orchestrator', status: { connection: 'unknown', working: 'unknown' }, source: 'fallback', freshness: { lastSnapshotAt: null } },
|
|
||||||
{ id: 'narang', type: 'sister', role: 'Generator', status: { connection: 'unknown', working: 'unknown' }, source: 'fallback', freshness: { lastSnapshotAt: null } },
|
|
||||||
{ id: 'darang', type: 'sister', role: 'Evaluator', status: { connection: 'unknown', working: 'unknown' }, source: 'fallback', freshness: { lastSnapshotAt: null } },
|
|
||||||
{ id: 'erang', type: 'sister', role: 'Infra Manager', status: { connection: 'unknown', working: 'unknown' }, source: 'fallback', freshness: { lastSnapshotAt: null } },
|
|
||||||
];
|
|
||||||
|
|
||||||
const FALLBACK_INDEPENDENT_AGENTS: IndependentAgent[] = [
|
|
||||||
{ id: 'security-auditor', name: 'security-auditor', ownerSister: 'darang', source: 'fallback' },
|
|
||||||
{ id: 'monitoring', name: 'monitoring', ownerSister: 'erang', source: 'fallback' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const MEMBER_DISPLAY: Record<string, string> = {
|
|
||||||
harang: '하랑이', narang: '나랑이', darang: '다랑이', erang: '이랑이',
|
|
||||||
};
|
|
||||||
|
|
||||||
const LXC_ID: Record<string, number> = {
|
|
||||||
harang: 104, narang: 105, darang: 106, erang: 107,
|
|
||||||
};
|
|
||||||
|
|
||||||
// ─── Helpers ───
|
|
||||||
|
|
||||||
function statusLabel(status: OrgMember['status']): string {
|
|
||||||
if (status.working === 'active') return 'active working';
|
|
||||||
if (status.connection === 'connected') return 'connected idle';
|
|
||||||
if (status.connection === 'unknown') return 'unknown';
|
|
||||||
return 'offline';
|
|
||||||
}
|
|
||||||
|
|
||||||
function statusTone(status: OrgMember['status']): 'active' | 'idle' | 'offline' | 'unknown' {
|
|
||||||
if (status.working === 'active') return 'active';
|
|
||||||
if (status.connection === 'connected') return 'idle';
|
|
||||||
if (status.connection === 'unknown') return 'unknown';
|
|
||||||
return 'offline';
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatFreshness(ts: string | null): string {
|
|
||||||
if (!ts) return 'NO DATA';
|
|
||||||
const diff = Date.now() - new Date(ts).getTime();
|
|
||||||
if (!Number.isFinite(diff) || diff < 0) return 'UNKNOWN';
|
|
||||||
const sec = Math.floor(diff / 1000);
|
|
||||||
if (sec < 60) return `${sec}s AGO`;
|
|
||||||
const min = Math.floor(sec / 60);
|
|
||||||
if (min < 60) return `${min}m AGO`;
|
|
||||||
return `${Math.floor(min / 60)}h AGO`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildOrgFromLegacy(data: OrgApiData): {
|
|
||||||
orgUnits: OrgUnit[];
|
|
||||||
members: OrgMember[];
|
|
||||||
independentAgents: IndependentAgent[];
|
|
||||||
} {
|
|
||||||
if (data.orgUnits && data.members) {
|
|
||||||
return {
|
|
||||||
orgUnits: data.orgUnits,
|
|
||||||
members: data.members,
|
|
||||||
independentAgents: data.independentAgents ?? FALLBACK_INDEPENDENT_AGENTS,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transform legacy /api/org response into org chart model
|
|
||||||
const sisters = data.sisters ?? [];
|
|
||||||
if (sisters.length === 0) {
|
|
||||||
return { orgUnits: FALLBACK_ORG_UNITS, members: FALLBACK_MEMBERS, independentAgents: FALLBACK_INDEPENDENT_AGENTS };
|
|
||||||
}
|
|
||||||
|
|
||||||
const ROLE_TO_TEAM: Record<string, string> = {
|
|
||||||
Orchestrator: 'hq',
|
|
||||||
Generator: 'delivery',
|
|
||||||
Evaluator: 'review',
|
|
||||||
'Infra Manager': 'infra',
|
|
||||||
};
|
|
||||||
|
|
||||||
const orgUnits: OrgUnit[] = [
|
|
||||||
{ id: 'hq', name: '하나랑 HQ', kind: 'hq', lead: null, memberIds: [] },
|
|
||||||
{ id: 'delivery', name: 'Delivery', kind: 'functional_team', lead: null, memberIds: [] },
|
|
||||||
{ id: 'review', name: 'QA / Review', kind: 'functional_team', lead: null, memberIds: [] },
|
|
||||||
{ id: 'infra', name: 'Infra / Deploy', kind: 'functional_team', lead: null, memberIds: [] },
|
|
||||||
];
|
|
||||||
|
|
||||||
const members: OrgMember[] = sisters.map((s) => {
|
|
||||||
const teamId = ROLE_TO_TEAM[s.role] ?? 'delivery';
|
|
||||||
const unit = orgUnits.find((u) => u.id === teamId);
|
|
||||||
if (unit) {
|
|
||||||
unit.memberIds.push(s.name);
|
|
||||||
if (!unit.lead) unit.lead = s.name;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
id: s.name,
|
|
||||||
type: 'sister' as const,
|
|
||||||
role: s.role,
|
|
||||||
status: {
|
|
||||||
connection: s.status === 'online' || s.status === 'working' ? 'connected' : s.status === 'offline' ? 'disconnected' : 'unknown',
|
|
||||||
working: s.status === 'working' ? 'active' : 'idle',
|
|
||||||
},
|
|
||||||
source: 'snapshot',
|
|
||||||
freshness: { lastSnapshotAt: new Date().toISOString() },
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return { orgUnits, members, independentAgents: FALLBACK_INDEPENDENT_AGENTS };
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Styled Components ───
|
|
||||||
|
|
||||||
const Shell = styled.div`
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--space-xl);
|
gap: var(--space-xl);
|
||||||
min-height: 80vh;
|
min-height: 80vh;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const OrgHeader = styled.div`
|
const HeaderInfo = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
gap: var(--space-xl);
|
||||||
align-items: baseline;
|
font-family: var(--font-mono);
|
||||||
gap: var(--space-lg);
|
font-size: 11px;
|
||||||
flex-wrap: wrap;
|
color: var(--text-secondary);
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
padding-bottom: var(--space-md);
|
padding-bottom: var(--space-md);
|
||||||
|
|
||||||
|
span { color: var(--text-primary); }
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const OrgTitle = styled.h1`
|
const TreeContainer = styled.div`
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const OrgMeta = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-md);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const OrgBadge = styled.span<{ $tone: 'default' | 'active' | 'fallback' }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
padding: 2px 6px;
|
|
||||||
border: 1px solid ${({ $tone }) =>
|
|
||||||
$tone === 'active' ? '#00BFA5' : $tone === 'fallback' ? '#777' : 'var(--border-color)'};
|
|
||||||
color: ${({ $tone }) =>
|
|
||||||
$tone === 'active' ? '#00BFA5' : $tone === 'fallback' ? '#777' : 'var(--text-secondary)'};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SectionLabel = styled.h2`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
margin: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HQCard = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-left-width: 3px;
|
|
||||||
border-left-color: #f6b26b;
|
|
||||||
padding: var(--space-lg);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--space-md);
|
align-items: center;
|
||||||
`;
|
overflow-x: auto;
|
||||||
|
padding: var(--space-xl) 0;
|
||||||
const TeamGrid = styled.div`
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
||||||
gap: var(--space-lg);
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TeamCard = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-md);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TeamTitle = styled.div`
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TeamLead = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MemberChipRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MemberChip = styled.div<{ $tone: 'active' | 'idle' | 'offline' | 'unknown' }>`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-xs);
|
|
||||||
border: 1px solid ${({ $tone }) =>
|
|
||||||
$tone === 'active' ? '#2979FF' : $tone === 'idle' ? '#00BFA5' : $tone === 'offline' ? '#555' : '#444'};
|
|
||||||
padding: 4px 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StatusDot = styled.span<{ $tone: 'active' | 'idle' | 'offline' | 'unknown' }>`
|
|
||||||
width: 6px;
|
|
||||||
height: 6px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: ${({ $tone }) =>
|
|
||||||
$tone === 'active' ? '#2979FF' : $tone === 'idle' ? '#00BFA5' : $tone === 'offline' ? '#FF1744' : '#555'};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MetaRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentSection = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-md);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentCard = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
padding: var(--space-md) var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-md);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
|
|
||||||
@media (max-width: 389px) {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const AgentName = styled.div`
|
const NodeGroup = styled.div`
|
||||||
font-size: 13px;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TerminalCard = styled.div<{ $level: 'high' | 'mid' | 'low' | 'none' }>`
|
||||||
|
border: 1px solid ${({ $level }) => ({
|
||||||
|
high: '#f43f5e',
|
||||||
|
mid: '#3b82f6',
|
||||||
|
low: '#10b981',
|
||||||
|
none: '#525252',
|
||||||
|
})[$level]};
|
||||||
|
border-left-width: 3px;
|
||||||
|
padding: var(--space-md) var(--space-lg);
|
||||||
|
background: var(--bg-main);
|
||||||
|
min-width: 200px;
|
||||||
|
max-width: 260px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
||||||
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
|
position: relative;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
box-shadow: 0 12px 36px rgba(0,0,0,0.7);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeLabel = styled.div`
|
||||||
|
font-size: 14px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
`;
|
margin-bottom: var(--space-sm);
|
||||||
|
|
||||||
const AgentMeta = styled.div`
|
span {
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
`;
|
margin-right: var(--space-xs);
|
||||||
|
|
||||||
const EmptyState = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
font-family: var(--font-mono);
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: var(--text-secondary);
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const BadgeRow = styled.div`
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-xs);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Badge = styled.div`
|
||||||
|
background: #1a1a1a;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
padding: 2px 6px;
|
||||||
|
font-size: 9px;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-weight: 700;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.06em;
|
letter-spacing: 0.04em;
|
||||||
padding: var(--space-md) 0;
|
color: var(--text-secondary);
|
||||||
|
|
||||||
|
b { color: var(--text-primary); font-weight: normal; }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TreeConnector = styled.div`
|
||||||
|
width: 1px;
|
||||||
|
height: 24px;
|
||||||
|
background: var(--border-color);
|
||||||
|
margin: 0 auto;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TreeBranch = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TreeChildren = styled.div`
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-xl);
|
||||||
|
align-items: flex-start;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: calc(var(--space-xl) / 2 + 100px);
|
||||||
|
right: calc(var(--space-xl) / 2 + 100px);
|
||||||
|
height: 1px;
|
||||||
|
background: var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
|
||||||
|
&::before { display: none; }
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PageFooter = styled.footer`
|
const PageFooter = styled.footer`
|
||||||
@@ -334,175 +142,139 @@ const PageFooter = styled.footer`
|
|||||||
padding: var(--space-lg) 0;
|
padding: var(--space-lg) 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: var(--space-md);
|
|
||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
font-family: var(--font-mono);
|
font-family: var(--font-mono);
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// ─── Component ───
|
type Level = 'high' | 'mid' | 'low' | 'none';
|
||||||
|
|
||||||
|
interface OrgData {
|
||||||
|
owner: { name: string; role: string };
|
||||||
|
sisters: Array<{
|
||||||
|
name: string;
|
||||||
|
role: string;
|
||||||
|
description?: string;
|
||||||
|
status?: string;
|
||||||
|
lxcId?: number;
|
||||||
|
}>;
|
||||||
|
pipeline: Array<{ from: string; to: string; label: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LEVEL_MAP: Record<string, Level> = {
|
||||||
|
Orchestrator: 'high',
|
||||||
|
Generator: 'mid',
|
||||||
|
Evaluator: 'mid',
|
||||||
|
'Infra Manager': 'low',
|
||||||
|
};
|
||||||
|
|
||||||
|
const ROLE_TAG: Record<string, string> = {
|
||||||
|
Orchestrator: 'ORCH',
|
||||||
|
Generator: 'GEN',
|
||||||
|
Evaluator: 'EVAL',
|
||||||
|
'Infra Manager': 'INFRA',
|
||||||
|
};
|
||||||
|
|
||||||
|
const LXC_ID: Record<string, number> = {
|
||||||
|
harang: 104,
|
||||||
|
narang: 105,
|
||||||
|
darang: 106,
|
||||||
|
erang: 107,
|
||||||
|
};
|
||||||
|
|
||||||
export default function OrgPage() {
|
export default function OrgPage() {
|
||||||
const [orgData, setOrgData] = useState<OrgApiData | null>(null);
|
const [orgData, setOrgData] = useState<OrgData | null>(null);
|
||||||
const [dataSource, setDataSource] = useState<'live' | 'snapshot' | 'fallback'>('fallback');
|
const ts = new Date().toLocaleDateString('ko-KR').replace(/\. /g, '.').replace('.', '') + '_' +
|
||||||
|
new Date().toLocaleTimeString('ko-KR', { hour12: false, hour: '2-digit', minute: '2-digit' });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`${API_URL}/api/org`)
|
fetch(`${API_URL}/api/org`)
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((data) => {
|
.then(setOrgData)
|
||||||
setOrgData(data);
|
.catch(() => {});
|
||||||
setDataSource(data.orgUnits ? 'snapshot' : data.sisters?.length > 0 ? 'snapshot' : 'fallback');
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
setDataSource('fallback');
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { orgUnits, members, independentAgents } = orgData
|
const sisters = orgData?.sisters ?? [];
|
||||||
? buildOrgFromLegacy(orgData)
|
|
||||||
: { orgUnits: FALLBACK_ORG_UNITS, members: FALLBACK_MEMBERS, independentAgents: FALLBACK_INDEPENDENT_AGENTS };
|
|
||||||
|
|
||||||
const memberMap = new Map(members.map((m) => [m.id, m]));
|
|
||||||
const hqUnit = orgUnits.find((u) => u.kind === 'hq');
|
|
||||||
const functionalTeams = orgUnits.filter((u) => u.kind === 'functional_team');
|
|
||||||
|
|
||||||
const totalMembers = members.length;
|
|
||||||
const totalUnits = orgUnits.length;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Shell>
|
<MainViewport>
|
||||||
<OrgHeader>
|
<HeaderInfo>
|
||||||
<OrgTitle>조직도</OrgTitle>
|
<div>SYS_TYPE: <span>CORE_ROOT_01</span></div>
|
||||||
<OrgMeta>
|
<div>TIMESTAMP: <span style={{ color: 'var(--text-secondary)' }}>{ts}</span></div>
|
||||||
<OrgBadge $tone={dataSource === 'fallback' ? 'fallback' : 'default'}>
|
</HeaderInfo>
|
||||||
source: {dataSource}
|
|
||||||
</OrgBadge>
|
|
||||||
<OrgBadge $tone="default">{totalUnits} units</OrgBadge>
|
|
||||||
<OrgBadge $tone="default">{totalMembers} members</OrgBadge>
|
|
||||||
<OrgBadge $tone="default">{independentAgents.length} agents</OrgBadge>
|
|
||||||
</OrgMeta>
|
|
||||||
</OrgHeader>
|
|
||||||
|
|
||||||
{/* HQ Section */}
|
<TreeContainer>
|
||||||
{hqUnit && (
|
<NodeGroup>
|
||||||
<>
|
{/* HQ */}
|
||||||
<SectionLabel>HQ</SectionLabel>
|
<TerminalCard $level="high">
|
||||||
<HQCard>
|
<NodeLabel><span>[HQ]</span> 하나랑 글로벌</NodeLabel>
|
||||||
<TeamTitle>{hqUnit.name}</TeamTitle>
|
<BadgeRow>
|
||||||
<TeamLead>
|
<Badge>MEM: <b>{sisters.length + 1}</b></Badge>
|
||||||
{hqUnit.lead
|
<Badge>S_ADMIN</Badge>
|
||||||
? `LEAD: ${MEMBER_DISPLAY[hqUnit.lead] ?? hqUnit.lead}`
|
<Badge>LV_09</Badge>
|
||||||
: 'LEAD 미정'}
|
</BadgeRow>
|
||||||
</TeamLead>
|
</TerminalCard>
|
||||||
<MemberChipRow>
|
<TreeConnector />
|
||||||
{hqUnit.memberIds.map((id) => {
|
|
||||||
const member = memberMap.get(id);
|
|
||||||
const tone = member ? statusTone(member.status) : 'unknown';
|
|
||||||
return (
|
|
||||||
<MemberChip key={id} $tone={tone}>
|
|
||||||
<SisterAvatar name={id} size={20} />
|
|
||||||
<StatusDot $tone={tone} />
|
|
||||||
{MEMBER_DISPLAY[id] ?? id}
|
|
||||||
</MemberChip>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</MemberChipRow>
|
|
||||||
<MetaRow>
|
|
||||||
{hqUnit.memberIds.map((id) => {
|
|
||||||
const member = memberMap.get(id);
|
|
||||||
return (
|
|
||||||
<span key={id}>
|
|
||||||
{MEMBER_DISPLAY[id] ?? id}: {member ? statusLabel(member.status) : 'unknown'}
|
|
||||||
{LXC_ID[id] ? ` · LXC ${LXC_ID[id]}` : ''}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</MetaRow>
|
|
||||||
</HQCard>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Functional Teams */}
|
{/* 자매 레벨 */}
|
||||||
<SectionLabel>FUNCTIONAL TEAMS</SectionLabel>
|
<TreeBranch>
|
||||||
<TeamGrid>
|
<TreeChildren>
|
||||||
{functionalTeams.map((team) => (
|
{/* 하랑이 (Orchestrator) */}
|
||||||
<TeamCard key={team.id}>
|
{sisters.filter((s) => s.role === 'Orchestrator').map((s) => (
|
||||||
<TeamTitle>{team.name}</TeamTitle>
|
<NodeGroup key={s.name}>
|
||||||
<TeamLead>
|
<TerminalCard $level={LEVEL_MAP[s.role] ?? 'none'}>
|
||||||
{team.lead
|
<NodeLabel>
|
||||||
? `LEAD: ${MEMBER_DISPLAY[team.lead] ?? team.lead}`
|
<span>[{ROLE_TAG[s.role] ?? s.role}]</span>
|
||||||
: 'LEAD 미정'}
|
{s.name === 'harang' ? '하랑이' : s.name}
|
||||||
</TeamLead>
|
</NodeLabel>
|
||||||
<MemberChipRow>
|
<BadgeRow>
|
||||||
{team.memberIds.map((id) => {
|
<Badge>LXC: <b>{LXC_ID[s.name] ?? '---'}</b></Badge>
|
||||||
const member = memberMap.get(id);
|
<Badge>{ROLE_TAG[s.role] ?? s.role}</Badge>
|
||||||
const tone = member ? statusTone(member.status) : 'unknown';
|
<Badge>{s.status === 'online' ? 'ACTIVE' : s.status === 'offline' ? 'STBY' : 'RUN'}</Badge>
|
||||||
return (
|
</BadgeRow>
|
||||||
<MemberChip key={id} $tone={tone}>
|
</TerminalCard>
|
||||||
<SisterAvatar name={id} size={20} />
|
<TreeConnector />
|
||||||
<StatusDot $tone={tone} />
|
<TreeBranch>
|
||||||
{MEMBER_DISPLAY[id] ?? id}
|
<TreeChildren>
|
||||||
</MemberChip>
|
{/* 나랑/다랑/이랑 */}
|
||||||
);
|
{sisters.filter((s2) => s2.role !== 'Orchestrator').map((s2) => (
|
||||||
})}
|
<NodeGroup key={s2.name}>
|
||||||
</MemberChipRow>
|
<TerminalCard $level={LEVEL_MAP[s2.role] ?? 'none'}>
|
||||||
<MetaRow>
|
<NodeLabel>
|
||||||
{team.memberIds.map((id) => {
|
{s2.name === 'narang' ? '나랑이' : s2.name === 'darang' ? '다랑이' : '이랑이'}
|
||||||
const member = memberMap.get(id);
|
</NodeLabel>
|
||||||
return (
|
<BadgeRow>
|
||||||
<span key={id}>
|
<Badge>LXC: <b>{LXC_ID[s2.name] ?? '---'}</b></Badge>
|
||||||
{member?.role ?? 'unknown'}
|
<Badge>{ROLE_TAG[s2.role] ?? s2.role}</Badge>
|
||||||
{member ? ` · ${statusLabel(member.status)}` : ''}
|
<Badge>{s2.status === 'online' ? 'ON' : s2.status === 'offline' ? '--' : 'RUN'}</Badge>
|
||||||
{member ? ` · ${member.source}` : ''}
|
</BadgeRow>
|
||||||
</span>
|
</TerminalCard>
|
||||||
);
|
</NodeGroup>
|
||||||
})}
|
))}
|
||||||
<span>freshness: {formatFreshness(
|
</TreeChildren>
|
||||||
team.memberIds
|
</TreeBranch>
|
||||||
.map((id) => memberMap.get(id)?.freshness.lastSnapshotAt)
|
</NodeGroup>
|
||||||
.filter(Boolean)
|
|
||||||
.sort()
|
|
||||||
.at(-1) ?? null
|
|
||||||
)}</span>
|
|
||||||
</MetaRow>
|
|
||||||
</TeamCard>
|
|
||||||
))}
|
))}
|
||||||
</TeamGrid>
|
|
||||||
|
|
||||||
{/* Independent Agents */}
|
{/* Orchestrator 없을 때 fallback */}
|
||||||
<SectionLabel>INDEPENDENT AGENTS</SectionLabel>
|
{sisters.filter((s) => s.role === 'Orchestrator').length === 0 && (
|
||||||
<AgentSection>
|
<NodeGroup>
|
||||||
{independentAgents.length === 0 ? (
|
<TerminalCard $level="none">
|
||||||
<EmptyState>INDEPENDENT AGENTS 없음</EmptyState>
|
<NodeLabel>데이터 없음</NodeLabel>
|
||||||
) : (
|
<BadgeRow><Badge>N/A</Badge></BadgeRow>
|
||||||
independentAgents.map((agent) => (
|
</TerminalCard>
|
||||||
<AgentCard key={agent.id}>
|
</NodeGroup>
|
||||||
<div>
|
|
||||||
<AgentName>{agent.name}</AgentName>
|
|
||||||
<AgentMeta>
|
|
||||||
{agent.ownerSister
|
|
||||||
? `owner: ${MEMBER_DISPLAY[agent.ownerSister] ?? agent.ownerSister}`
|
|
||||||
: 'independent'}
|
|
||||||
</AgentMeta>
|
|
||||||
</div>
|
|
||||||
<MetaRow>
|
|
||||||
<span>source: {agent.source}</span>
|
|
||||||
</MetaRow>
|
|
||||||
</AgentCard>
|
|
||||||
))
|
|
||||||
)}
|
)}
|
||||||
</AgentSection>
|
</TreeChildren>
|
||||||
|
</TreeBranch>
|
||||||
|
</NodeGroup>
|
||||||
|
</TreeContainer>
|
||||||
|
|
||||||
<PageFooter>
|
<PageFooter>
|
||||||
<div>UNITS: {String(totalUnits).padStart(2, '0')}</div>
|
<div>TOTAL_NODES: {String(sisters.length + 1).padStart(2, '0')}</div>
|
||||||
<div>MEMBERS: {String(totalMembers).padStart(2, '0')}</div>
|
<div>STATUS: SYNC_COMPLETE</div>
|
||||||
<div>AGENTS: {String(independentAgents.length).padStart(2, '0')}</div>
|
|
||||||
<div>SOURCE: {dataSource.toUpperCase()}</div>
|
|
||||||
</PageFooter>
|
</PageFooter>
|
||||||
</Shell>
|
</MainViewport>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,348 +1,608 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useState, useCallback } from 'react';
|
||||||
import { useParams } from 'next/navigation';
|
import { useParams } from 'next/navigation';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { LabelMeta, PageTitle, SectionTitle, TechBar, TechBarFill, BtnToggle } from '@/components/ui/base';
|
import { LabelMeta, PageTitle, SectionTitle, TechBar, TechBarFill } from '@/components/ui/base';
|
||||||
import { API_URL } from '@/lib/config';
|
import { API_URL } from '@/lib/config';
|
||||||
import SisterAvatar from '@/components/common/SisterAvatar';
|
import SisterAvatar from '@/components/common/SisterAvatar';
|
||||||
|
|
||||||
interface TaskItem { id: number; taskId: string; title: string; assignee: string; status: string; }
|
// ─── Styled ───
|
||||||
interface SprintItem { id: number; number: number; name: string; status: string; progress: number; tasks: TaskItem[]; }
|
const Breadcrumb = styled.div`
|
||||||
interface HistoryItem { label: string; kind: 'sprint' | 'hotfix'; summary?: string | null; description?: string | null; }
|
font-family: var(--font-mono);
|
||||||
interface SisterState { name: string; status: string; }
|
font-size: 11px;
|
||||||
interface CommitItem { sha?: string; html_url?: string; commit?: { message?: string; author?: { date?: string; name?: string } }; author?: { login?: string } | null; }
|
color: var(--text-secondary);
|
||||||
interface BranchItem { name?: string; protected?: boolean; commit?: { id?: string } }
|
margin-bottom: var(--space-md);
|
||||||
interface PullItem { id?: number; number?: number; title?: string; html_url?: string; state?: string; merged?: boolean; user?: { login?: string }; created_at?: string; }
|
a { color: var(--text-secondary); text-decoration: none; &:hover { color: var(--text-primary); } }
|
||||||
interface ProjectDetail {
|
`;
|
||||||
id: number;
|
|
||||||
name: string;
|
const PageTitleRow = styled.div`
|
||||||
repoUrl: string;
|
display: flex;
|
||||||
status: string;
|
justify-content: space-between;
|
||||||
phase: string;
|
align-items: flex-start;
|
||||||
currentSprint?: string | null;
|
gap: var(--space-lg);
|
||||||
latestQa: { label: string | null; status: 'passed' | 'failed' | 'unknown'; blockerCount: number; summary: string | null } | null;
|
margin-bottom: var(--space-xl);
|
||||||
deploy: { branch: string; status: string; latestDeployAt: string | null; redeployRequired: boolean; note: string };
|
flex-wrap: wrap;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TabBar = styled.div`
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
margin-bottom: var(--space-xl);
|
||||||
|
overflow-x: auto;
|
||||||
|
scrollbar-width: none;
|
||||||
|
&::-webkit-scrollbar { display: none; }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TabBtn = styled.button<{ $active: boolean }>`
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: ${({ $active }) => $active ? 'var(--text-primary)' : 'var(--text-secondary)'};
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid ${({ $active }) => $active ? 'var(--text-primary)' : 'transparent'};
|
||||||
|
padding: var(--space-sm) 0;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: color 0.15s, border-color 0.15s;
|
||||||
|
&:hover { color: var(--text-primary); }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CommitTable = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
background: var(--bg-code);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CommitRow = styled.a`
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 80px 1fr 120px 100px;
|
||||||
|
gap: var(--space-md);
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #1a1a1a;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background 0.1s;
|
||||||
|
&:last-child { border-bottom: none; }
|
||||||
|
&:hover { background: #1a1a1a; }
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
grid-template-columns: 70px 1fr;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CommitHash = styled.span`
|
||||||
|
font-size: 12px;
|
||||||
|
color: #5fafff;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CommitMsg = styled.span`
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CommitMeta = styled.span`
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const BranchGrid = styled.div`
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||||
|
gap: var(--space-md);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const BranchCard = styled.div`
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
padding: var(--space-md) var(--space-lg);
|
||||||
|
transition: border-color 0.15s;
|
||||||
|
&:hover { border-color: var(--border-hover); }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const BranchName = styled.div`
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const BranchMeta = styled.div`
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PRList = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PRItem = styled.a`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-md);
|
||||||
|
padding: 12px var(--space-lg);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: border-color 0.15s;
|
||||||
|
&:hover { border-color: var(--border-hover); }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PRState = styled.span<{ $state: string }>`
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border: 1px solid;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
${({ $state }) => {
|
||||||
|
switch ($state) {
|
||||||
|
case 'open': return "color: #5fff8a; border-color: #5fff8a44;";
|
||||||
|
case 'closed': return "color: var(--text-secondary); border-color: var(--border-color);";
|
||||||
|
case 'merged': return "color: #5fafff; border-color: #5fafff44;";
|
||||||
|
default: return "color: var(--text-secondary); border-color: var(--border-color);";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PRTitle = styled.span`
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
flex: 1;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PRMeta = styled.span`
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
white-space: nowrap;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const FilterRow = styled.div`
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
margin-bottom: var(--space-lg);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const FilterBtn = styled.button<{ $active: boolean }>`
|
||||||
|
background: ${({ $active }) => $active ? 'var(--text-primary)' : 'transparent'};
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
color: ${({ $active }) => $active ? '#000' : 'var(--text-secondary)'};
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 4px 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
transition: all 0.15s;
|
||||||
|
&:hover { border-color: var(--border-hover); color: ${({ $active }) => $active ? '#000' : 'var(--text-primary)'}; }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Empty = styled.div`
|
||||||
|
padding: var(--space-xl) 0;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Phase timeline 컴포넌트들
|
||||||
|
const ProjectGrid = styled.div`
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 320px;
|
||||||
|
gap: var(--space-xxl);
|
||||||
|
align-items: start;
|
||||||
|
@media (max-width: 1199px) { grid-template-columns: 1fr; gap: var(--space-xl); }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PhaseTimeline = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
margin-bottom: var(--space-xl);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PhaseItem = styled.div`
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 100px 1fr;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
align-items: flex-start;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PhaseMeta = styled.div`
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
text-transform: uppercase;
|
||||||
|
line-height: 1.6;
|
||||||
|
padding-top: var(--space-sm);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PhaseBox = styled.div<{ $active?: boolean }>`
|
||||||
|
border: 1px solid ${({ $active }) => $active ? 'var(--border-hover)' : 'var(--border-color)'};
|
||||||
|
padding: var(--space-md) var(--space-lg);
|
||||||
|
background: ${({ $active }) => $active ? '#1a1a1a' : 'transparent'};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PhaseName = styled.div`
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-bottom: var(--space-xs);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PhaseDesc = styled.div`
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
line-height: 1.5;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeStack = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
margin-bottom: var(--space-xl);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeMiniCard = styled.div`
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
padding: var(--space-sm) var(--space-md);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-md);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeInfo = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
min-width: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeLabel = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
min-width: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeName = styled.div`
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeRole = styled.div`
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NodeDot = styled.div`
|
||||||
|
width: 6px; height: 6px;
|
||||||
|
background: #00FF00;
|
||||||
|
border-radius: 50%;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Checklist = styled.ul`
|
||||||
|
list-style: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CheckItem = styled.li<{ $done?: boolean }>`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-md);
|
||||||
|
padding: var(--space-sm) 0;
|
||||||
|
border-bottom: 1px solid #1a1a1a;
|
||||||
|
font-size: 13px;
|
||||||
|
color: ${({ $done }) => $done ? 'var(--text-secondary)' : 'var(--text-primary)'};
|
||||||
|
text-decoration: ${({ $done }) => $done ? 'line-through' : 'none'};
|
||||||
|
&:last-child { border-bottom: none; }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CheckBox = styled.div<{ $checked?: boolean }>`
|
||||||
|
width: 14px; height: 14px;
|
||||||
|
border: 1px solid ${({ $checked }) => $checked ? 'var(--text-primary)' : 'var(--border-color)'};
|
||||||
|
flex-shrink: 0;
|
||||||
|
background: ${({ $checked }) => $checked ? 'var(--text-primary)' : 'transparent'};
|
||||||
|
position: relative;
|
||||||
|
${({ $checked }) => $checked && `&::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #000; }`}
|
||||||
|
`;
|
||||||
|
|
||||||
|
// ─── Helpers ───
|
||||||
|
function getSprintMeta(sprint: any): { label: string; isActive: boolean } {
|
||||||
|
if (sprint.status === 'done') return { label: `COMPLETED`, isActive: false };
|
||||||
|
if (sprint.status === 'in_progress') return { label: 'IN PROGRESS', isActive: true };
|
||||||
|
return { label: 'PENDING', isActive: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
const Breadcrumb = styled.div`font-family:var(--font-mono);font-size:11px;color:var(--text-secondary);margin-bottom:var(--space-md);a{color:var(--text-secondary);text-decoration:none;&:hover{color:var(--text-primary);}}`;
|
function formatDate(str: string): string {
|
||||||
const PageTitleRow = styled.div`display:flex;justify-content:space-between;align-items:flex-start;gap:var(--space-lg);margin-bottom:var(--space-xl);flex-wrap:wrap;`;
|
return new Date(str).toLocaleDateString('ko-KR', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false });
|
||||||
const ProjectGrid = styled.div`display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:var(--space-xl);align-items:start;@media (max-width:1199px){display:flex;flex-direction:column;}`;
|
|
||||||
const Panel = styled.section<{ $column?: 'main' | 'side'; $mobileOrder?: number }>`border:1px solid var(--border-color);padding:var(--space-lg);background:var(--bg-surface);${({$column})=>$column==='side'?'grid-column:2;':'grid-column:1;'}@media (max-width:1199px){order:${({$mobileOrder=0})=>$mobileOrder};}`;
|
|
||||||
const FlowList = styled.div`display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:var(--space-sm);@media (max-width:767px){grid-template-columns:1fr;}`;
|
|
||||||
const FlowItem = styled.div<{ $active:boolean }>`border:1px solid ${({$active})=>$active?'var(--text-primary)':'var(--border-color)'};padding:var(--space-md);background:${({$active})=>$active?'#111':'transparent'};display:flex;flex-direction:column;gap:4px;`;
|
|
||||||
const LedgerList = styled.div`display:flex;flex-direction:column;gap:var(--space-md);`;
|
|
||||||
const LedgerItem = styled.div`display:flex;flex-direction:column;gap:8px;border-top:1px solid #1a1a1a;padding-top:var(--space-md);&:first-child{border-top:none;padding-top:0;}`;
|
|
||||||
const Meta = styled.div`font-size:11px;color:var(--text-secondary);font-family:var(--font-mono);`;
|
|
||||||
const NodeStack = styled.div`display:flex;flex-direction:column;gap:var(--space-sm);`;
|
|
||||||
const NodeMiniCard = styled.div`border:1px solid var(--border-color);padding:var(--space-sm) var(--space-md);display:flex;justify-content:space-between;align-items:center;gap:var(--space-md);`;
|
|
||||||
const NodeInfo = styled.div`display:flex;align-items:center;gap:var(--space-sm);`;
|
|
||||||
const NodeDot = styled.div<{ $status:string }>`width:8px;height:8px;border-radius:50%;background:${({$status})=>$status==='online'?'#00ff88':$status==='working'?'#5fafff':'#555'};`;
|
|
||||||
const Empty = styled.div`padding:var(--space-xl) 0;color:var(--text-secondary);font-size:13px;font-family:var(--font-mono);`;
|
|
||||||
const TabBar = styled.div`display:flex;gap:var(--space-sm);margin-bottom:var(--space-xl);flex-wrap:wrap;`;
|
|
||||||
const GitList = styled.div`display:flex;flex-direction:column;gap:var(--space-sm);`;
|
|
||||||
const GitItem = styled.a`border:1px solid var(--border-color);padding:12px var(--space-lg);text-decoration:none;color:var(--text-primary);display:flex;justify-content:space-between;gap:var(--space-md);align-items:center;`;
|
|
||||||
const GitPrimary = styled.div`display:flex;flex-direction:column;gap:4px;min-width:0;`;
|
|
||||||
const GitTitle = styled.div`font-size:13px;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;`;
|
|
||||||
|
|
||||||
const ParticipantSection = styled.div`display:flex;flex-direction:column;gap:var(--space-md);`;
|
|
||||||
const ParticipantCard = styled.div`border:1px solid var(--border-color);padding:var(--space-sm) var(--space-md);display:flex;flex-direction:column;gap:6px;`;
|
|
||||||
const ParticipantBadgeRow = styled.div`display:flex;gap:var(--space-xs);flex-wrap:wrap;`;
|
|
||||||
const WhyBadge = styled.span`font-family:var(--font-mono);font-size:9px;text-transform:uppercase;letter-spacing:0.06em;padding:2px 6px;border:1px solid #2979FF;color:#2979FF;white-space:nowrap;`;
|
|
||||||
const SourceBadge = styled.span`font-family:var(--font-mono);font-size:9px;text-transform:uppercase;letter-spacing:0.06em;padding:2px 6px;border:1px solid #777;color:#777;white-space:nowrap;`;
|
|
||||||
const EmptyParticipant = styled.div`font-family:var(--font-mono);font-size:11px;color:var(--text-secondary);text-transform:uppercase;letter-spacing:0.06em;padding:var(--space-md) 0;`;
|
|
||||||
|
|
||||||
const ROLE_LABEL: Record<string, string> = { harang: 'ORCHESTRATOR', narang: 'GENERATOR', darang: 'EVALUATOR', erang: 'INFRA' };
|
|
||||||
const ROLE_NAME: Record<string, string> = { harang: '하랑', narang: '나랑', darang: '다랑', erang: '이랑' };
|
|
||||||
|
|
||||||
function formatDate(value?: string | null): string {
|
|
||||||
if (!value) return '-';
|
|
||||||
return new Date(value).toLocaleString('ko-KR');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NODE_META = {
|
||||||
|
harang: { label: '하랑', role: 'PRIMARY' },
|
||||||
|
narang: { label: '나랑', role: 'GEN' },
|
||||||
|
darang: { label: '다랑', role: 'EVAL' },
|
||||||
|
erang: { label: '이랑', role: 'INFRA' },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const TABS = [
|
||||||
|
{ id: 'overview', label: 'Overview' },
|
||||||
|
{ id: 'commits', label: 'Commits' },
|
||||||
|
{ id: 'branches', label: 'Branches' },
|
||||||
|
{ id: 'prs', label: 'Pull Requests' },
|
||||||
|
];
|
||||||
|
|
||||||
export default function ProjectDetailPage() {
|
export default function ProjectDetailPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const [project, setProject] = useState<ProjectDetail | null>(null);
|
const [project, setProject] = useState<any>(null);
|
||||||
const [tasks, setTasks] = useState<SprintItem[]>([]);
|
const [tasks, setTasks] = useState<any[]>([]);
|
||||||
const [history, setHistory] = useState<HistoryItem[]>([]);
|
const [history, setHistory] = useState<any[]>([]);
|
||||||
const [sisters, setSisters] = useState<SisterState[]>([]);
|
const [commits, setCommits] = useState<any[]>([]);
|
||||||
const [commits, setCommits] = useState<CommitItem[]>([]);
|
const [branches, setBranches] = useState<any[]>([]);
|
||||||
const [branches, setBranches] = useState<BranchItem[]>([]);
|
const [pulls, setPulls] = useState<any[]>([]);
|
||||||
const [pulls, setPulls] = useState<PullItem[]>([]);
|
const [prFilter, setPrFilter] = useState<'open' | 'closed' | 'all'>('open');
|
||||||
const [tab, setTab] = useState<'overview'|'commits'|'branches'|'prs'>('overview');
|
const [tab, setTab] = useState('overview');
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [tabLoading, setTabLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Promise.allSettled([
|
Promise.allSettled([
|
||||||
fetch(`${API_URL}/api/projects/${id}`),
|
fetch(`${API_URL}/api/projects/${id}`),
|
||||||
fetch(`${API_URL}/api/projects/${id}/tasks`),
|
fetch(`${API_URL}/api/projects/${id}/tasks`),
|
||||||
fetch(`${API_URL}/api/projects/${id}/history`),
|
fetch(`${API_URL}/api/projects/${id}/history`),
|
||||||
fetch(`${API_URL}/api/sisters`),
|
]).then(([pRes, tRes, hRes]) => {
|
||||||
]).then(async ([projectRes, tasksRes, historyRes, sistersRes]) => {
|
if (pRes.status === 'fulfilled' && pRes.value.ok) pRes.value.json().then(setProject);
|
||||||
if (projectRes.status === 'fulfilled' && projectRes.value.ok) setProject(await projectRes.value.json());
|
if (tRes.status === 'fulfilled' && tRes.value.ok) tRes.value.json().then(setTasks);
|
||||||
if (tasksRes.status === 'fulfilled' && tasksRes.value.ok) setTasks(await tasksRes.value.json());
|
if (hRes.status === 'fulfilled' && hRes.value.ok) hRes.value.json().then(setHistory);
|
||||||
if (historyRes.status === 'fulfilled' && historyRes.value.ok) setHistory(await historyRes.value.json());
|
|
||||||
if (sistersRes.status === 'fulfilled' && sistersRes.value.ok) setSisters(await sistersRes.value.json());
|
|
||||||
}).finally(() => setLoading(false));
|
}).finally(() => setLoading(false));
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
|
const loadCommits = useCallback(async () => {
|
||||||
|
setTabLoading(true);
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/api/projects/${id}/commits?limit=30`);
|
||||||
|
if (res.ok) setCommits(await res.json());
|
||||||
|
} finally { setTabLoading(false); }
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadBranches = useCallback(async () => {
|
||||||
|
setTabLoading(true);
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/api/projects/${id}/branches`);
|
||||||
|
if (res.ok) setBranches(await res.json());
|
||||||
|
} finally { setTabLoading(false); }
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadPulls = useCallback(async (state: 'open' | 'closed' | 'all') => {
|
||||||
|
setTabLoading(true);
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/api/projects/${id}/pulls?state=${state}`);
|
||||||
|
if (res.ok) setPulls(await res.json());
|
||||||
|
} finally { setTabLoading(false); }
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tab === 'commits' && commits.length === 0) fetch(`${API_URL}/api/projects/${id}/commits?limit=20`).then((r) => r.ok ? r.json() : []).then(setCommits).catch(() => {});
|
if (tab === 'commits' && commits.length === 0) loadCommits();
|
||||||
if (tab === 'branches' && branches.length === 0) fetch(`${API_URL}/api/projects/${id}/branches`).then((r) => r.ok ? r.json() : []).then(setBranches).catch(() => {});
|
if (tab === 'branches' && branches.length === 0) loadBranches();
|
||||||
if (tab === 'prs' && pulls.length === 0) fetch(`${API_URL}/api/projects/${id}/pulls?state=all`).then((r) => r.ok ? r.json() : []).then(setPulls).catch(() => {});
|
if (tab === 'prs' && pulls.length === 0) loadPulls(prFilter);
|
||||||
}, [tab, id, commits.length, branches.length, pulls.length]);
|
}, [tab]);
|
||||||
|
|
||||||
const allTasks = useMemo(() => tasks.flatMap((sprint) => sprint.tasks ?? []), [tasks]);
|
useEffect(() => {
|
||||||
const participantModel = useMemo(() => {
|
if (tab === 'prs') loadPulls(prFilter);
|
||||||
const taskAssigneeNames = Array.from(new Set(allTasks.map((task) => task.assignee).filter(Boolean)));
|
}, [prFilter]);
|
||||||
const taskCountByAssignee: Record<string, number> = {};
|
|
||||||
for (const task of allTasks) {
|
|
||||||
if (task.assignee) {
|
|
||||||
taskCountByAssignee[task.assignee] = (taskCountByAssignee[task.assignee] ?? 0) + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const participants: { name: string; whyVisible: string[]; source: string; status: string }[] = [];
|
const allTasks = tasks.flatMap((s: any) => s.tasks ?? []);
|
||||||
for (const name of taskAssigneeNames) {
|
const activeSprint = tasks.find((s: any) => s.status === 'in_progress');
|
||||||
const reasons: string[] = [];
|
const assignedNodeNames = Array.from(new Set(allTasks.map((task: any) => task.assignee).filter(Boolean)));
|
||||||
if (taskCountByAssignee[name]) reasons.push('task_assignee');
|
const assignedNodes = (assignedNodeNames.length > 0 ? assignedNodeNames : ['harang', 'narang', 'darang', 'erang']).map((name) => ({
|
||||||
const sisterStatus = sisters.find((s) => s.name === name)?.status ?? 'offline';
|
|
||||||
if (sisterStatus === 'working' || sisterStatus === 'online') reasons.push('current_implementer');
|
|
||||||
participants.push({
|
|
||||||
name,
|
name,
|
||||||
whyVisible: reasons.length > 0 ? reasons : ['task_assignee'],
|
label: NODE_META[name as keyof typeof NODE_META]?.label ?? name,
|
||||||
source: 'snapshot',
|
role: NODE_META[name as keyof typeof NODE_META]?.role ?? 'NODE',
|
||||||
status: sisterStatus,
|
}));
|
||||||
});
|
const hotfixEntries = history.filter((entry: any) => entry.kind === 'hotfix');
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
currentOwners: [] as { name: string; source: string }[],
|
|
||||||
participants,
|
|
||||||
taskAssignees: taskAssigneeNames.map((name) => ({
|
|
||||||
name,
|
|
||||||
taskCount: taskCountByAssignee[name] ?? 0,
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
}, [allTasks, sisters]);
|
|
||||||
const hotfixes = history.filter((entry) => entry.kind === 'hotfix');
|
|
||||||
const currentSprintMeta = useMemo(() => {
|
|
||||||
if (project?.currentSprint) return project.currentSprint;
|
|
||||||
|
|
||||||
const activeSprint = tasks.find((sprint) => sprint.status === 'in_progress');
|
|
||||||
if (activeSprint) return activeSprint.name || String(activeSprint.number).padStart(2, '0');
|
|
||||||
|
|
||||||
const latestSprint = tasks.at(-1);
|
|
||||||
if (latestSprint?.status === 'done') return 'COMPLETED';
|
|
||||||
if (latestSprint) return latestSprint.name || String(latestSprint.number).padStart(2, '0');
|
|
||||||
|
|
||||||
return 'BACKLOG';
|
|
||||||
}, [project, tasks]);
|
|
||||||
|
|
||||||
if (loading) return <Empty>LOADING...</Empty>;
|
if (loading) return <Empty>LOADING...</Empty>;
|
||||||
if (!project) return <Empty>PROJECT NOT FOUND</Empty>;
|
if (!project) return <Empty>PROJECT NOT FOUND</Empty>;
|
||||||
|
|
||||||
const flowStates = [
|
|
||||||
{ key: 'PLANNING', title: 'Planning', active: project.phase === 'PLANNING' },
|
|
||||||
{ key: 'IMPLEMENT', title: 'Implement', active: project.phase === 'IMPLEMENT' },
|
|
||||||
{ key: 'QA', title: 'QA', active: project.phase === 'QA' },
|
|
||||||
{ key: 'READY FOR DEPLOY', title: 'Merge to Main', active: project.phase === 'READY FOR DEPLOY' },
|
|
||||||
{ key: 'DEPLOYED', title: 'Redeploy', active: project.phase === 'DEPLOYED' },
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumb><Link href="/projects">PROJECTS</Link> / P-{String(project.id).padStart(3, '0')} / {project.name}</Breadcrumb>
|
<Breadcrumb>
|
||||||
|
<Link href="/projects">PROJECTS</Link> / P-{String(project.id).padStart(3, '0')} / {project.name}
|
||||||
|
</Breadcrumb>
|
||||||
<PageTitleRow>
|
<PageTitleRow>
|
||||||
<PageTitle>
|
<PageTitle>
|
||||||
{project.name}
|
{project.name}
|
||||||
{project.repoUrl && <a href={project.repoUrl} target="_blank" rel="noopener" style={{ fontSize: '12px', color: '#5fafff', marginLeft: 'var(--space-md)', fontWeight: 400 }}>↗ GITEA</a>}
|
{project.repoUrl && (
|
||||||
|
<a href={project.repoUrl} target="_blank" rel="noopener"
|
||||||
|
style={{ fontSize: '12px', color: '#5fafff', marginLeft: 'var(--space-md)', fontWeight: 400 }}>
|
||||||
|
↗ GITEA
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</PageTitle>
|
</PageTitle>
|
||||||
<LabelMeta><span>STATUS:</span>{project.status?.toUpperCase()} / <span>SPRINT:</span>{currentSprintMeta} / <span>DEPLOY:</span>{project.deploy.status}</LabelMeta>
|
<LabelMeta><span>STATUS:</span>{project.status?.toUpperCase()} / {activeSprint?.name ?? 'PLANNING'}</LabelMeta>
|
||||||
</PageTitleRow>
|
</PageTitleRow>
|
||||||
|
|
||||||
<TabBar>
|
<TabBar>
|
||||||
<BtnToggle $active={tab === 'overview'} onClick={() => setTab('overview')}>Overview</BtnToggle>
|
{TABS.map((t) => (
|
||||||
<BtnToggle $active={tab === 'commits'} onClick={() => setTab('commits')}>Commits</BtnToggle>
|
<TabBtn key={t.id} $active={tab === t.id} onClick={() => setTab(t.id)}>
|
||||||
<BtnToggle $active={tab === 'branches'} onClick={() => setTab('branches')}>Branches</BtnToggle>
|
{t.label}
|
||||||
<BtnToggle $active={tab === 'prs'} onClick={() => setTab('prs')}>Pull Requests</BtnToggle>
|
</TabBtn>
|
||||||
|
))}
|
||||||
</TabBar>
|
</TabBar>
|
||||||
|
|
||||||
|
{/* OVERVIEW */}
|
||||||
{tab === 'overview' && (
|
{tab === 'overview' && (
|
||||||
<ProjectGrid>
|
<ProjectGrid>
|
||||||
<Panel $column="main" $mobileOrder={1}>
|
|
||||||
<SectionTitle><span>DELIVERY FLOW</span><LabelMeta>{project.phase}</LabelMeta></SectionTitle>
|
|
||||||
<FlowList>
|
|
||||||
{flowStates.map((item) => (
|
|
||||||
<FlowItem key={item.key} $active={item.active}>
|
|
||||||
<LabelMeta>{item.title}</LabelMeta>
|
|
||||||
<Meta>{item.key}</Meta>
|
|
||||||
</FlowItem>
|
|
||||||
))}
|
|
||||||
</FlowList>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<Panel $column="side" $mobileOrder={2}>
|
|
||||||
<SectionTitle><span>QA STATUS</span><LabelMeta>{project.latestQa?.status ?? 'unknown'}</LabelMeta></SectionTitle>
|
|
||||||
<Meta>{project.latestQa?.label ?? 'QA 문서 없음'}</Meta>
|
|
||||||
<div style={{ marginTop: 'var(--space-md)', fontSize: '13px', color: 'var(--text-primary)' }}>{project.latestQa?.summary ?? 'latest QA 없음'}</div>
|
|
||||||
<Meta style={{ marginTop: 'var(--space-md)' }}>{project.latestQa?.status === 'passed' ? 'QA PASSED' : project.latestQa?.status === 'failed' ? `QA FAILED · ${project.latestQa.blockerCount} BLOCKERS` : 'QA PENDING'}</Meta>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<Panel $column="side" $mobileOrder={3}>
|
|
||||||
<SectionTitle><span>DEPLOY STATUS</span><LabelMeta>{project.deploy.branch}</LabelMeta></SectionTitle>
|
|
||||||
<Meta>{project.deploy.status}</Meta>
|
|
||||||
<Meta style={{ marginTop: 'var(--space-sm)' }}>{project.deploy.note}</Meta>
|
|
||||||
<Meta style={{ marginTop: 'var(--space-sm)' }}>{project.deploy.latestDeployAt ? formatDate(project.deploy.latestDeployAt) : 'LAST DEPLOY UNKNOWN'}</Meta>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<Panel $column="main" $mobileOrder={4}>
|
|
||||||
<SectionTitle><span>SPRINT LEDGER</span><LabelMeta>{tasks.length} SPRINTS</LabelMeta></SectionTitle>
|
|
||||||
<LedgerList>
|
|
||||||
{tasks.map((sprint) => (
|
|
||||||
<LedgerItem key={sprint.id}>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', gap: 'var(--space-md)', flexWrap: 'wrap' }}>
|
|
||||||
<div>
|
<div>
|
||||||
<div style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-primary)' }}>SPRINT {String(sprint.number).padStart(2, '0')} · {sprint.name}</div>
|
<SectionTitle>
|
||||||
<Meta>{sprint.tasks?.length ?? 0} TASKS · {sprint.tasks?.filter((task) => task.status === 'done').length ?? 0} DONE</Meta>
|
<span>PHASE TIMELINE</span>
|
||||||
|
<LabelMeta>CURRENT: {activeSprint ? `S${activeSprint.number}` : 'N/A'}</LabelMeta>
|
||||||
|
</SectionTitle>
|
||||||
|
<PhaseTimeline>
|
||||||
|
{tasks.map((sprint: any) => {
|
||||||
|
const { label, isActive } = getSprintMeta(sprint);
|
||||||
|
return (
|
||||||
|
<PhaseItem key={sprint.id}>
|
||||||
|
<PhaseMeta>{label}</PhaseMeta>
|
||||||
|
<PhaseBox $active={isActive}>
|
||||||
|
<PhaseName>SPRINT {String(sprint.number).padStart(2, '0')}: {sprint.name}</PhaseName>
|
||||||
|
<PhaseDesc>태스크 {sprint.tasks?.length ?? 0}개 · 완료 {sprint.tasks?.filter((t: any) => t.status === 'done').length ?? 0}개</PhaseDesc>
|
||||||
|
<TechBar style={{ marginTop: 'var(--space-sm)' }}>
|
||||||
|
<TechBarFill $width={sprint.progress ?? 0} />
|
||||||
|
</TechBar>
|
||||||
|
</PhaseBox>
|
||||||
|
</PhaseItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{tasks.length === 0 && history.filter((entry: any) => entry.kind !== 'hotfix').length === 0 && <PhaseItem><PhaseMeta>PENDING</PhaseMeta><PhaseBox><PhaseName>Sprint 없음</PhaseName></PhaseBox></PhaseItem>}
|
||||||
|
</PhaseTimeline>
|
||||||
</div>
|
</div>
|
||||||
<LabelMeta>{sprint.status}</LabelMeta>
|
|
||||||
</div>
|
|
||||||
<TechBar><TechBarFill $width={sprint.progress ?? 0} /></TechBar>
|
|
||||||
</LedgerItem>
|
|
||||||
))}
|
|
||||||
{tasks.length === 0 && <Empty>NO SPRINTS</Empty>}
|
|
||||||
</LedgerList>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<Panel $column="main" $mobileOrder={5}>
|
|
||||||
<SectionTitle><span>HOTFIX HISTORY</span><LabelMeta>{hotfixes.length} ITEMS</LabelMeta></SectionTitle>
|
|
||||||
<LedgerList>
|
|
||||||
{hotfixes.map((entry) => (
|
|
||||||
<LedgerItem key={entry.label}>
|
|
||||||
<div style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-primary)' }}>{entry.label}</div>
|
|
||||||
<Meta>{entry.summary ?? entry.description ?? 'hotfix summary 없음'}</Meta>
|
|
||||||
</LedgerItem>
|
|
||||||
))}
|
|
||||||
{hotfixes.length === 0 && <Empty>NO HOTFIX HISTORY</Empty>}
|
|
||||||
</LedgerList>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<Panel $column="side" $mobileOrder={6}>
|
|
||||||
<SectionTitle><span>CURRENT OWNERS</span><LabelMeta>SNAPSHOT</LabelMeta></SectionTitle>
|
|
||||||
<ParticipantSection>
|
|
||||||
{participantModel.currentOwners.length === 0 ? (
|
|
||||||
<EmptyParticipant>NO ACTIVE OWNER</EmptyParticipant>
|
|
||||||
) : (
|
|
||||||
participantModel.currentOwners.map((owner) => (
|
|
||||||
<NodeMiniCard key={owner.name}>
|
|
||||||
<NodeInfo>
|
|
||||||
<SisterAvatar name={owner.name} size={28} />
|
|
||||||
<div>
|
<div>
|
||||||
<div style={{ fontSize: '13px', color: 'var(--text-primary)', fontWeight: 600 }}>{ROLE_NAME[owner.name] ?? owner.name}</div>
|
{hotfixEntries.length > 0 && (
|
||||||
<Meta>{ROLE_LABEL[owner.name] ?? 'OWNER'}</Meta>
|
<>
|
||||||
</div>
|
<SectionTitle style={{ marginBottom: 'var(--space-md)' }}>HOTFIX HISTORY</SectionTitle>
|
||||||
</NodeInfo>
|
<PhaseTimeline style={{ marginBottom: 'var(--space-xl)' }}>
|
||||||
<SourceBadge>{owner.source}</SourceBadge>
|
{hotfixEntries.map((entry: any) => (
|
||||||
</NodeMiniCard>
|
<PhaseItem key={entry.label}>
|
||||||
))
|
<PhaseMeta>HOTFIX</PhaseMeta>
|
||||||
|
<PhaseBox $active={false}>
|
||||||
|
<PhaseName>{entry.label}</PhaseName>
|
||||||
|
<PhaseDesc>{entry.summary ?? entry.description ?? '보정/수정 이력'}</PhaseDesc>
|
||||||
|
</PhaseBox>
|
||||||
|
</PhaseItem>
|
||||||
|
))}
|
||||||
|
</PhaseTimeline>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</ParticipantSection>
|
<SectionTitle style={{ marginBottom: 'var(--space-md)' }}>ASSIGNED NODES</SectionTitle>
|
||||||
|
|
||||||
<SectionTitle style={{ marginTop: 'var(--space-lg)' }}><span>PARTICIPANTS</span><LabelMeta>SNAPSHOT</LabelMeta></SectionTitle>
|
|
||||||
<ParticipantSection>
|
|
||||||
{participantModel.participants.length === 0 ? (
|
|
||||||
<EmptyParticipant>NO CONFIRMED ACTIVE PARTICIPANT</EmptyParticipant>
|
|
||||||
) : (
|
|
||||||
participantModel.participants.map((p) => (
|
|
||||||
<ParticipantCard key={p.name}>
|
|
||||||
<NodeInfo>
|
|
||||||
<SisterAvatar name={p.name} size={28} />
|
|
||||||
<div>
|
|
||||||
<div style={{ fontSize: '13px', color: 'var(--text-primary)', fontWeight: 600 }}>{ROLE_NAME[p.name] ?? p.name}</div>
|
|
||||||
<Meta>{ROLE_LABEL[p.name] ?? 'PARTICIPANT'}</Meta>
|
|
||||||
</div>
|
|
||||||
</NodeInfo>
|
|
||||||
<ParticipantBadgeRow>
|
|
||||||
{p.whyVisible.map((reason) => (
|
|
||||||
<WhyBadge key={reason}>{reason}</WhyBadge>
|
|
||||||
))}
|
|
||||||
<SourceBadge>{p.source}</SourceBadge>
|
|
||||||
</ParticipantBadgeRow>
|
|
||||||
</ParticipantCard>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</ParticipantSection>
|
|
||||||
|
|
||||||
<SectionTitle style={{ marginTop: 'var(--space-lg)' }}><span>TASK ASSIGNEES</span><LabelMeta>{participantModel.taskAssignees.length} ASSIGNEES</LabelMeta></SectionTitle>
|
|
||||||
<ParticipantSection>
|
|
||||||
{participantModel.taskAssignees.length === 0 ? (
|
|
||||||
<EmptyParticipant>NO TASK ASSIGNEE DATA</EmptyParticipant>
|
|
||||||
) : (
|
|
||||||
<NodeStack>
|
<NodeStack>
|
||||||
{participantModel.taskAssignees.map((a) => (
|
{assignedNodes.map((node) => (
|
||||||
<NodeMiniCard key={a.name}>
|
<NodeMiniCard key={node.name}>
|
||||||
<NodeInfo>
|
<NodeInfo>
|
||||||
<SisterAvatar name={a.name} size={28} />
|
<SisterAvatar name={node.name} size={28} />
|
||||||
<div>
|
<NodeLabel>
|
||||||
<div style={{ fontSize: '13px', color: 'var(--text-primary)', fontWeight: 600 }}>{ROLE_NAME[a.name] ?? a.name}</div>
|
<NodeName>{node.label}</NodeName>
|
||||||
<Meta>{a.taskCount} TASKS</Meta>
|
<NodeRole>[{node.role}]</NodeRole>
|
||||||
</div>
|
</NodeLabel>
|
||||||
</NodeInfo>
|
</NodeInfo>
|
||||||
<SourceBadge>snapshot</SourceBadge>
|
<NodeDot />
|
||||||
</NodeMiniCard>
|
</NodeMiniCard>
|
||||||
))}
|
))}
|
||||||
</NodeStack>
|
</NodeStack>
|
||||||
)}
|
|
||||||
</ParticipantSection>
|
<SectionTitle>TASK CHECKLIST</SectionTitle>
|
||||||
</Panel>
|
<Checklist>
|
||||||
|
{allTasks.slice(0, 8).map((task: any) => (
|
||||||
|
<CheckItem key={task.id} $done={task.status === 'done'}>
|
||||||
|
<CheckBox $checked={task.status === 'done'} />
|
||||||
|
<span>[{task.taskId}] {task.title}</span>
|
||||||
|
</CheckItem>
|
||||||
|
))}
|
||||||
|
{allTasks.length === 0 && <CheckItem><CheckBox /><span style={{ color: 'var(--text-secondary)' }}>태스크 없음</span></CheckItem>}
|
||||||
|
</Checklist>
|
||||||
|
</div>
|
||||||
</ProjectGrid>
|
</ProjectGrid>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* COMMITS */}
|
||||||
{tab === 'commits' && (
|
{tab === 'commits' && (
|
||||||
<GitList>
|
<>
|
||||||
{commits.map((commit) => (
|
{tabLoading ? <Empty>LOADING COMMITS...</Empty> : (
|
||||||
<GitItem key={commit.sha} href={commit.html_url ?? '#'} target="_blank" rel="noopener">
|
<>
|
||||||
<GitPrimary>
|
<CommitTable>
|
||||||
<GitTitle>{commit.commit?.message?.split('\n')[0] ?? commit.sha ?? 'UNKNOWN COMMIT'}</GitTitle>
|
{commits.length === 0 ? (
|
||||||
<Meta>{commit.commit?.author?.name ?? commit.author?.login ?? '-'}</Meta>
|
<div style={{ padding: 'var(--space-xl)', color: 'var(--text-secondary)', fontSize: '12px', textAlign: 'center', fontFamily: 'var(--font-mono)' }}>NO COMMITS</div>
|
||||||
</GitPrimary>
|
) : (
|
||||||
<Meta>{commit.sha?.slice(0, 7) ?? '-'} · {formatDate(commit.commit?.author?.date)}</Meta>
|
commits.map((c: any) => (
|
||||||
</GitItem>
|
<CommitRow key={c.sha} href={c.html_url} target="_blank" rel="noopener">
|
||||||
))}
|
<CommitHash>{c.sha?.slice(0, 7)}</CommitHash>
|
||||||
{commits.length === 0 && <Empty>NO COMMITS</Empty>}
|
<CommitMsg>{c.commit?.message?.split('\n')[0]}</CommitMsg>
|
||||||
</GitList>
|
<CommitMeta style={{ display: 'var(--media-hide, initial)' }}>
|
||||||
|
{c.commit?.author?.name ?? c.author?.login ?? '-'}
|
||||||
|
</CommitMeta>
|
||||||
|
<CommitMeta>
|
||||||
|
{c.commit?.author?.date ? formatDate(c.commit.author.date) : '-'}
|
||||||
|
</CommitMeta>
|
||||||
|
</CommitRow>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</CommitTable>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* BRANCHES */}
|
||||||
{tab === 'branches' && (
|
{tab === 'branches' && (
|
||||||
<GitList>
|
<>
|
||||||
{branches.map((branch) => (
|
{tabLoading ? <Empty>LOADING BRANCHES...</Empty> : (
|
||||||
<GitItem key={branch.name} href={project.repoUrl} target="_blank" rel="noopener">
|
<BranchGrid>
|
||||||
<GitPrimary>
|
{branches.length === 0 ? (
|
||||||
<GitTitle>{branch.name ?? 'UNKNOWN BRANCH'}</GitTitle>
|
<Empty>NO BRANCHES</Empty>
|
||||||
<Meta>{branch.protected ? 'PROTECTED' : 'ACTIVE BRANCH'}</Meta>
|
) : (
|
||||||
</GitPrimary>
|
branches.map((b: any) => (
|
||||||
<Meta>{branch.commit?.id?.slice(0, 7) ?? '-'}</Meta>
|
<BranchCard key={b.name}>
|
||||||
</GitItem>
|
<BranchName>{b.name}</BranchName>
|
||||||
))}
|
<BranchMeta>
|
||||||
{branches.length === 0 && <Empty>NO BRANCHES</Empty>}
|
{b.commit?.id?.slice(0, 7) ?? '-'}
|
||||||
</GitList>
|
{b.protected && ' · PROTECTED'}
|
||||||
|
</BranchMeta>
|
||||||
|
</BranchCard>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</BranchGrid>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* PULL REQUESTS */}
|
||||||
{tab === 'prs' && (
|
{tab === 'prs' && (
|
||||||
<GitList>
|
<>
|
||||||
{pulls.map((pull) => (
|
<FilterRow>
|
||||||
<GitItem key={pull.id} href={pull.html_url ?? '#'} target="_blank" rel="noopener">
|
{(['open', 'closed', 'all'] as const).map((s) => (
|
||||||
<GitPrimary>
|
<FilterBtn key={s} $active={prFilter === s} onClick={() => setPrFilter(s)}>
|
||||||
<GitTitle>#{pull.number ?? '-'} {pull.title ?? 'UNKNOWN PR'}</GitTitle>
|
{s.toUpperCase()}
|
||||||
<Meta>{pull.user?.login ?? '-'} · {pull.merged ? 'MERGED' : pull.state?.toUpperCase() ?? 'UNKNOWN'}</Meta>
|
</FilterBtn>
|
||||||
</GitPrimary>
|
|
||||||
<Meta>{formatDate(pull.created_at)}</Meta>
|
|
||||||
</GitItem>
|
|
||||||
))}
|
))}
|
||||||
{pulls.length === 0 && <Empty>NO PULL REQUESTS</Empty>}
|
</FilterRow>
|
||||||
</GitList>
|
{tabLoading ? <Empty>LOADING PULL REQUESTS...</Empty> : (
|
||||||
|
<PRList>
|
||||||
|
{pulls.length === 0 ? (
|
||||||
|
<Empty>NO PULL REQUESTS ({prFilter})</Empty>
|
||||||
|
) : (
|
||||||
|
pulls.map((pr: any) => (
|
||||||
|
<PRItem key={pr.id} href={pr.html_url} target="_blank" rel="noopener">
|
||||||
|
<PRState $state={pr.merged ? 'merged' : pr.state}>
|
||||||
|
{pr.merged ? 'MERGED' : pr.state?.toUpperCase()}
|
||||||
|
</PRState>
|
||||||
|
<PRTitle>#{pr.number} {pr.title}</PRTitle>
|
||||||
|
<PRMeta>{pr.user?.login ?? '-'} · {pr.created_at ? formatDate(pr.created_at) : '-'}</PRMeta>
|
||||||
|
</PRItem>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</PRList>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,40 +7,21 @@ import { PageTitle, LabelMeta, TechBar, TechBarFill, Btn } from '@/components/ui
|
|||||||
import { API_URL } from '@/lib/config';
|
import { API_URL } from '@/lib/config';
|
||||||
import { adminFetch } from '@/lib/adminFetch';
|
import { adminFetch } from '@/lib/adminFetch';
|
||||||
|
|
||||||
interface ProjectListItem {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
description: string | null;
|
|
||||||
progress: number;
|
|
||||||
phase: string;
|
|
||||||
currentSprint: string | null;
|
|
||||||
latestHotfix: string | null;
|
|
||||||
latestQaLabel: string | null;
|
|
||||||
latestQaStatus: 'passed' | 'failed' | 'unknown';
|
|
||||||
blockerCount: number;
|
|
||||||
deployStatus: string;
|
|
||||||
updatedAt: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ProjectList = styled.div`display:flex;flex-direction:column;gap:var(--space-md);`;
|
const ProjectList = styled.div`display:flex;flex-direction:column;gap:var(--space-md);`;
|
||||||
const ProjectRow = styled(Link)`display:grid;grid-template-columns:1.2fr 1fr 220px;gap:var(--space-lg);padding:var(--space-lg);border:1px solid var(--border-color);align-items:center;text-decoration:none;transition:border-color .15s, background .15s;&:hover{border-color:var(--border-hover);background:#111}@media (max-width:1199px){grid-template-columns:1fr;}`;
|
const ProjectRow = styled(Link)`display:grid;grid-template-columns:1.4fr 1fr 180px;gap:var(--space-lg);padding:var(--space-lg);border:1px solid var(--border-color);align-items:center;text-decoration:none;transition:border-color .15s, background .15s;&:hover{border-color:var(--border-hover);background:#111}@media (max-width:1199px){grid-template-columns:1fr;}`;
|
||||||
const Left = styled.div`display:flex;flex-direction:column;gap:6px;min-width:0;`;
|
const Left = styled.div`display:flex;align-items:flex-start;gap:var(--space-md);min-width:0;`;
|
||||||
const ProjectName = styled.div`font-size:15px;font-weight:600;color:var(--text-primary);`;
|
const ProjectMark = styled.div`width:40px;height:40px;border-radius:10px;border:1px solid var(--border-color);display:flex;align-items:center;justify-content:center;font-family:var(--font-mono);font-size:14px;color:var(--text-secondary);background:#111;flex-shrink:0;`;
|
||||||
|
const NameBlock = styled.div`display:flex;flex-direction:column;gap:4px;min-width:0;`;
|
||||||
|
const ProjectName = styled.div`font-size:15px;font-weight:600;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;`;
|
||||||
const ProjectDesc = styled.div`font-size:12px;color:var(--text-secondary);line-height:1.5;`;
|
const ProjectDesc = styled.div`font-size:12px;color:var(--text-secondary);line-height:1.5;`;
|
||||||
const Middle = styled.div`display:flex;flex-direction:column;gap:10px;`;
|
const Middle = styled.div`display:flex;flex-direction:column;gap:8px;`;
|
||||||
const Right = styled.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;@media (max-width:1199px){align-items:flex-start;}`;
|
const ProgressRow = styled.div`display:flex;align-items:center;gap:var(--space-sm);`;
|
||||||
|
const Right = styled.div`display:flex;flex-direction:column;align-items:flex-end;gap:8px;@media (max-width:1199px){align-items:flex-start;}`;
|
||||||
const Meta = styled.div`font-size:11px;color:var(--text-secondary);font-family:var(--font-mono);`;
|
const Meta = styled.div`font-size:11px;color:var(--text-secondary);font-family:var(--font-mono);`;
|
||||||
const PhaseBadge = styled.div<{ $phase:string }>`font-size:11px;font-family:var(--font-mono);padding:4px 8px;border:1px solid ${({$phase})=>$phase==='DEPLOYED'?'#5fafff44':$phase==='READY FOR DEPLOY'?'#5fff8a44':$phase==='QA'?'#ffcc6644':'var(--border-color)'};color:${({$phase})=>$phase==='DEPLOYED'?'#5fafff':$phase==='READY FOR DEPLOY'?'#5fff8a':$phase==='QA'?'#ffcc66':'var(--text-primary)'};white-space:nowrap;`;
|
|
||||||
const EmptyState = styled.div`padding:var(--space-xl) 0;color:var(--text-secondary);font-size:13px;font-family:var(--font-mono);`;
|
const EmptyState = styled.div`padding:var(--space-xl) 0;color:var(--text-secondary);font-size:13px;font-family:var(--font-mono);`;
|
||||||
|
|
||||||
function qaLabel(project: ProjectListItem): string {
|
|
||||||
if (project.latestQaStatus === 'passed') return 'QA PASSED';
|
|
||||||
if (project.latestQaStatus === 'failed') return `QA FAILED${project.blockerCount > 0 ? ` · ${project.blockerCount} BLOCKERS` : ''}`;
|
|
||||||
return 'QA PENDING';
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ProjectsPage() {
|
export default function ProjectsPage() {
|
||||||
const [projects, setProjects] = useState<ProjectListItem[]>([]);
|
const [projects, setProjects] = useState<any[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [syncing, setSyncing] = useState(false);
|
const [syncing, setSyncing] = useState(false);
|
||||||
const [syncResult, setSyncResult] = useState<string | null>(null);
|
const [syncResult, setSyncResult] = useState<string | null>(null);
|
||||||
@@ -50,59 +31,61 @@ export default function ProjectsPage() {
|
|||||||
fetch(`${API_URL}/api/projects`).then((r) => r.json()).then(setProjects).catch(() => {}).finally(() => setLoading(false));
|
fetch(`${API_URL}/api/projects`).then((r) => r.json()).then(setProjects).catch(() => {}).finally(() => setLoading(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
const runSync = async (path: string, label: string) => {
|
const handleSync = async () => {
|
||||||
setSyncing(true);
|
setSyncing(true); setSyncResult(null);
|
||||||
setSyncResult(null);
|
|
||||||
try {
|
try {
|
||||||
const res = await adminFetch(path, { method: 'POST' });
|
const res = await adminFetch('/api/admin/gitea/sync', { method: 'POST' });
|
||||||
const data = await res.json();
|
const d = await res.json();
|
||||||
setSyncResult(`${label}: ${JSON.stringify(data)}`);
|
setSyncResult(`sync: ${d.created ?? 0} new, ${d.updated ?? 0} updated`);
|
||||||
loadProjects();
|
loadProjects();
|
||||||
} catch {
|
} catch { setSyncResult('sync failed'); } finally { setSyncing(false); }
|
||||||
setSyncResult(`${label}: failed`);
|
};
|
||||||
} finally {
|
|
||||||
setSyncing(false);
|
const handleSprintSync = async () => {
|
||||||
}
|
setSyncing(true); setSyncResult(null);
|
||||||
|
try {
|
||||||
|
const res = await adminFetch('/api/projects/sync-all-sprints', { method: 'POST' });
|
||||||
|
const d = await res.json();
|
||||||
|
setSyncResult(`sprint sync: ${d.synced ?? 0} synced across ${d.projects ?? 0} projects`);
|
||||||
|
loadProjects();
|
||||||
|
} catch { setSyncResult('sprint sync failed'); } finally { setSyncing(false); }
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => { loadProjects(); }, []);
|
useEffect(() => { loadProjects(); }, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 'var(--space-md)', flexWrap: 'wrap', marginBottom: 'var(--space-lg)' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 'var(--space-lg)' }}>
|
||||||
<PageTitle>프로젝트</PageTitle>
|
<PageTitle>프로젝트</PageTitle>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 'var(--space-md)', flexWrap: 'wrap' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 'var(--space-md)' }}>
|
||||||
{syncResult && <span style={{ fontFamily: 'var(--font-mono)', fontSize: '11px', color: 'var(--text-secondary)' }}>{syncResult}</span>}
|
{syncResult && <span style={{ fontFamily: 'var(--font-mono)', fontSize: '11px', color: 'var(--text-secondary)' }}>{syncResult}</span>}
|
||||||
<LabelMeta>VOL: {String(projects.length).padStart(2, '0')}</LabelMeta>
|
<LabelMeta>VOL: {String(projects.length).padStart(2, '0')}</LabelMeta>
|
||||||
<Btn onClick={() => runSync('/api/admin/gitea/sync', 'gitea sync')} disabled={syncing}>{syncing ? 'SYNCING...' : '↻ GITEA SYNC'}</Btn>
|
<Btn onClick={handleSync} disabled={syncing}>{syncing ? 'SYNCING...' : '↻ GITEA SYNC'}</Btn>
|
||||||
<Btn onClick={() => runSync('/api/projects/sync-all-sprints', 'sprint sync')} disabled={syncing}>{syncing ? '...' : '↻ SPRINT SYNC'}</Btn>
|
<Btn onClick={handleSprintSync} disabled={syncing}>{syncing ? '...' : '↻ SPRINT SYNC'}</Btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading ? <EmptyState>LOADING...</EmptyState> : projects.length === 0 ? <EmptyState>NO PROJECTS REGISTERED</EmptyState> : (
|
{loading ? <EmptyState>LOADING...</EmptyState> : projects.length === 0 ? <EmptyState>NO PROJECTS REGISTERED</EmptyState> : (
|
||||||
<ProjectList>
|
<ProjectList>
|
||||||
{projects.map((project) => (
|
{projects.map((p) => (
|
||||||
<ProjectRow key={project.id} href={`/projects/${project.id}`}>
|
<ProjectRow key={p.id} href={`/projects/${p.id}`}>
|
||||||
<Left>
|
<Left>
|
||||||
<Meta>P-{String(project.id).padStart(3, '0')}</Meta>
|
<ProjectMark>{String(p.name ?? 'P').slice(0, 1).toUpperCase()}</ProjectMark>
|
||||||
<ProjectName>{project.name}</ProjectName>
|
<NameBlock>
|
||||||
<ProjectDesc>{project.description ?? '설명 없음'}</ProjectDesc>
|
<ProjectName>{p.name}</ProjectName>
|
||||||
|
<ProjectDesc>{p.description ?? '설명 없음'}</ProjectDesc>
|
||||||
|
</NameBlock>
|
||||||
</Left>
|
</Left>
|
||||||
<Middle>
|
<Middle>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 'var(--space-sm)', flexWrap: 'wrap' }}>
|
<ProgressRow>
|
||||||
<PhaseBadge $phase={project.phase}>{project.phase}</PhaseBadge>
|
<TechBar style={{ flex: 1 }}><TechBarFill $width={p.progress ?? 0} /></TechBar>
|
||||||
<Meta>{project.currentSprint ? `SPRINT ${project.currentSprint}` : 'PLANNING BACKLOG'}</Meta>
|
<LabelMeta style={{ minWidth: 44, textAlign: 'right' }}>{p.progress ?? 0}%</LabelMeta>
|
||||||
{project.latestHotfix && <Meta>HOTFIX {project.latestHotfix}</Meta>}
|
</ProgressRow>
|
||||||
</div>
|
<Meta>{p.doneSprints ?? 0} / {p.totalSprints ?? 0} SPRINTS DONE</Meta>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 'var(--space-sm)' }}>
|
|
||||||
<TechBar style={{ flex: 1 }}><TechBarFill $width={project.progress ?? 0} /></TechBar>
|
|
||||||
<LabelMeta style={{ minWidth: 44, textAlign: 'right' }}>{project.progress ?? 0}%</LabelMeta>
|
|
||||||
</div>
|
|
||||||
</Middle>
|
</Middle>
|
||||||
<Right>
|
<Right>
|
||||||
<Meta>{qaLabel(project)}</Meta>
|
<LabelMeta>{p.currentSprint ?? p.status?.toUpperCase() ?? 'ACTIVE'}</LabelMeta>
|
||||||
<Meta>{project.deployStatus}</Meta>
|
<Meta>{new Date(p.updatedAt).toLocaleDateString('ko-KR')} UPDATED</Meta>
|
||||||
<Meta>{new Date(project.updatedAt).toLocaleDateString('ko-KR')} UPDATED</Meta>
|
|
||||||
</Right>
|
</Right>
|
||||||
</ProjectRow>
|
</ProjectRow>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import React, { useEffect, useState, useCallback } from 'react';
|
|||||||
import { useParams } from 'next/navigation';
|
import { useParams } from 'next/navigation';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { LabelMeta, TechBar, TechBarFill, Timeline, TimelineItem, TimeStamp, TimelineContent, Btn } from '@/components/ui/base';
|
import { LabelMeta, SectionTitle, TechBar, TechBarFill, Timeline, TimelineItem, TimeStamp, TimelineContent, Btn } from '@/components/ui/base';
|
||||||
import { API_URL } from '@/lib/config';
|
import { API_URL } from '@/lib/config';
|
||||||
import SisterAvatar from '@/components/common/SisterAvatar';
|
import SisterAvatar from '@/components/common/SisterAvatar';
|
||||||
import { SISTER_ROLES } from '@/lib/sisters';
|
import { SISTER_ROLES } from '@/lib/sisters';
|
||||||
@@ -26,6 +26,7 @@ const StatValue = styled.div`font-size:18px;color:var(--text-primary);font-famil
|
|||||||
const DetailGrid = styled.div`display:grid;grid-template-columns:320px 1fr;gap:var(--space-xxl);align-items:start;@media (max-width:1199px){grid-template-columns:1fr;gap:var(--space-xl);}`;
|
const DetailGrid = styled.div`display:grid;grid-template-columns:320px 1fr;gap:var(--space-xxl);align-items:start;@media (max-width:1199px){grid-template-columns:1fr;gap:var(--space-xl);}`;
|
||||||
const MetaPanel = styled.div`display:flex;flex-direction:column;gap:var(--space-lg);`;
|
const MetaPanel = styled.div`display:flex;flex-direction:column;gap:var(--space-lg);`;
|
||||||
const MetaCard = styled.div`border:1px solid var(--border-color);padding:var(--space-lg);`;
|
const MetaCard = styled.div`border:1px solid var(--border-color);padding:var(--space-lg);`;
|
||||||
|
const ConfigPre = styled.pre`background:#0d0d0d;border:1px solid var(--border-color);padding:var(--space-md);font-family:var(--font-mono);font-size:11px;color:#8888aa;overflow:auto;max-height:400px;white-space:pre-wrap;word-break:break-word;line-height:1.6;`;
|
||||||
const TabBar = styled.div`display:flex;gap:var(--space-lg);border-bottom:1px solid var(--border-color);margin-bottom:var(--space-lg);overflow:auto;`;
|
const TabBar = styled.div`display:flex;gap:var(--space-lg);border-bottom:1px solid var(--border-color);margin-bottom:var(--space-lg);overflow:auto;`;
|
||||||
const TabBtn = styled.button<{ $active: boolean }>`font-size:13px;font-weight:500;color:${({$active})=>$active?'var(--text-primary)':'var(--text-secondary)'};background:transparent;border:none;border-bottom:1px solid ${({$active})=>$active?'var(--text-primary)':'transparent'};padding:var(--space-sm) 0;cursor:pointer;transition:color .15s,border-color .15s;white-space:nowrap;&:hover{color:var(--text-primary);}`;
|
const TabBtn = styled.button<{ $active: boolean }>`font-size:13px;font-weight:500;color:${({$active})=>$active?'var(--text-primary)':'var(--text-secondary)'};background:transparent;border:none;border-bottom:1px solid ${({$active})=>$active?'var(--text-primary)':'transparent'};padding:var(--space-sm) 0;cursor:pointer;transition:color .15s,border-color .15s;white-space:nowrap;&:hover{color:var(--text-primary);}`;
|
||||||
const Toolbar = styled.div`display:flex;align-items:center;gap:10px;margin-bottom:12px;flex-wrap:wrap;`;
|
const Toolbar = styled.div`display:flex;align-items:center;gap:10px;margin-bottom:12px;flex-wrap:wrap;`;
|
||||||
@@ -36,69 +37,13 @@ const SessionCard = styled.div`border:1px solid var(--border-color);padding:var(
|
|||||||
const SISTER_DISPLAY: Record<string, string> = { harang: '하랑이', narang: '나랑이', darang: '다랑이', erang: '이랑이' };
|
const SISTER_DISPLAY: Record<string, string> = { harang: '하랑이', narang: '나랑이', darang: '다랑이', erang: '이랑이' };
|
||||||
const FILES = ['SOUL.md', 'AGENTS.md', 'TOOLS.md', 'PROTOCOL.md', 'HEARTBEAT.md'];
|
const FILES = ['SOUL.md', 'AGENTS.md', 'TOOLS.md', 'PROTOCOL.md', 'HEARTBEAT.md'];
|
||||||
|
|
||||||
interface SisterInfo {
|
|
||||||
id?: number;
|
|
||||||
name: string;
|
|
||||||
status?: string;
|
|
||||||
lxcId?: string | number | null;
|
|
||||||
lastSeen?: string | null;
|
|
||||||
user?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SystemInfo {
|
|
||||||
uptime?: string;
|
|
||||||
cpu?: number;
|
|
||||||
memory?: { used?: number; total?: number };
|
|
||||||
disk?: { used?: string; total?: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ConfigData {
|
|
||||||
description?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ActivityItem {
|
|
||||||
id: number;
|
|
||||||
createdAt: string;
|
|
||||||
action?: string;
|
|
||||||
detail?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ActivityResponse {
|
|
||||||
items?: ActivityItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SessionItem {
|
|
||||||
id?: string | number;
|
|
||||||
title?: string;
|
|
||||||
label?: string;
|
|
||||||
status?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SessionsResponse {
|
|
||||||
sessions?: SessionItem[];
|
|
||||||
items?: SessionItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HarnessResponse {
|
|
||||||
content?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SaveHarnessResponse {
|
|
||||||
success?: boolean;
|
|
||||||
error?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LogResponse {
|
|
||||||
lines?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function SisterDetailPage() {
|
export default function SisterDetailPage() {
|
||||||
const { name } = useParams<{ name: string }>();
|
const { name } = useParams<{ name: string }>();
|
||||||
const [sisterInfo, setSisterInfo] = useState<SisterInfo | null>(null);
|
const [sisterInfo, setSisterInfo] = useState<any>(null);
|
||||||
const [systemInfo, setSystemInfo] = useState<SystemInfo | null>(null);
|
const [systemInfo, setSystemInfo] = useState<any>(null);
|
||||||
const [configData, setConfigData] = useState<ConfigData | null>(null);
|
const [configData, setConfigData] = useState<any>(null);
|
||||||
const [activity, setActivity] = useState<ActivityItem[]>([]);
|
const [activity, setActivity] = useState<any[]>([]);
|
||||||
const [sessions, setSessions] = useState<SessionItem[]>([]);
|
const [sessions, setSessions] = useState<any[]>([]);
|
||||||
const [tab, setTab] = useState('overview');
|
const [tab, setTab] = useState('overview');
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [logLines, setLogLines] = useState<string[]>([]);
|
const [logLines, setLogLines] = useState<string[]>([]);
|
||||||
@@ -117,11 +62,11 @@ export default function SisterDetailPage() {
|
|||||||
fetch(`${API_URL}/api/sisters/${name}/system`),
|
fetch(`${API_URL}/api/sisters/${name}/system`),
|
||||||
fetch(`${API_URL}/api/sisters/${name}/sessions`),
|
fetch(`${API_URL}/api/sisters/${name}/sessions`),
|
||||||
]).then(([sRes, cRes, aRes, syRes, ssRes]) => {
|
]).then(([sRes, cRes, aRes, syRes, ssRes]) => {
|
||||||
if (sRes.status === 'fulfilled' && sRes.value.ok) sRes.value.json().then((d: SisterInfo[]) => setSisterInfo(d.find((s) => s.name === name) ?? null));
|
if (sRes.status === 'fulfilled' && sRes.value.ok) sRes.value.json().then((d: any[]) => setSisterInfo(d.find((s) => s.name === name)));
|
||||||
if (cRes.status === 'fulfilled' && cRes.value.ok) cRes.value.json().then((data: ConfigData) => setConfigData(data));
|
if (cRes.status === 'fulfilled' && cRes.value.ok) cRes.value.json().then(setConfigData);
|
||||||
if (aRes.status === 'fulfilled' && aRes.value.ok) aRes.value.json().then((d: ActivityResponse) => setActivity(d.items ?? []));
|
if (aRes.status === 'fulfilled' && aRes.value.ok) aRes.value.json().then((d: any) => setActivity(d.items ?? []));
|
||||||
if (syRes.status === 'fulfilled' && syRes.value.ok) syRes.value.json().then((data: SystemInfo) => setSystemInfo(data));
|
if (syRes.status === 'fulfilled' && syRes.value.ok) syRes.value.json().then(setSystemInfo);
|
||||||
if (ssRes.status === 'fulfilled' && ssRes.value.ok) ssRes.value.json().then((d: SessionsResponse) => setSessions(d.sessions ?? d.items ?? []));
|
if (ssRes.status === 'fulfilled' && ssRes.value.ok) ssRes.value.json().then((d: any) => setSessions(d.sessions ?? d.items ?? []));
|
||||||
}).finally(() => setLoading(false));
|
}).finally(() => setLoading(false));
|
||||||
}, [name]);
|
}, [name]);
|
||||||
|
|
||||||
@@ -129,7 +74,7 @@ export default function SisterDetailPage() {
|
|||||||
setLogLoading(true);
|
setLogLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await adminFetch(`/api/admin/logs/${name}?lines=${lines}`);
|
const res = await adminFetch(`/api/admin/logs/${name}?lines=${lines}`);
|
||||||
const d: LogResponse = await res.json();
|
const d = await res.json();
|
||||||
setLogLines(d.lines ?? []);
|
setLogLines(d.lines ?? []);
|
||||||
} catch {
|
} catch {
|
||||||
setLogLines(['(로그 로드 실패)']);
|
setLogLines(['(로그 로드 실패)']);
|
||||||
@@ -145,7 +90,7 @@ export default function SisterDetailPage() {
|
|||||||
setSaveResult(null);
|
setSaveResult(null);
|
||||||
adminFetch(`/api/admin/harness/${name}/${selectedFile}`)
|
adminFetch(`/api/admin/harness/${name}/${selectedFile}`)
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((d: HarnessResponse) => { setContent(d.content ?? ''); setSaved(d.content ?? ''); })
|
.then((d) => { setContent(d.content ?? ''); setSaved(d.content ?? ''); })
|
||||||
.catch(() => setContent('(로드 실패)'));
|
.catch(() => setContent('(로드 실패)'));
|
||||||
}, [tab, name, selectedFile]);
|
}, [tab, name, selectedFile]);
|
||||||
|
|
||||||
@@ -153,7 +98,7 @@ export default function SisterDetailPage() {
|
|||||||
setSaveResult(null);
|
setSaveResult(null);
|
||||||
try {
|
try {
|
||||||
const res = await adminFetch(`/api/admin/harness/${name}/${selectedFile}`, { method: 'PUT', body: JSON.stringify({ content }) });
|
const res = await adminFetch(`/api/admin/harness/${name}/${selectedFile}`, { method: 'PUT', body: JSON.stringify({ content }) });
|
||||||
const d: SaveHarnessResponse = await res.json();
|
const d = await res.json();
|
||||||
if (d.success) { setSaved(content); setSaveResult({ success: true, msg: '저장 완료' }); }
|
if (d.success) { setSaved(content); setSaveResult({ success: true, msg: '저장 완료' }); }
|
||||||
else setSaveResult({ success: false, msg: d.error ?? '저장 실패' });
|
else setSaveResult({ success: false, msg: d.error ?? '저장 실패' });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -206,7 +151,7 @@ export default function SisterDetailPage() {
|
|||||||
</TabBar>
|
</TabBar>
|
||||||
|
|
||||||
{tab === 'overview' && <Timeline>{activity.slice(0, 8).map((item) => <TimelineItem key={item.id}><TimeStamp>{new Date(item.createdAt).toLocaleString('ko-KR', { hour12: false })}</TimeStamp><TimelineContent>{item.detail ?? item.action}</TimelineContent></TimelineItem>)}</Timeline>}
|
{tab === 'overview' && <Timeline>{activity.slice(0, 8).map((item) => <TimelineItem key={item.id}><TimeStamp>{new Date(item.createdAt).toLocaleString('ko-KR', { hour12: false })}</TimeStamp><TimelineContent>{item.detail ?? item.action}</TimelineContent></TimelineItem>)}</Timeline>}
|
||||||
{tab === 'sessions' && <>{sessions.length === 0 ? <div style={{ color: 'var(--text-secondary)' }}>세션 없음</div> : sessions.map((session, i: number) => <SessionCard key={session.id ?? i}><div style={{ color: 'var(--text-primary)', fontSize: '13px' }}>{session.title ?? session.label ?? session.id ?? 'session'}</div><div style={{ color: 'var(--text-secondary)', fontSize: '11px', fontFamily: 'var(--font-mono)' }}>{session.status ?? ''}</div></SessionCard>)}</>}
|
{tab === 'sessions' && <>{sessions.length === 0 ? <div style={{ color: 'var(--text-secondary)' }}>세션 없음</div> : sessions.map((s: any, i: number) => <SessionCard key={i}><div style={{ color: 'var(--text-primary)', fontSize: '13px' }}>{s.title ?? s.label ?? s.id ?? 'session'}</div><div style={{ color: 'var(--text-secondary)', fontSize: '11px', fontFamily: 'var(--font-mono)' }}>{s.status ?? ''}</div></SessionCard>)}</>}
|
||||||
{tab === 'activity' && <Timeline>{activity.map((item) => <TimelineItem key={item.id}><TimeStamp>{new Date(item.createdAt).toLocaleString('ko-KR', { hour12: false })}</TimeStamp><TimelineContent>{item.detail ?? item.action}</TimelineContent></TimelineItem>)}</Timeline>}
|
{tab === 'activity' && <Timeline>{activity.map((item) => <TimelineItem key={item.id}><TimeStamp>{new Date(item.createdAt).toLocaleString('ko-KR', { hour12: false })}</TimeStamp><TimelineContent>{item.detail ?? item.action}</TimelineContent></TimelineItem>)}</Timeline>}
|
||||||
{tab === 'harness' && <><Toolbar><Select value={selectedFile} onChange={(e) => setSelectedFile(e.target.value)}>{FILES.map((f) => <option key={f} value={f}>{f}</option>)}</Select><Btn onClick={() => { setContent(saved); setSaveResult(null); }}>되돌리기</Btn><Btn onClick={handleSave}>저장</Btn></Toolbar>{saveResult && <ResultMsg $success={saveResult.success}>{saveResult.msg}</ResultMsg>}<CodeEditor value={content} onChange={setContent} /></>}
|
{tab === 'harness' && <><Toolbar><Select value={selectedFile} onChange={(e) => setSelectedFile(e.target.value)}>{FILES.map((f) => <option key={f} value={f}>{f}</option>)}</Select><Btn onClick={() => { setContent(saved); setSaveResult(null); }}>되돌리기</Btn><Btn onClick={handleSave}>저장</Btn></Toolbar>{saveResult && <ResultMsg $success={saveResult.success}>{saveResult.msg}</ResultMsg>}<CodeEditor value={content} onChange={setContent} /></>}
|
||||||
{tab === 'logs' && <><Toolbar><span style={{ color: 'var(--text-secondary)', fontSize: '12px' }}>최근</span><LinesInput type="number" value={lines} onChange={(e) => setLines(parseInt(e.target.value, 10) || 100)} min={10} max={500} /><span style={{ color: 'var(--text-secondary)', fontSize: '12px' }}>줄</span><Btn onClick={fetchLogs}>{logLoading ? '로딩 중...' : '로그 가져오기'}</Btn></Toolbar><LogTerminal lines={logLines} /></>}
|
{tab === 'logs' && <><Toolbar><span style={{ color: 'var(--text-secondary)', fontSize: '12px' }}>최근</span><LinesInput type="number" value={lines} onChange={(e) => setLines(parseInt(e.target.value, 10) || 100)} min={10} max={500} /><span style={{ color: 'var(--text-secondary)', fontSize: '12px' }}>줄</span><Btn onClick={fetchLogs}>{logLoading ? '로딩 중...' : '로그 가져오기'}</Btn></Toolbar><LogTerminal lines={logLines} /></>}
|
||||||
|
|||||||
@@ -9,20 +9,6 @@ import SisterAvatar from '@/components/common/SisterAvatar';
|
|||||||
|
|
||||||
const pulse = keyframes`0%{opacity:.35}50%{opacity:.7}100%{opacity:.35}`;
|
const pulse = keyframes`0%{opacity:.35}50%{opacity:.7}100%{opacity:.35}`;
|
||||||
const SISTER_ROLES: Record<string, string> = { harang: 'Primary', narang: 'Secondary', darang: 'Standby', erang: 'Sync' };
|
const SISTER_ROLES: Record<string, string> = { harang: 'Primary', narang: 'Secondary', darang: 'Standby', erang: 'Sync' };
|
||||||
|
|
||||||
interface SisterListItem {
|
|
||||||
id?: number;
|
|
||||||
name: string;
|
|
||||||
status: string;
|
|
||||||
uptime?: string;
|
|
||||||
lastSeen?: string | null;
|
|
||||||
cpu?: number;
|
|
||||||
lxcId?: string | number | null;
|
|
||||||
currentTask?: string | null;
|
|
||||||
memory?: { used?: number; total?: number };
|
|
||||||
disk?: { used?: string; total?: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
const NodeGrid = styled.section`display:flex;flex-direction:column;gap:var(--space-lg);`;
|
const NodeGrid = styled.section`display:flex;flex-direction:column;gap:var(--space-lg);`;
|
||||||
const NodeEntry = styled(Link)`display:grid;grid-template-columns:220px 1fr 180px;gap:0;border:1px solid var(--border-color);transition:border-color .2s, background .15s;text-decoration:none;&:hover{border-color:var(--border-hover);background:#111}@media (max-width:1199px){grid-template-columns:200px 1fr}@media (max-width:767px){grid-template-columns:1fr}`;
|
const NodeEntry = styled(Link)`display:grid;grid-template-columns:220px 1fr 180px;gap:0;border:1px solid var(--border-color);transition:border-color .2s, background .15s;text-decoration:none;&:hover{border-color:var(--border-hover);background:#111}@media (max-width:1199px){grid-template-columns:200px 1fr}@media (max-width:767px){grid-template-columns:1fr}`;
|
||||||
const NodeInfo = styled.div`border-right:1px solid var(--border-color);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md);@media (max-width:767px){border-right:none;border-bottom:1px solid var(--border-color)}`;
|
const NodeInfo = styled.div`border-right:1px solid var(--border-color);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md);@media (max-width:767px){border-right:none;border-bottom:1px solid var(--border-color)}`;
|
||||||
@@ -41,9 +27,9 @@ const MetaRow = styled.div`display:flex;justify-content:space-between;font-famil
|
|||||||
const Skeleton = styled.div`height:120px;border:1px solid var(--border-color);background:#111;animation:${pulse} 1.4s ease-in-out infinite;`;
|
const Skeleton = styled.div`height:120px;border:1px solid var(--border-color);background:#111;animation:${pulse} 1.4s ease-in-out infinite;`;
|
||||||
const ErrorBox = styled.div`padding:var(--space-lg);border:1px solid #5a2a2a;color:#ff9b9b;`;
|
const ErrorBox = styled.div`padding:var(--space-lg);border:1px solid #5a2a2a;color:#ff9b9b;`;
|
||||||
|
|
||||||
function getNodeStatus(s: SisterListItem): boolean { return s.status === 'online' || s.status === 'working'; }
|
function getNodeStatus(s: any): boolean { return s.status === 'online' || s.status === 'working'; }
|
||||||
function getStatusBtns(s: SisterListItem): [string, string] { if (s.status === 'offline') return ['STANDBY', 'ACTIVATE']; return ['ACTIVE', 'REBOOT']; }
|
function getStatusBtns(s: any): [string, string] { if (s.status === 'offline') return ['STANDBY', 'ACTIVATE']; return ['ACTIVE', 'REBOOT']; }
|
||||||
function diskPercent(disk?: SisterListItem['disk']): number {
|
function diskPercent(disk: any): number {
|
||||||
if (!disk?.used || !disk?.total) return 0;
|
if (!disk?.used || !disk?.total) return 0;
|
||||||
const parse = (v: string) => {
|
const parse = (v: string) => {
|
||||||
const m = String(v).match(/([0-9.]+)\s*([KMGTP]?)/i);
|
const m = String(v).match(/([0-9.]+)\s*([KMGTP]?)/i);
|
||||||
@@ -60,7 +46,7 @@ function diskPercent(disk?: SisterListItem['disk']): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function SistersPage() {
|
export default function SistersPage() {
|
||||||
const [sisters, setSisters] = useState<SisterListItem[]>([]);
|
const [sisters, setSisters] = useState<any[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
@@ -68,8 +54,8 @@ export default function SistersPage() {
|
|||||||
let active = true;
|
let active = true;
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
try {
|
try {
|
||||||
const base: SisterListItem[] = await fetch(`${API_URL}/api/sisters`).then((r) => r.ok ? r.json() : Promise.reject());
|
const base = await fetch(`${API_URL}/api/sisters`).then((r) => r.ok ? r.json() : Promise.reject());
|
||||||
const withSystem = await Promise.all(base.map(async (s: SisterListItem) => {
|
const withSystem = await Promise.all(base.map(async (s: any) => {
|
||||||
try {
|
try {
|
||||||
const system = await fetch(`${API_URL}/api/sisters/${s.name}/system`).then((r) => r.ok ? r.json() : null);
|
const system = await fetch(`${API_URL}/api/sisters/${s.name}/system`).then((r) => r.ok ? r.json() : null);
|
||||||
return { ...s, ...(system ?? {}) };
|
return { ...s, ...(system ?? {}) };
|
||||||
@@ -115,7 +101,7 @@ export default function SistersPage() {
|
|||||||
<CapacitySection>
|
<CapacitySection>
|
||||||
<BarWrap>
|
<BarWrap>
|
||||||
<BarRow><span>CPU</span><span>{s.cpu?.toFixed?.(1) ?? '0.0'}%</span><Bar><Fill $width={Math.max(0, Math.min(100, Number(s.cpu ?? 0)))} /></Bar></BarRow>
|
<BarRow><span>CPU</span><span>{s.cpu?.toFixed?.(1) ?? '0.0'}%</span><Bar><Fill $width={Math.max(0, Math.min(100, Number(s.cpu ?? 0)))} /></Bar></BarRow>
|
||||||
<BarRow><span>MEM</span><span>{s.memory?.used ?? 0}/{s.memory?.total ?? 0}MB</span><Bar><Fill $width={s.memory?.total ? Math.max(0, Math.min(100, (((s.memory.used ?? 0) / s.memory.total) * 100))) : 0} /></Bar></BarRow>
|
<BarRow><span>MEM</span><span>{s.memory?.used ?? 0}/{s.memory?.total ?? 0}MB</span><Bar><Fill $width={s.memory?.total ? Math.max(0, Math.min(100, (s.memory.used / s.memory.total) * 100)) : 0} /></Bar></BarRow>
|
||||||
<BarRow><span>DSK</span><span>{s.disk?.used ?? '0G'}/{s.disk?.total ?? '0G'}</span><Bar><Fill $width={diskPercent(s.disk)} /></Bar></BarRow>
|
<BarRow><span>DSK</span><span>{s.disk?.used ?? '0G'}/{s.disk?.total ?? '0G'}</span><Bar><Fill $width={diskPercent(s.disk)} /></Bar></BarRow>
|
||||||
</BarWrap>
|
</BarWrap>
|
||||||
</CapacitySection>
|
</CapacitySection>
|
||||||
|
|||||||
@@ -5,59 +5,195 @@ import styled from 'styled-components';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { useAuth } from '@/lib/AuthContext';
|
import { useAuth } from '@/lib/AuthContext';
|
||||||
|
import { useSidebar } from '@/lib/SidebarContext';
|
||||||
|
|
||||||
const NAV_ITEMS = [
|
const NAV_ITEMS = [
|
||||||
{ href: '/', label: '대시' },
|
{ href: '/', label: '대시' },
|
||||||
{ href: '/office', label: '오피스' },
|
|
||||||
{ href: '/projects', label: '프로' },
|
|
||||||
{ href: '/activities', label: '활동' },
|
{ href: '/activities', label: '활동' },
|
||||||
|
{ href: '/projects', label: '프로' },
|
||||||
{ href: '/sisters', label: '자매' },
|
{ href: '/sisters', label: '자매' },
|
||||||
{ href: '/org', label: '조직' },
|
{ href: '/org', label: '조직' },
|
||||||
{ href: '/settings', label: '설정' },
|
{ href: '/settings', label: '설정' },
|
||||||
{ href: '/admin', label: '관리' },
|
{ href: '/admin', label: '관리' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// ─── Desktop Sidebar ───
|
||||||
const SidebarWrapper = styled.aside`
|
const SidebarWrapper = styled.aside`
|
||||||
width: 240px;flex-shrink: 0;border-right: 1px solid var(--border-color);display: flex;flex-direction: column;padding: var(--space-xl) var(--space-lg);position: sticky;top: 0;height: 100vh;overflow-y: auto;
|
width: 240px;
|
||||||
@media (min-width: 768px) and (max-width: 1199px) { width: 64px;padding: var(--space-xl) var(--space-md);align-items: center; }
|
flex-shrink: 0;
|
||||||
@media (max-width: 767px) { display: none; }
|
border-right: 1px solid var(--border-color);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: var(--space-xl) var(--space-lg);
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
height: 100vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
|
@media (min-width: 768px) and (max-width: 1199px) {
|
||||||
|
width: 64px;
|
||||||
|
padding: var(--space-xl) var(--space-md);
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const LogoContainer = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
margin-bottom: var(--space-xxl);
|
||||||
|
|
||||||
|
@media (min-width: 768px) and (max-width: 1199px) {
|
||||||
|
margin-bottom: var(--space-xl);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CircleFull = styled.div`
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background-color: var(--text-primary);
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CircleHalf = styled.div`
|
||||||
|
width: 10px;
|
||||||
|
height: 20px;
|
||||||
|
background-color: var(--text-primary);
|
||||||
|
border-radius: 0 20px 20px 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NavMenu = styled.ul`
|
||||||
|
list-style: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
width: 100%;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const NavItem = styled.li``;
|
||||||
|
|
||||||
|
const NavLink = styled(Link)<{ $active: boolean }>`
|
||||||
|
color: ${({ $active }) => $active ? 'var(--accent-hover)' : 'var(--text-secondary)'};
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: var(--space-sm) 0;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
${({ $active }) => $active && `
|
||||||
|
&::before { content: "["; margin-right: 4px; color: var(--text-secondary); }
|
||||||
|
&::after { content: "]"; margin-left: 4px; color: var(--text-secondary); }
|
||||||
|
`}
|
||||||
|
|
||||||
|
@media (min-width: 768px) and (max-width: 1199px) {
|
||||||
|
font-size: 11px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
// ─── Mobile Bottom Tab Bar ───
|
||||||
|
const BottomTabBar = styled.nav`
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
display: flex;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 56px;
|
||||||
|
background: var(--bg-main);
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
z-index: 100;
|
||||||
|
overflow-x: auto;
|
||||||
|
scrollbar-width: none;
|
||||||
|
&::-webkit-scrollbar { display: none; }
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TabItem = styled(Link)<{ $active: boolean }>`
|
||||||
|
flex: 1;
|
||||||
|
min-width: 48px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: ${({ $active }) => $active ? 'var(--text-primary)' : 'var(--text-secondary)'};
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 6px 4px;
|
||||||
|
transition: color 0.15s;
|
||||||
|
border-top: ${({ $active }) => $active ? '1px solid var(--text-primary)' : '1px solid transparent'};
|
||||||
|
|
||||||
|
&:hover { color: var(--text-primary); }
|
||||||
`;
|
`;
|
||||||
const LogoContainer = styled.div`display:flex;align-items:center;gap:4px;margin-bottom:var(--space-xxl);@media (min-width:768px) and (max-width:1199px){margin-bottom:var(--space-xl);}`;
|
|
||||||
const CircleFull = styled.div`width:20px;height:20px;background-color:var(--text-primary);border-radius:50%;flex-shrink:0;`;
|
|
||||||
const CircleHalf = styled.div`width:10px;height:20px;background-color:var(--text-primary);border-radius:0 20px 20px 0;flex-shrink:0;`;
|
|
||||||
const NavMenu = styled.ul`list-style:none;display:flex;flex-direction:column;gap:var(--space-sm);width:100%;`;
|
|
||||||
const NavLink = styled(Link)<{ $active: boolean }>`color:${({ $active }) => $active ? 'var(--accent-hover)' : 'var(--text-secondary)'};text-decoration:none;font-size:14px;font-weight:500;padding:var(--space-sm) 0;transition:color .2s ease;display:block;width:100%;&:hover{color:var(--accent-hover)}${({ $active }) => $active && `&::before { content: "["; margin-right: 4px; color: var(--text-secondary); } &::after { content: "]"; margin-left: 4px; color: var(--text-secondary); }`}@media (min-width:768px) and (max-width:1199px){font-size:11px;text-align:center;padding:6px 0;}`;
|
|
||||||
const BottomTabBar = styled.nav`display:none;@media (max-width:767px){display:flex;position:fixed;bottom:0;left:0;right:0;height:56px;background:var(--bg-main);border-top:1px solid var(--border-color);z-index:100;overflow-x:auto;scrollbar-width:none;&::-webkit-scrollbar{display:none;}}`;
|
|
||||||
const TabItem = styled(Link)<{ $active: boolean }>`flex:1;min-width:48px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:10px;font-weight:600;text-transform:uppercase;color:${({ $active }) => $active ? 'var(--text-primary)' : 'var(--text-secondary)'};text-decoration:none;padding:6px 4px;transition:color .15s;border-top:${({ $active }) => $active ? '1px solid var(--text-primary)' : '1px solid transparent'};&:hover{color:var(--text-primary)}`;
|
|
||||||
|
|
||||||
export default function Sidebar() {
|
export default function Sidebar() {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { user, logout } = useAuth();
|
const { user, logout } = useAuth();
|
||||||
const isActive = (href: string) => href === '/' ? pathname === '/' : pathname.startsWith(href);
|
|
||||||
|
const isActive = (href: string) =>
|
||||||
|
href === '/' ? pathname === '/' : pathname.startsWith(href);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SidebarWrapper>
|
<SidebarWrapper>
|
||||||
<LogoContainer><CircleFull /><CircleHalf /></LogoContainer>
|
<LogoContainer>
|
||||||
|
<CircleFull />
|
||||||
|
<CircleHalf />
|
||||||
|
</LogoContainer>
|
||||||
<nav>
|
<nav>
|
||||||
<NavMenu>
|
<NavMenu>
|
||||||
{NAV_ITEMS.map((item) => (
|
{NAV_ITEMS.map((item) => (
|
||||||
<li key={item.href}>
|
<NavItem key={item.href}>
|
||||||
<NavLink href={item.href} $active={isActive(item.href)}>{item.label}</NavLink>
|
<NavLink href={item.href} $active={isActive(item.href)}>
|
||||||
</li>
|
{item.label}
|
||||||
|
</NavLink>
|
||||||
|
</NavItem>
|
||||||
))}
|
))}
|
||||||
</NavMenu>
|
</NavMenu>
|
||||||
</nav>
|
</nav>
|
||||||
{user && (
|
{user && (
|
||||||
<div style={{ marginTop: 'auto', paddingTop: 'var(--space-xl)' }}>
|
<div style={{ marginTop: 'auto', paddingTop: 'var(--space-xl)' }}>
|
||||||
<div style={{ fontSize: '11px', color: 'var(--text-secondary)', fontFamily: 'var(--font-mono)', marginBottom: 'var(--space-sm)' }}>[{user.username}]</div>
|
<div style={{ fontSize: '11px', color: 'var(--text-secondary)', fontFamily: 'var(--font-mono)', marginBottom: 'var(--space-sm)' }}>
|
||||||
<button onClick={logout} style={{ background: 'transparent', border: 'none', color: 'var(--text-secondary)', fontSize: '13px', cursor: 'pointer', padding: 0, textAlign: 'left', transition: 'color 0.15s', fontFamily: 'inherit' }}>로그아웃</button>
|
[{user.username}]
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={logout}
|
||||||
|
style={{
|
||||||
|
background: 'transparent', border: 'none', color: 'var(--text-secondary)',
|
||||||
|
fontSize: '13px', cursor: 'pointer', padding: 0, textAlign: 'left',
|
||||||
|
transition: 'color 0.15s', fontFamily: 'inherit',
|
||||||
|
}}
|
||||||
|
onMouseEnter={(e) => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||||
|
onMouseLeave={(e) => (e.currentTarget.style.color = 'var(--text-secondary)')}
|
||||||
|
>
|
||||||
|
로그아웃
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</SidebarWrapper>
|
</SidebarWrapper>
|
||||||
|
|
||||||
<BottomTabBar>
|
<BottomTabBar>
|
||||||
{NAV_ITEMS.map((item) => (
|
{NAV_ITEMS.map((item) => (
|
||||||
<TabItem key={item.href} href={item.href} $active={isActive(item.href)}>{item.label}</TabItem>
|
<TabItem key={item.href} href={item.href} $active={isActive(item.href)}>
|
||||||
|
{item.label}
|
||||||
|
</TabItem>
|
||||||
))}
|
))}
|
||||||
</BottomTabBar>
|
</BottomTabBar>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ interface SisterAvatarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function SisterAvatar({ name, size = 32, className, style }: SisterAvatarProps) {
|
export default function SisterAvatar({ name, size = 32, className, style }: SisterAvatarProps) {
|
||||||
const [failedFor, setFailedFor] = useState<string | null>(null);
|
const [failed, setFailed] = useState(false);
|
||||||
const initial = SISTER_INITIALS[name] ?? name.slice(0, 1).toUpperCase();
|
const initial = SISTER_INITIALS[name] ?? name.slice(0, 1).toUpperCase();
|
||||||
|
|
||||||
if (failedFor === name) {
|
if (failed) {
|
||||||
return <Fallback $size={size} className={className} style={style}>{initial}</Fallback>;
|
return <Fallback $size={size} className={className} style={style}>{initial}</Fallback>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ export default function SisterAvatar({ name, size = 32, className, style }: Sist
|
|||||||
alt={name}
|
alt={name}
|
||||||
className={className}
|
className={className}
|
||||||
style={style}
|
style={style}
|
||||||
onError={() => setFailedFor(name)}
|
onError={() => setFailed(true)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,295 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import styled, { keyframes } from 'styled-components';
|
|
||||||
|
|
||||||
export interface PipelineNode {
|
|
||||||
id: string;
|
|
||||||
label: string;
|
|
||||||
role: string;
|
|
||||||
state: 'idle' | 'active' | 'review' | 'blocked' | 'ready';
|
|
||||||
detail: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ActivePipelineProps {
|
|
||||||
activeTask: string;
|
|
||||||
focus: string;
|
|
||||||
reviewLoopCount: number;
|
|
||||||
escalationCount: number;
|
|
||||||
deployState: string;
|
|
||||||
nodes: PipelineNode[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const flow = keyframes`
|
|
||||||
0% { transform: translateX(0); opacity: 0.15; }
|
|
||||||
40% { opacity: 0.8; }
|
|
||||||
100% { transform: translateX(20px); opacity: 0; }
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PipelineCard = styled.section`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Header = styled.div`
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: var(--space-md);
|
|
||||||
align-items: flex-start;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Eyebrow = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Title = styled.h2`
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
margin-top: 6px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Summary = styled.p`
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
line-height: 1.6;
|
|
||||||
max-width: 780px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderStats = styled.div`
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, minmax(110px, 1fr));
|
|
||||||
gap: var(--space-sm);
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
width: 100%;
|
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StatBox = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
padding: 10px 12px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
min-width: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StatLabel = styled.span`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StatValue = styled.span`
|
|
||||||
font-size: 15px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FlowMap = styled.div`
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
|
||||||
gap: 14px;
|
|
||||||
align-items: stretch;
|
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeWrap = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Connector = styled.div<{ $active?: boolean }>`
|
|
||||||
flex: 1;
|
|
||||||
min-width: 36px;
|
|
||||||
height: 1px;
|
|
||||||
background: ${({ $active }) => ($active ? 'rgba(245,245,245,0.45)' : 'var(--border-color)')};
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: -2px;
|
|
||||||
left: -18px;
|
|
||||||
width: 18px;
|
|
||||||
height: 5px;
|
|
||||||
background: ${({ $active }) => ($active ? 'rgba(245,245,245,0.85)' : 'transparent')};
|
|
||||||
animation: ${({ $active }) => ($active ? flow : 'none')} 1.6s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
|
||||||
width: 1px;
|
|
||||||
height: 24px;
|
|
||||||
min-width: 1px;
|
|
||||||
margin: 0 auto;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
top: -8px;
|
|
||||||
left: -2px;
|
|
||||||
width: 5px;
|
|
||||||
height: 10px;
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const stateBorder: Record<PipelineNode['state'], string> = {
|
|
||||||
idle: 'var(--border-color)',
|
|
||||||
active: '#6fc3ff',
|
|
||||||
review: '#ff7ac6',
|
|
||||||
blocked: '#ff8d7a',
|
|
||||||
ready: '#8dffb2',
|
|
||||||
};
|
|
||||||
|
|
||||||
const stateText: Record<PipelineNode['state'], string> = {
|
|
||||||
idle: 'IDLE',
|
|
||||||
active: 'ACTIVE',
|
|
||||||
review: 'REVIEW',
|
|
||||||
blocked: 'BLOCKED',
|
|
||||||
ready: 'READY',
|
|
||||||
};
|
|
||||||
|
|
||||||
const NodeCard = styled.div<{ $state: PipelineNode['state'] }>`
|
|
||||||
border: 1px solid ${({ $state }) => stateBorder[$state]};
|
|
||||||
padding: 14px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
min-height: 148px;
|
|
||||||
background: linear-gradient(180deg, rgba(255,255,255,0.015) 0%, rgba(255,255,255,0) 100%);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeTop = styled.div`
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
align-items: flex-start;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeLabel = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeName = styled.div`
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeRole = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StateBadge = styled.span<{ $state: PipelineNode['state'] }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: ${({ $state }) => stateBorder[$state]};
|
|
||||||
border: 1px solid ${({ $state }) => stateBorder[$state]};
|
|
||||||
padding: 4px 6px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
white-space: nowrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeDetail = styled.div`
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const NodeHint = styled.div`
|
|
||||||
margin-top: auto;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default function ActivePipeline({
|
|
||||||
activeTask,
|
|
||||||
focus,
|
|
||||||
reviewLoopCount,
|
|
||||||
escalationCount,
|
|
||||||
deployState,
|
|
||||||
nodes,
|
|
||||||
}: ActivePipelineProps) {
|
|
||||||
return (
|
|
||||||
<PipelineCard>
|
|
||||||
<Header>
|
|
||||||
<div>
|
|
||||||
<Eyebrow>Active pipeline / snapshot</Eyebrow>
|
|
||||||
<Title>{activeTask}</Title>
|
|
||||||
<Summary>{focus}</Summary>
|
|
||||||
</div>
|
|
||||||
<HeaderStats>
|
|
||||||
<StatBox>
|
|
||||||
<StatLabel>review loop</StatLabel>
|
|
||||||
<StatValue>{reviewLoopCount}x</StatValue>
|
|
||||||
</StatBox>
|
|
||||||
<StatBox>
|
|
||||||
<StatLabel>escalations</StatLabel>
|
|
||||||
<StatValue>{escalationCount}</StatValue>
|
|
||||||
</StatBox>
|
|
||||||
<StatBox>
|
|
||||||
<StatLabel>deploy state</StatLabel>
|
|
||||||
<StatValue>{deployState}</StatValue>
|
|
||||||
</StatBox>
|
|
||||||
</HeaderStats>
|
|
||||||
</Header>
|
|
||||||
|
|
||||||
<FlowMap>
|
|
||||||
{nodes.map((node, index) => {
|
|
||||||
const connectorActive = node.state === 'active' || node.state === 'review' || node.state === 'ready';
|
|
||||||
return (
|
|
||||||
<NodeWrap key={node.id}>
|
|
||||||
<NodeCard $state={node.state}>
|
|
||||||
<NodeTop>
|
|
||||||
<NodeLabel>
|
|
||||||
<NodeName>{node.label}</NodeName>
|
|
||||||
<NodeRole>{node.role}</NodeRole>
|
|
||||||
</NodeLabel>
|
|
||||||
<StateBadge $state={node.state}>{stateText[node.state]}</StateBadge>
|
|
||||||
</NodeTop>
|
|
||||||
<NodeDetail>{node.detail}</NodeDetail>
|
|
||||||
<NodeHint>snapshot {String(index + 1).padStart(2, '0')}</NodeHint>
|
|
||||||
</NodeCard>
|
|
||||||
{index < nodes.length - 1 && <Connector $active={connectorActive} />}
|
|
||||||
</NodeWrap>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</FlowMap>
|
|
||||||
</PipelineCard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,647 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import React, { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
||||||
import styled, { keyframes } from 'styled-components';
|
|
||||||
import SisterAvatar from '@/components/common/SisterAvatar';
|
|
||||||
import { API_URL } from '@/lib/config';
|
|
||||||
import { withSessionRequest } from '@/lib/csrf';
|
|
||||||
import type { SisterName, AgentState } from './OfficeScene';
|
|
||||||
|
|
||||||
interface RuntimeMessage {
|
|
||||||
id: string;
|
|
||||||
role: 'user' | 'assistant' | 'tool';
|
|
||||||
content: string;
|
|
||||||
ts: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RuntimeSnapshot {
|
|
||||||
name: SisterName;
|
|
||||||
gatewayConnected: boolean;
|
|
||||||
mainState: AgentState;
|
|
||||||
currentTask: string | null;
|
|
||||||
activeSessionLabel: string | null;
|
|
||||||
recentMessages: RuntimeMessage[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ChatMessage {
|
|
||||||
id: string;
|
|
||||||
role: 'user' | 'assistant' | 'tool';
|
|
||||||
content: string;
|
|
||||||
toolName?: string;
|
|
||||||
ts: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ChatWorkspaceProps {
|
|
||||||
initialSister: SisterName;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SISTER_DISPLAY: Record<SisterName, string> = {
|
|
||||||
harang: '하랑이',
|
|
||||||
narang: '나랑이',
|
|
||||||
darang: '다랑이',
|
|
||||||
erang: '이랑이',
|
|
||||||
};
|
|
||||||
|
|
||||||
const SISTER_ROLES: Record<SisterName, string> = {
|
|
||||||
harang: 'Planning & Orchestration',
|
|
||||||
narang: 'Development & Implementation',
|
|
||||||
darang: 'QA & Review',
|
|
||||||
erang: 'Infra & Deploy',
|
|
||||||
};
|
|
||||||
|
|
||||||
const SISTER_ORDER: SisterName[] = ['harang', 'narang', 'darang', 'erang'];
|
|
||||||
|
|
||||||
const fadeIn = keyframes`
|
|
||||||
from { opacity: 0; transform: translateY(4px); }
|
|
||||||
to { opacity: 1; transform: translateY(0); }
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Workspace = styled.div`
|
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SisterTabs = styled.nav`
|
|
||||||
width: 200px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
border-right: 1px solid var(--border-color);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: var(--space-md) 0;
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
width: 100%;
|
|
||||||
flex-direction: row;
|
|
||||||
padding: 0;
|
|
||||||
overflow-x: auto;
|
|
||||||
border-right: none;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SisterTabHeader = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
padding: 0 var(--space-md) var(--space-md);
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SisterTab = styled.button<{ $active: boolean }>`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
background: ${({ $active }) => ($active ? 'rgba(255,255,255,0.04)' : 'transparent')};
|
|
||||||
border: none;
|
|
||||||
border-left: 2px solid ${({ $active }) => ($active ? 'var(--text-primary)' : 'transparent')};
|
|
||||||
color: ${({ $active }) => ($active ? 'var(--text-primary)' : 'var(--text-secondary)')};
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: left;
|
|
||||||
width: 100%;
|
|
||||||
transition: all 0.15s;
|
|
||||||
font-family: inherit;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: var(--text-primary);
|
|
||||||
background: rgba(255,255,255,0.03);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
border-left: none;
|
|
||||||
border-bottom: 2px solid ${({ $active }) => ($active ? 'var(--text-primary)' : 'transparent')};
|
|
||||||
white-space: nowrap;
|
|
||||||
flex-shrink: 0;
|
|
||||||
padding: var(--space-xs) var(--space-sm);
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TabMeta = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 2px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TabName = styled.div`
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TabRole = styled.div`
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MessageArea = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MessageHeader = styled.div`
|
|
||||||
padding: var(--space-md) var(--space-lg);
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-md);
|
|
||||||
flex-shrink: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderMeta = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderName = styled.div`
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderRole = styled.div`
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderBadge = styled.div<{ $ok: boolean }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: ${({ $ok }) => ($ok ? '#00BFA5' : 'var(--text-secondary)')};
|
|
||||||
border: 1px solid currentColor;
|
|
||||||
padding: 2px var(--space-sm);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Timeline = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-md);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MessageBubble = styled.div<{ $role: ChatMessage['role'] }>`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
align-items: ${({ $role }) => ($role === 'user' ? 'flex-end' : 'flex-start')};
|
|
||||||
animation: ${fadeIn} 0.2s ease;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const BubbleContent = styled.div<{ $role: ChatMessage['role'] }>`
|
|
||||||
max-width: 75%;
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: var(--text-primary);
|
|
||||||
background: ${({ $role }) =>
|
|
||||||
$role === 'user'
|
|
||||||
? 'rgba(255,255,255,0.06)'
|
|
||||||
: $role === 'tool'
|
|
||||||
? 'rgba(255, 152, 0, 0.06)'
|
|
||||||
: 'rgba(255,255,255,0.02)'};
|
|
||||||
border: 1px solid ${({ $role }) =>
|
|
||||||
$role === 'user'
|
|
||||||
? 'rgba(255,255,255,0.12)'
|
|
||||||
: $role === 'tool'
|
|
||||||
? 'rgba(255,152,0,0.2)'
|
|
||||||
: 'rgba(255,255,255,0.06)'};
|
|
||||||
font-family: ${({ $role }) => ($role === 'tool' ? 'var(--font-mono)' : 'inherit')};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const BubbleMeta = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
opacity: 0.6;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const EmptyTimeline = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-md);
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
text-align: center;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const RuntimeNotice = styled.div`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
padding: var(--space-md);
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
line-height: 1.7;
|
|
||||||
max-width: 320px;
|
|
||||||
text-align: center;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const InputArea = styled.div`
|
|
||||||
padding: var(--space-md) var(--space-lg);
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
align-items: flex-end;
|
|
||||||
flex-shrink: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MessageInput = styled.textarea`
|
|
||||||
flex: 1;
|
|
||||||
background: var(--bg-input, #1a1a1a);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
resize: none;
|
|
||||||
min-height: 40px;
|
|
||||||
max-height: 120px;
|
|
||||||
line-height: 1.5;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
&::placeholder {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SendBtn = styled.button`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: transparent;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
cursor: pointer;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
transition: all 0.15s;
|
|
||||||
white-space: nowrap;
|
|
||||||
align-self: flex-end;
|
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
opacity: 0.3;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const InputMeta = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
opacity: 0.6;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
text-align: center;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SisterContext = styled.aside`
|
|
||||||
width: 220px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
border-left: 1px solid var(--border-color);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
overflow-y: auto;
|
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ContextSection = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CtxLabel = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
padding-bottom: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CtxValue = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
line-height: 1.5;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CtxMono = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CloseBtn = styled.button`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: transparent;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
padding: var(--space-xs) var(--space-sm);
|
|
||||||
cursor: pointer;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
function formatTs(ts: string): string {
|
|
||||||
const date = new Date(ts);
|
|
||||||
const diff = Date.now() - date.getTime();
|
|
||||||
const min = Math.floor(diff / 60000);
|
|
||||||
if (min < 1) return '방금';
|
|
||||||
if (min < 60) return `${min}분 전`;
|
|
||||||
const hr = Math.floor(min / 60);
|
|
||||||
if (hr < 24) return `${hr}시간 전`;
|
|
||||||
return `${Math.floor(hr / 24)}일 전`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function runtimeStateLabel(state: AgentState): string {
|
|
||||||
if (state === 'thinking') return 'thinking';
|
|
||||||
if (state === 'tool_calling') return 'tool_calling';
|
|
||||||
if (state === 'speaking') return 'speaking';
|
|
||||||
if (state === 'error') return 'error';
|
|
||||||
return 'idle';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix #4: Remove localStorage token — use cookie-based auth via withSessionRequest
|
|
||||||
// Token is handled by HttpOnly cookies + CSRF, no client-side access needed
|
|
||||||
|
|
||||||
function mergeMessages(prev: ChatMessage[], incoming: ChatMessage[]) {
|
|
||||||
const map = new Map<string, ChatMessage>();
|
|
||||||
[...prev, ...incoming].forEach((item) => {
|
|
||||||
map.set(item.id, item);
|
|
||||||
});
|
|
||||||
return Array.from(map.values()).sort((a, b) => new Date(a.ts).getTime() - new Date(b.ts).getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapRuntimeMessages(items: RuntimeMessage[]): ChatMessage[] {
|
|
||||||
return items.map((item, index) => ({
|
|
||||||
id: item.id || `${item.role}-${item.ts ?? 'none'}-${index}`,
|
|
||||||
role: item.role,
|
|
||||||
content: item.content,
|
|
||||||
ts: item.ts ?? new Date().toISOString(),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ChatWorkspace({ initialSister, onClose }: ChatWorkspaceProps) {
|
|
||||||
const [activeSister, setActiveSister] = useState<SisterName>(initialSister);
|
|
||||||
const [allMessages, setAllMessages] = useState<Partial<Record<SisterName, ChatMessage[]>>>({});
|
|
||||||
const [runtimeBySister, setRuntimeBySister] = useState<Partial<Record<SisterName, RuntimeSnapshot>>>({});
|
|
||||||
// Per-sister draft — prevents input leaking across tabs
|
|
||||||
const [drafts, setDrafts] = useState<Partial<Record<SisterName, string>>>({});
|
|
||||||
const input = drafts[activeSister] ?? '';
|
|
||||||
const [sending, setSending] = useState(false);
|
|
||||||
const timelineRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
const messages = useMemo(() => allMessages[activeSister] ?? [], [allMessages, activeSister]);
|
|
||||||
const runtime = runtimeBySister[activeSister] ?? null;
|
|
||||||
// Cookie-based auth always available (no token check needed)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setActiveSister(initialSister);
|
|
||||||
}, [initialSister]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (timelineRef.current) {
|
|
||||||
timelineRef.current.scrollTop = timelineRef.current.scrollHeight;
|
|
||||||
}
|
|
||||||
}, [messages]);
|
|
||||||
|
|
||||||
const setMessages = useCallback((sister: SisterName, updater: (prev: ChatMessage[]) => ChatMessage[]) => {
|
|
||||||
setAllMessages((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[sister]: updater(prev[sister] ?? []),
|
|
||||||
}));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const loadRuntime = useCallback(async (sister: SisterName) => {
|
|
||||||
try {
|
|
||||||
const res = await fetch(`${API_URL}/api/sisters/${sister}/runtime`, withSessionRequest());
|
|
||||||
if (!res.ok) return;
|
|
||||||
const data = (await res.json()) as RuntimeSnapshot;
|
|
||||||
setRuntimeBySister((prev) => ({ ...prev, [sister]: data }));
|
|
||||||
const runtimeMessages = mapRuntimeMessages(data.recentMessages ?? []);
|
|
||||||
if (runtimeMessages.length > 0) {
|
|
||||||
setMessages(sister, (prev) => mergeMessages(prev, runtimeMessages));
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// ignore runtime refresh failures
|
|
||||||
}
|
|
||||||
}, [setMessages]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
void loadRuntime(activeSister);
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
void loadRuntime(activeSister);
|
|
||||||
}, 8000);
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, [activeSister, loadRuntime]);
|
|
||||||
|
|
||||||
const handleSend = useCallback(async () => {
|
|
||||||
const text = input.trim();
|
|
||||||
if (!text || sending) return;
|
|
||||||
|
|
||||||
// Cookie-based auth — no token check needed
|
|
||||||
|
|
||||||
const userMessage: ChatMessage = {
|
|
||||||
id: `user-${crypto.randomUUID()}`,
|
|
||||||
role: 'user',
|
|
||||||
content: text,
|
|
||||||
ts: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
setMessages(activeSister, (prev) => mergeMessages(prev, [userMessage]));
|
|
||||||
setDrafts((prev) => ({ ...prev, [activeSister]: '' }));
|
|
||||||
setSending(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await fetch(`${API_URL}/api/sisters/${activeSister}/chat`, withSessionRequest({
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ message: text }),
|
|
||||||
}, { csrf: true }));
|
|
||||||
|
|
||||||
const data = await res.json();
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(data?.message || '채팅 전송 실패');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data?.runtime) {
|
|
||||||
setRuntimeBySister((prev) => ({ ...prev, [activeSister]: data.runtime as RuntimeSnapshot }));
|
|
||||||
}
|
|
||||||
|
|
||||||
const reply = String(data?.reply || '').trim();
|
|
||||||
if (reply) {
|
|
||||||
setMessages(activeSister, (prev) => mergeMessages(prev, [{
|
|
||||||
id: `assistant-${crypto.randomUUID()}`,
|
|
||||||
role: 'assistant',
|
|
||||||
content: reply,
|
|
||||||
ts: new Date().toISOString(),
|
|
||||||
}]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadRuntime(activeSister);
|
|
||||||
} catch (error) {
|
|
||||||
const message = error instanceof Error ? error.message : '채팅 전송 중 오류가 발생했어.';
|
|
||||||
setMessages(activeSister, (prev) => mergeMessages(prev, [{
|
|
||||||
id: `error-${crypto.randomUUID()}`,
|
|
||||||
role: 'assistant',
|
|
||||||
content: `전송 실패: ${message}`,
|
|
||||||
ts: new Date().toISOString(),
|
|
||||||
}]));
|
|
||||||
} finally {
|
|
||||||
setSending(false);
|
|
||||||
}
|
|
||||||
}, [activeSister, input, loadRuntime, sending, setMessages]);
|
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
||||||
if (e.key === 'Enter' && !e.shiftKey) {
|
|
||||||
e.preventDefault();
|
|
||||||
void handleSend();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Workspace>
|
|
||||||
<SisterTabs>
|
|
||||||
<SisterTabHeader>direct chat</SisterTabHeader>
|
|
||||||
{SISTER_ORDER.map((name) => (
|
|
||||||
<SisterTab key={name} $active={activeSister === name} onClick={() => setActiveSister(name)}>
|
|
||||||
<SisterAvatar name={name} size={22} />
|
|
||||||
<TabMeta>
|
|
||||||
<TabName>{SISTER_DISPLAY[name]}</TabName>
|
|
||||||
<TabRole>{SISTER_ROLES[name].split(' ')[0]}</TabRole>
|
|
||||||
</TabMeta>
|
|
||||||
</SisterTab>
|
|
||||||
))}
|
|
||||||
</SisterTabs>
|
|
||||||
|
|
||||||
<MessageArea>
|
|
||||||
<MessageHeader>
|
|
||||||
<SisterAvatar name={activeSister} size={28} />
|
|
||||||
<HeaderMeta>
|
|
||||||
<HeaderName>{SISTER_DISPLAY[activeSister]}</HeaderName>
|
|
||||||
<HeaderRole>{SISTER_ROLES[activeSister]}</HeaderRole>
|
|
||||||
</HeaderMeta>
|
|
||||||
<HeaderBadge $ok={Boolean(runtime?.gatewayConnected)}>
|
|
||||||
{runtime?.gatewayConnected ? 'Runtime 연결됨' : 'Runtime 확인 중'}
|
|
||||||
</HeaderBadge>
|
|
||||||
<CloseBtn onClick={onClose}>✕ 닫기</CloseBtn>
|
|
||||||
</MessageHeader>
|
|
||||||
|
|
||||||
<Timeline ref={timelineRef}>
|
|
||||||
{messages.length === 0 ? (
|
|
||||||
<EmptyTimeline>
|
|
||||||
<SisterAvatar name={activeSister} size={32} />
|
|
||||||
<div>{SISTER_DISPLAY[activeSister]}에게 메시지를 보내봐.</div>
|
|
||||||
<RuntimeNotice>
|
|
||||||
{runtime?.gatewayConnected
|
|
||||||
? '직접 채팅이 자매 runtime으로 연결돼 있어. 입력하면 바로 전달돼.'
|
|
||||||
: 'runtime 상태를 확인 중이야. 연결이 느려도 메시지는 다시 시도할 수 있어.'}
|
|
||||||
</RuntimeNotice>
|
|
||||||
</EmptyTimeline>
|
|
||||||
) : (
|
|
||||||
messages.map((msg) => (
|
|
||||||
<MessageBubble key={msg.id} $role={msg.role}>
|
|
||||||
<BubbleContent $role={msg.role}>{msg.content}</BubbleContent>
|
|
||||||
<BubbleMeta>{formatTs(msg.ts)}</BubbleMeta>
|
|
||||||
</MessageBubble>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</Timeline>
|
|
||||||
|
|
||||||
<InputMeta>
|
|
||||||
shift+enter = 줄바꿈 · enter = 전송 · runtime: {runtime ? runtimeStateLabel(runtime.mainState) : 'loading'}
|
|
||||||
</InputMeta>
|
|
||||||
|
|
||||||
<InputArea>
|
|
||||||
<MessageInput
|
|
||||||
placeholder={`${SISTER_DISPLAY[activeSister]}에게 지시해...`}
|
|
||||||
value={input}
|
|
||||||
onChange={(e) => setDrafts((prev) => ({ ...prev, [activeSister]: e.target.value }))}
|
|
||||||
onKeyDown={handleKeyDown}
|
|
||||||
rows={1}
|
|
||||||
/>
|
|
||||||
<SendBtn onClick={() => void handleSend()} disabled={!input.trim() || sending}>
|
|
||||||
{sending ? '전송 중' : '전송'}
|
|
||||||
</SendBtn>
|
|
||||||
</InputArea>
|
|
||||||
</MessageArea>
|
|
||||||
|
|
||||||
<SisterContext>
|
|
||||||
<ContextSection>
|
|
||||||
<CtxLabel>agent</CtxLabel>
|
|
||||||
<CtxValue>{SISTER_DISPLAY[activeSister]}</CtxValue>
|
|
||||||
<CtxMono>{SISTER_ROLES[activeSister]}</CtxMono>
|
|
||||||
</ContextSection>
|
|
||||||
|
|
||||||
<ContextSection>
|
|
||||||
<CtxLabel>채팅 상태</CtxLabel>
|
|
||||||
<CtxValue>{runtime?.gatewayConnected ? 'Runtime 연결됨' : 'Runtime 확인 중'}</CtxValue>
|
|
||||||
<CtxMono>{runtime ? runtimeStateLabel(runtime.mainState) : 'loading'}</CtxMono>
|
|
||||||
</ContextSection>
|
|
||||||
|
|
||||||
<ContextSection>
|
|
||||||
<CtxLabel>data source</CtxLabel>
|
|
||||||
<CtxMono>
|
|
||||||
control: ssh → openclaw agent
|
|
||||||
<br />
|
|
||||||
activity: runtime session snapshot
|
|
||||||
</CtxMono>
|
|
||||||
</ContextSection>
|
|
||||||
|
|
||||||
<ContextSection>
|
|
||||||
<CtxLabel>current task</CtxLabel>
|
|
||||||
<CtxValue>{runtime?.currentTask ?? runtime?.activeSessionLabel ?? '작업 정보 없음'}</CtxValue>
|
|
||||||
</ContextSection>
|
|
||||||
</SisterContext>
|
|
||||||
</Workspace>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,422 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import Link from 'next/link';
|
|
||||||
import SisterAvatar from '@/components/common/SisterAvatar';
|
|
||||||
import type { SisterNode, SubAgent, SisterName, AgentState, SelectedAgent } from './OfficeScene';
|
|
||||||
|
|
||||||
interface ContextPanelProps {
|
|
||||||
selected: SelectedAgent | null;
|
|
||||||
sisters: SisterNode[];
|
|
||||||
onOpenChat: (sisterName: SisterName) => void;
|
|
||||||
onClear: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Panel = styled.aside`
|
|
||||||
width: 300px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
border-left: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow-y: auto;
|
|
||||||
|
|
||||||
@media (max-width: 1199px) {
|
|
||||||
width: 260px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
width: 100%;
|
|
||||||
border-left: none;
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
max-height: 260px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PanelHeader = styled.div`
|
|
||||||
padding: var(--space-md) var(--space-lg);
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
flex-shrink: 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PanelTitle = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ClearBtn = styled.button`
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0;
|
|
||||||
line-height: 1;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const PanelBody = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: var(--space-lg);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const EmptyState = styled.div`
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.6;
|
|
||||||
text-align: center;
|
|
||||||
padding: var(--space-xl) 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentHeader = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: var(--space-md);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentAvatarWrap = styled.div`
|
|
||||||
flex-shrink: 0;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentMeta = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentName = styled.div`
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentRole = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AgentType = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StateRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StateDot = styled.span<{ $state: AgentState }>`
|
|
||||||
width: 8px;
|
|
||||||
height: 8px;
|
|
||||||
border-radius: 50%;
|
|
||||||
flex-shrink: 0;
|
|
||||||
background: ${({ $state }) => {
|
|
||||||
const colors: Record<AgentState, string> = {
|
|
||||||
idle: '#444',
|
|
||||||
thinking: '#2979FF',
|
|
||||||
tool_calling: '#FF9800',
|
|
||||||
speaking: '#00BFA5',
|
|
||||||
error: '#FF1744',
|
|
||||||
};
|
|
||||||
return colors[$state];
|
|
||||||
}};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StateLabel = styled.span<{ $state: AgentState }>`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 11px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
color: ${({ $state }) => {
|
|
||||||
const colors: Record<AgentState, string> = {
|
|
||||||
idle: 'var(--text-secondary)',
|
|
||||||
thinking: '#2979FF',
|
|
||||||
tool_calling: '#FF9800',
|
|
||||||
speaking: '#00BFA5',
|
|
||||||
error: '#FF1744',
|
|
||||||
};
|
|
||||||
return colors[$state];
|
|
||||||
}};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Section = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SectionLabel = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
padding-bottom: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SectionValue = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
line-height: 1.5;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CurrentTaskBox = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: #58A6FF;
|
|
||||||
padding: var(--space-sm) var(--space-md);
|
|
||||||
background: rgba(88, 166, 255, 0.06);
|
|
||||||
border-left: 2px solid #58A6FF;
|
|
||||||
line-height: 1.5;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SubagentGrid = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SubagentRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SubDot = styled.span<{ $state: AgentState }>`
|
|
||||||
width: 6px;
|
|
||||||
height: 6px;
|
|
||||||
border-radius: 50%;
|
|
||||||
flex-shrink: 0;
|
|
||||||
background: ${({ $state }) => {
|
|
||||||
const colors: Record<AgentState, string> = {
|
|
||||||
idle: '#444',
|
|
||||||
thinking: '#2979FF',
|
|
||||||
tool_calling: '#FF9800',
|
|
||||||
speaking: '#00BFA5',
|
|
||||||
error: '#FF1744',
|
|
||||||
};
|
|
||||||
return colors[$state];
|
|
||||||
}};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SubName = styled.span`
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 11px;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ActionRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ActionBtn = styled.button`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: transparent;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
padding: var(--space-xs) var(--space-sm);
|
|
||||||
cursor: pointer;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
transition: all 0.15s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ActionLink = styled(Link)`
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: transparent;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
padding: var(--space-xs) var(--space-sm);
|
|
||||||
text-decoration: none;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
transition: all 0.15s;
|
|
||||||
display: inline-block;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FallbackNote = styled.div`
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
opacity: 0.7;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SISTER_DISPLAY: Record<SisterName, string> = {
|
|
||||||
harang: '하랑이',
|
|
||||||
narang: '나랑이',
|
|
||||||
darang: '다랑이',
|
|
||||||
erang: '이랑이',
|
|
||||||
};
|
|
||||||
|
|
||||||
function SisterDetail({ sister, onOpenChat }: { sister: SisterNode; onOpenChat: (name: SisterName) => void }) {
|
|
||||||
const hasLiveSubagentState = sister.subagents.some((item) => item.sessionLabel || item.currentTask || item.updatedAt);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<AgentHeader>
|
|
||||||
<AgentAvatarWrap>
|
|
||||||
<SisterAvatar name={sister.name} size={40} />
|
|
||||||
</AgentAvatarWrap>
|
|
||||||
<AgentMeta>
|
|
||||||
<AgentName>{SISTER_DISPLAY[sister.name]}</AgentName>
|
|
||||||
<AgentRole>{sister.role}</AgentRole>
|
|
||||||
<AgentType>main agent</AgentType>
|
|
||||||
</AgentMeta>
|
|
||||||
</AgentHeader>
|
|
||||||
|
|
||||||
<StateRow>
|
|
||||||
<StateDot $state={sister.state} />
|
|
||||||
<StateLabel $state={sister.state}>{sister.state}</StateLabel>
|
|
||||||
</StateRow>
|
|
||||||
|
|
||||||
{(sister.currentTask || sister.activeSessionLabel) && (
|
|
||||||
<Section>
|
|
||||||
<SectionLabel>current task</SectionLabel>
|
|
||||||
<CurrentTaskBox>{sister.currentTask ?? sister.activeSessionLabel ?? '작업 정보 없음'}</CurrentTaskBox>
|
|
||||||
</Section>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Section>
|
|
||||||
<SectionLabel>subagents ({sister.subagents.length})</SectionLabel>
|
|
||||||
<SubagentGrid>
|
|
||||||
{sister.subagents.map((sub) => (
|
|
||||||
<SubagentRow key={sub.id}>
|
|
||||||
<SubDot $state={sub.state} />
|
|
||||||
<span>{sub.label}</span>
|
|
||||||
<SubName>· {sub.state}</SubName>
|
|
||||||
</SubagentRow>
|
|
||||||
))}
|
|
||||||
</SubagentGrid>
|
|
||||||
<FallbackNote>{hasLiveSubagentState ? 'subagent state: live runtime' : 'subagent state: fallback'}</FallbackNote>
|
|
||||||
</Section>
|
|
||||||
|
|
||||||
<ActionRow>
|
|
||||||
<ActionBtn onClick={() => onOpenChat(sister.name)}>채팅</ActionBtn>
|
|
||||||
<ActionLink href={`/sisters/${sister.name}`}>상세</ActionLink>
|
|
||||||
</ActionRow>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SubagentDetail({
|
|
||||||
sub,
|
|
||||||
sister,
|
|
||||||
onOpenChat,
|
|
||||||
}: {
|
|
||||||
sub: SubAgent;
|
|
||||||
sister: SisterNode;
|
|
||||||
onOpenChat: (name: SisterName) => void;
|
|
||||||
}) {
|
|
||||||
const liveNote = sub.sessionLabel || sub.currentTask || sub.updatedAt;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<AgentHeader>
|
|
||||||
<AgentAvatarWrap>
|
|
||||||
<SisterAvatar name={sister.name} size={40} />
|
|
||||||
</AgentAvatarWrap>
|
|
||||||
<AgentMeta>
|
|
||||||
<AgentName>{sub.label}</AgentName>
|
|
||||||
<AgentRole>{sub.name}</AgentRole>
|
|
||||||
<AgentType>subagent · {SISTER_DISPLAY[sister.name]} 소속</AgentType>
|
|
||||||
</AgentMeta>
|
|
||||||
</AgentHeader>
|
|
||||||
|
|
||||||
<StateRow>
|
|
||||||
<StateDot $state={sub.state} />
|
|
||||||
<StateLabel $state={sub.state}>{sub.state}</StateLabel>
|
|
||||||
</StateRow>
|
|
||||||
|
|
||||||
<Section>
|
|
||||||
<SectionLabel>parent</SectionLabel>
|
|
||||||
<SectionValue>{SISTER_DISPLAY[sister.name]} · {sister.role}</SectionValue>
|
|
||||||
</Section>
|
|
||||||
|
|
||||||
{(sub.currentTask || sub.sessionLabel) && (
|
|
||||||
<Section>
|
|
||||||
<SectionLabel>current task</SectionLabel>
|
|
||||||
<CurrentTaskBox>{sub.currentTask ?? sub.sessionLabel ?? '작업 정보 없음'}</CurrentTaskBox>
|
|
||||||
</Section>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<FallbackNote>{liveNote ? 'subagent state: live runtime' : 'subagent state: fallback · no direct api'}</FallbackNote>
|
|
||||||
|
|
||||||
<ActionRow>
|
|
||||||
<ActionBtn onClick={() => onOpenChat(sister.name)}>{SISTER_DISPLAY[sister.name]} 채팅</ActionBtn>
|
|
||||||
<ActionLink href={`/sisters/${sister.name}`}>자매 상세</ActionLink>
|
|
||||||
</ActionRow>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ContextPanel({ selected, sisters, onOpenChat, onClear }: ContextPanelProps) {
|
|
||||||
const getSister = (name: SisterName) => sisters.find((s) => s.name === name);
|
|
||||||
|
|
||||||
let content: React.ReactNode = (
|
|
||||||
<EmptyState>
|
|
||||||
에이전트를 선택하면
|
|
||||||
<br />
|
|
||||||
상세 정보가 표시됩니다.
|
|
||||||
</EmptyState>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (selected?.type === 'sister') {
|
|
||||||
const sister = getSister(selected.name);
|
|
||||||
if (sister) content = <SisterDetail sister={sister} onOpenChat={onOpenChat} />;
|
|
||||||
} else if (selected?.type === 'subagent') {
|
|
||||||
const sister = getSister(selected.sister);
|
|
||||||
const sub = sister?.subagents.find((item) => item.id === selected.id);
|
|
||||||
if (sister && sub) content = <SubagentDetail sub={sub} sister={sister} onOpenChat={onOpenChat} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Panel>
|
|
||||||
<PanelHeader>
|
|
||||||
<PanelTitle>context panel</PanelTitle>
|
|
||||||
{selected && <ClearBtn onClick={onClear}>✕</ClearBtn>}
|
|
||||||
</PanelHeader>
|
|
||||||
<PanelBody>{content}</PanelBody>
|
|
||||||
</Panel>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,496 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import React, { useCallback } from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { API_URL } from '@/lib/config';
|
|
||||||
|
|
||||||
export type AgentState = 'idle' | 'thinking' | 'tool_calling' | 'speaking' | 'error';
|
|
||||||
export type SisterName = 'harang' | 'narang' | 'darang' | 'erang';
|
|
||||||
|
|
||||||
export interface SubAgent {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
label: string;
|
|
||||||
sister: SisterName;
|
|
||||||
state: AgentState;
|
|
||||||
currentTask?: string | null;
|
|
||||||
updatedAt?: number | null;
|
|
||||||
sessionLabel?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SisterNode {
|
|
||||||
name: SisterName;
|
|
||||||
displayName: string;
|
|
||||||
role: string;
|
|
||||||
state: AgentState;
|
|
||||||
currentTask: string | null;
|
|
||||||
activeSessionLabel?: string | null;
|
|
||||||
subagents: SubAgent[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SelectedAgent =
|
|
||||||
| { type: 'sister'; name: SisterName }
|
|
||||||
| { type: 'subagent'; id: string; sister: SisterName };
|
|
||||||
|
|
||||||
interface OfficeSceneProps {
|
|
||||||
sisters: SisterNode[];
|
|
||||||
selected: SelectedAgent | null;
|
|
||||||
onSelectSister: (name: SisterName) => void;
|
|
||||||
onSelectSubagent: (id: string, sister: SisterName) => void;
|
|
||||||
dataMode: 'live' | 'snapshot' | 'fallback';
|
|
||||||
subagentMode: 'live' | 'fallback';
|
|
||||||
}
|
|
||||||
|
|
||||||
const SceneWrapper = styled.div`
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 800 / 460;
|
|
||||||
max-height: 60vh;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-surface);
|
|
||||||
overflow: hidden;
|
|
||||||
user-select: none;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FreshnessLabel = styled.div`
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
right: 12px;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
font-size: 10px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
pointer-events: none;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const WsDot = styled.span<{ $connected: boolean }>`
|
|
||||||
display: inline-block;
|
|
||||||
width: 6px;
|
|
||||||
height: 6px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: ${({ $connected }) => ($connected ? '#00FF00' : '#666')};
|
|
||||||
margin-right: 5px;
|
|
||||||
vertical-align: middle;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const VB_W = 800;
|
|
||||||
const VB_H = 460;
|
|
||||||
type Point = [number, number];
|
|
||||||
|
|
||||||
const ZONES = {
|
|
||||||
harang: [5, 5, 345, 200] as const,
|
|
||||||
darang: [450, 5, 345, 200] as const,
|
|
||||||
narang: [5, 260, 345, 195] as const,
|
|
||||||
erang: [450, 260, 345, 195] as const,
|
|
||||||
};
|
|
||||||
|
|
||||||
const SISTER_POS: Record<SisterName, [number, number]> = {
|
|
||||||
harang: [75, 105],
|
|
||||||
darang: [725, 105],
|
|
||||||
narang: [75, 358],
|
|
||||||
erang: [725, 358],
|
|
||||||
};
|
|
||||||
|
|
||||||
const CONF = { cx: 400, cy: 232, rx: 55, ry: 30 };
|
|
||||||
|
|
||||||
const SUBAGENT_POSITIONS: Record<SisterName, Point[]> = {
|
|
||||||
harang: [[175, 65], [270, 65], [220, 160]],
|
|
||||||
darang: [[460, 65], [560, 65], [660, 65], [460, 160], [560, 160]],
|
|
||||||
narang: [[175, 295], [270, 295], [175, 395], [270, 395]],
|
|
||||||
erang: [[460, 295], [555, 295], [650, 295], [460, 395], [555, 395]],
|
|
||||||
};
|
|
||||||
|
|
||||||
const SUBAGENT_TARGETS: Record<SisterName, Point[]> = {
|
|
||||||
harang: [[295, 112], [338, 148], [365, 190]],
|
|
||||||
darang: [[505, 94], [560, 112], [462, 148], [438, 188], [520, 196]],
|
|
||||||
narang: [[292, 332], [330, 302], [362, 276], [344, 374]],
|
|
||||||
erang: [[618, 322], [664, 298], [702, 286], [610, 388], [664, 380]],
|
|
||||||
};
|
|
||||||
|
|
||||||
const ZONE_COLORS: Record<SisterName, string> = {
|
|
||||||
harang: 'rgba(41, 121, 255, 0.06)',
|
|
||||||
narang: 'rgba(0, 191, 165, 0.06)',
|
|
||||||
darang: 'rgba(255, 64, 129, 0.06)',
|
|
||||||
erang: 'rgba(255, 109, 0, 0.06)',
|
|
||||||
};
|
|
||||||
|
|
||||||
const ZONE_BORDER: Record<SisterName, string> = {
|
|
||||||
harang: 'rgba(41, 121, 255, 0.25)',
|
|
||||||
narang: 'rgba(0, 191, 165, 0.25)',
|
|
||||||
darang: 'rgba(255, 64, 129, 0.25)',
|
|
||||||
erang: 'rgba(255, 109, 0, 0.25)',
|
|
||||||
};
|
|
||||||
|
|
||||||
const STATE_COLORS: Record<AgentState, string> = {
|
|
||||||
idle: '#444444',
|
|
||||||
thinking: '#2979FF',
|
|
||||||
tool_calling: '#FF9800',
|
|
||||||
speaking: '#00BFA5',
|
|
||||||
error: '#FF1744',
|
|
||||||
};
|
|
||||||
|
|
||||||
const STATE_PROGRESS: Record<AgentState, number> = {
|
|
||||||
idle: 0,
|
|
||||||
error: 0,
|
|
||||||
thinking: 0.48,
|
|
||||||
tool_calling: 0.88,
|
|
||||||
speaking: 0.66,
|
|
||||||
};
|
|
||||||
|
|
||||||
function lerpPoint(from: Point, to: Point, progress: number): Point {
|
|
||||||
return [
|
|
||||||
from[0] + (to[0] - from[0]) * progress,
|
|
||||||
from[1] + (to[1] - from[1]) * progress,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSubagentPosition(sister: SisterName, index: number, state: AgentState): Point {
|
|
||||||
const from = SUBAGENT_POSITIONS[sister][index] ?? SUBAGENT_POSITIONS[sister][0];
|
|
||||||
const to = SUBAGENT_TARGETS[sister][index] ?? from;
|
|
||||||
return lerpPoint(from, to, STATE_PROGRESS[state]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSubagentMotion(state: AgentState, index: number): { dx: number; dy: number; dur: string } | null {
|
|
||||||
const phase = index % 2 === 0 ? 1 : -1;
|
|
||||||
|
|
||||||
if (state === 'thinking') return { dx: 5 * phase, dy: -6, dur: '3.6s' };
|
|
||||||
if (state === 'tool_calling') return { dx: 10 * phase, dy: -14, dur: '2s' };
|
|
||||||
if (state === 'speaking') return { dx: 6 * phase, dy: -4, dur: '2.8s' };
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function SisterCircle({
|
|
||||||
cx,
|
|
||||||
cy,
|
|
||||||
r,
|
|
||||||
state,
|
|
||||||
name,
|
|
||||||
selected,
|
|
||||||
onClick,
|
|
||||||
}: {
|
|
||||||
cx: number;
|
|
||||||
cy: number;
|
|
||||||
r: number;
|
|
||||||
state: AgentState;
|
|
||||||
name: SisterName;
|
|
||||||
selected: boolean;
|
|
||||||
onClick: () => void;
|
|
||||||
}) {
|
|
||||||
const color = STATE_COLORS[state];
|
|
||||||
const clipId = `avatar-clip-${name}`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<g
|
|
||||||
role="button"
|
|
||||||
tabIndex={0}
|
|
||||||
aria-label={`${name} — state: ${state}`}
|
|
||||||
onClick={onClick}
|
|
||||||
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onClick(); } }}
|
|
||||||
style={{ cursor: 'pointer', outline: 'none' }}
|
|
||||||
>
|
|
||||||
{selected && (
|
|
||||||
<circle
|
|
||||||
cx={cx}
|
|
||||||
cy={cy}
|
|
||||||
r={r + 8}
|
|
||||||
fill="none"
|
|
||||||
stroke="var(--text-primary)"
|
|
||||||
strokeWidth={1}
|
|
||||||
strokeDasharray="4 3"
|
|
||||||
opacity={0.6}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<circle
|
|
||||||
cx={cx}
|
|
||||||
cy={cy}
|
|
||||||
r={r + 4}
|
|
||||||
fill="none"
|
|
||||||
stroke={color}
|
|
||||||
strokeWidth={state === 'error' ? 2.5 : 1.5}
|
|
||||||
opacity={state === 'idle' ? 0.4 : 1}
|
|
||||||
>
|
|
||||||
{state === 'thinking' && (
|
|
||||||
<animate attributeName="opacity" values="0.45;1;0.45" dur="1.8s" repeatCount="indefinite" />
|
|
||||||
)}
|
|
||||||
{state === 'tool_calling' && (
|
|
||||||
<animate attributeName="stroke-opacity" values="1;0.2;1" dur="0.9s" repeatCount="indefinite" />
|
|
||||||
)}
|
|
||||||
</circle>
|
|
||||||
<circle cx={cx} cy={cy} r={r} fill="#1e1e1e" stroke={color} strokeWidth={1} />
|
|
||||||
<defs>
|
|
||||||
<clipPath id={clipId}>
|
|
||||||
<circle cx={cx} cy={cy} r={r - 2} />
|
|
||||||
</clipPath>
|
|
||||||
</defs>
|
|
||||||
<image
|
|
||||||
href={`${API_URL}/api/sisters/${name}/avatar`}
|
|
||||||
x={cx - r + 2}
|
|
||||||
y={cy - r + 2}
|
|
||||||
width={(r - 2) * 2}
|
|
||||||
height={(r - 2) * 2}
|
|
||||||
preserveAspectRatio="xMidYMid slice"
|
|
||||||
clipPath={`url(#${clipId})`}
|
|
||||||
/>
|
|
||||||
<text
|
|
||||||
x={cx}
|
|
||||||
y={cy + r + 16}
|
|
||||||
textAnchor="middle"
|
|
||||||
fontSize={9}
|
|
||||||
fontFamily="var(--font-mono)"
|
|
||||||
fill={color}
|
|
||||||
style={{ textTransform: 'uppercase', letterSpacing: '0.06em', userSelect: 'none', pointerEvents: 'none' }}
|
|
||||||
>
|
|
||||||
{state}
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SubagentCircle({
|
|
||||||
cx,
|
|
||||||
cy,
|
|
||||||
r,
|
|
||||||
state,
|
|
||||||
label,
|
|
||||||
selected,
|
|
||||||
motion,
|
|
||||||
motionBegin,
|
|
||||||
onClick,
|
|
||||||
}: {
|
|
||||||
cx: number;
|
|
||||||
cy: number;
|
|
||||||
r: number;
|
|
||||||
state: AgentState;
|
|
||||||
label: string;
|
|
||||||
selected: boolean;
|
|
||||||
motion: { dx: number; dy: number; dur: string } | null;
|
|
||||||
motionBegin: string;
|
|
||||||
onClick: () => void;
|
|
||||||
}) {
|
|
||||||
const color = STATE_COLORS[state];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<g
|
|
||||||
role="button"
|
|
||||||
tabIndex={0}
|
|
||||||
aria-label={`subagent ${label} — state: ${state}`}
|
|
||||||
onClick={onClick}
|
|
||||||
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onClick(); } }}
|
|
||||||
style={{ cursor: 'pointer', outline: 'none' }}
|
|
||||||
>
|
|
||||||
{motion && (
|
|
||||||
<animateTransform
|
|
||||||
attributeName="transform"
|
|
||||||
type="translate"
|
|
||||||
values={`0 0; ${motion.dx} ${motion.dy}; 0 0`}
|
|
||||||
dur={motion.dur}
|
|
||||||
begin={motionBegin}
|
|
||||||
repeatCount="indefinite"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{selected && (
|
|
||||||
<circle cx={cx} cy={cy} r={r + 5} fill="none" stroke="var(--text-primary)" strokeWidth={1} opacity={0.5} />
|
|
||||||
)}
|
|
||||||
<circle cx={cx} cy={cy} r={r + 2} fill="none" stroke={color} strokeWidth={1} opacity={state === 'idle' ? 0.3 : 0.8}>
|
|
||||||
{state === 'thinking' && (
|
|
||||||
<animate attributeName="opacity" values="0.35;0.95;0.35" dur="2s" repeatCount="indefinite" />
|
|
||||||
)}
|
|
||||||
</circle>
|
|
||||||
<circle cx={cx} cy={cy} r={r} fill="#1a1a1a" stroke={color} strokeWidth={0.8} />
|
|
||||||
<text
|
|
||||||
x={cx}
|
|
||||||
y={cy + 4}
|
|
||||||
textAnchor="middle"
|
|
||||||
fontSize={8}
|
|
||||||
fontFamily="var(--font-mono)"
|
|
||||||
fill={color}
|
|
||||||
opacity={0.9}
|
|
||||||
style={{ userSelect: 'none', pointerEvents: 'none' }}
|
|
||||||
>
|
|
||||||
{label.length > 8 ? `${label.slice(0, 7)}…` : label}
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ConnectorLine({ x1, y1, x2, y2, active }: { x1: number; y1: number; x2: number; y2: number; active: boolean }) {
|
|
||||||
return (
|
|
||||||
<line
|
|
||||||
x1={x1}
|
|
||||||
y1={y1}
|
|
||||||
x2={x2}
|
|
||||||
y2={y2}
|
|
||||||
stroke={active ? 'rgba(245,245,245,0.35)' : 'rgba(255,255,255,0.08)'}
|
|
||||||
strokeWidth={active ? 1.5 : 1}
|
|
||||||
strokeDasharray={active ? '6 4' : '3 4'}
|
|
||||||
strokeDashoffset={active ? 40 : 0}
|
|
||||||
>
|
|
||||||
{active && <animate attributeName="stroke-dashoffset" values="40;0" dur="1.4s" repeatCount="indefinite" />}
|
|
||||||
</line>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PathConnector({ d, active }: { d: string; active: boolean }) {
|
|
||||||
return (
|
|
||||||
<path
|
|
||||||
d={d}
|
|
||||||
fill="none"
|
|
||||||
stroke={active ? 'rgba(245,245,245,0.3)' : 'rgba(255,255,255,0.06)'}
|
|
||||||
strokeWidth={active ? 1.5 : 1}
|
|
||||||
strokeDasharray={active ? '6 4' : '3 4'}
|
|
||||||
strokeDashoffset={active ? 40 : 0}
|
|
||||||
>
|
|
||||||
{active && <animate attributeName="stroke-dashoffset" values="40;0" dur="1.8s" repeatCount="indefinite" />}
|
|
||||||
</path>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const SISTER_ORDER: SisterName[] = ['harang', 'narang', 'darang', 'erang'];
|
|
||||||
|
|
||||||
export default function OfficeScene({
|
|
||||||
sisters,
|
|
||||||
selected,
|
|
||||||
onSelectSister,
|
|
||||||
onSelectSubagent,
|
|
||||||
dataMode,
|
|
||||||
subagentMode,
|
|
||||||
}: OfficeSceneProps) {
|
|
||||||
const getSister = useCallback(
|
|
||||||
(name: SisterName) => sisters.find((s) => s.name === name),
|
|
||||||
[sisters],
|
|
||||||
);
|
|
||||||
|
|
||||||
const isActive = useCallback(
|
|
||||||
(name: SisterName) => {
|
|
||||||
const sister = getSister(name);
|
|
||||||
return sister?.state === 'thinking' || sister?.state === 'tool_calling' || sister?.state === 'speaking';
|
|
||||||
},
|
|
||||||
[getSister],
|
|
||||||
);
|
|
||||||
|
|
||||||
const isSisterSelected = (name: SisterName) => selected?.type === 'sister' && selected.name === name;
|
|
||||||
const isSubSelected = (id: string) => selected?.type === 'subagent' && selected.id === id;
|
|
||||||
|
|
||||||
const harangActive = isActive('harang');
|
|
||||||
const narangActive = isActive('narang');
|
|
||||||
const darangActive = isActive('darang');
|
|
||||||
const erangActive = isActive('erang');
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SceneWrapper>
|
|
||||||
<FreshnessLabel>
|
|
||||||
<WsDot $connected={dataMode === 'live'} />
|
|
||||||
{dataMode === 'live' ? 'live · ws' : dataMode === 'snapshot' ? 'snapshot · poll' : 'fallback · doc-derived'}
|
|
||||||
{subagentMode === 'live' ? ' · subagents: live · runtime' : ' · subagents: fallback'}
|
|
||||||
</FreshnessLabel>
|
|
||||||
|
|
||||||
<svg viewBox={`0 0 ${VB_W} ${VB_H}`} width="100%" height="100%" style={{ display: 'block' }}>
|
|
||||||
{SISTER_ORDER.map((name) => {
|
|
||||||
const [zx, zy, zw, zh] = ZONES[name];
|
|
||||||
return (
|
|
||||||
<rect
|
|
||||||
key={`zone-${name}`}
|
|
||||||
x={zx}
|
|
||||||
y={zy}
|
|
||||||
width={zw}
|
|
||||||
height={zh}
|
|
||||||
rx={4}
|
|
||||||
fill={ZONE_COLORS[name]}
|
|
||||||
stroke={ZONE_BORDER[name]}
|
|
||||||
strokeWidth={1}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
<rect x={358} y={5} width={84} height={450} rx={2} fill="#111111" stroke="rgba(255,255,255,0.04)" strokeWidth={1} />
|
|
||||||
<rect x={5} y={205} width={790} height={50} rx={2} fill="#111111" stroke="rgba(255,255,255,0.04)" strokeWidth={1} />
|
|
||||||
|
|
||||||
<ellipse cx={CONF.cx} cy={CONF.cy} rx={CONF.rx} ry={CONF.ry} fill="#1a1a1a" stroke="rgba(255,255,255,0.15)" strokeWidth={1} />
|
|
||||||
<text x={CONF.cx} y={CONF.cy + 4} textAnchor="middle" fontSize={9} fontFamily="var(--font-mono)" fill="rgba(255,255,255,0.4)">
|
|
||||||
회의실
|
|
||||||
</text>
|
|
||||||
|
|
||||||
<ConnectorLine x1={SISTER_POS.harang[0]} y1={SISTER_POS.harang[1] + 30} x2={SISTER_POS.narang[0]} y2={SISTER_POS.narang[1] - 30} active={harangActive || narangActive} />
|
|
||||||
<ConnectorLine x1={SISTER_POS.darang[0]} y1={SISTER_POS.darang[1] + 30} x2={SISTER_POS.erang[0]} y2={SISTER_POS.erang[1] - 30} active={darangActive || erangActive} />
|
|
||||||
<ConnectorLine x1={SISTER_POS.harang[0] + 30} y1={SISTER_POS.harang[1]} x2={SISTER_POS.darang[0] - 30} y2={SISTER_POS.darang[1]} active={harangActive || darangActive} />
|
|
||||||
<ConnectorLine x1={SISTER_POS.narang[0] + 30} y1={SISTER_POS.narang[1]} x2={SISTER_POS.erang[0] - 30} y2={SISTER_POS.erang[1]} active={narangActive || erangActive} />
|
|
||||||
<PathConnector d={`M${SISTER_POS.narang[0] + 20},${SISTER_POS.narang[1] - 20} Q${CONF.cx},${CONF.cy} ${SISTER_POS.darang[0] - 20},${SISTER_POS.darang[1] + 20}`} active={narangActive && darangActive} />
|
|
||||||
|
|
||||||
{([
|
|
||||||
['harang', 18, 22, '하랑이 · Planning'] as const,
|
|
||||||
['darang', 463, 22, '다랑이 · QA'] as const,
|
|
||||||
['narang', 18, 272, '나랑이 · Dev'] as const,
|
|
||||||
['erang', 463, 272, '이랑이 · Infra'] as const,
|
|
||||||
] as const).map(([name, lx, ly, text]) => (
|
|
||||||
<text key={`label-${name}`} x={lx} y={ly} fontSize={10} fontFamily="var(--font-mono)" fill={ZONE_BORDER[name]}>
|
|
||||||
{text}
|
|
||||||
</text>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{SISTER_ORDER.map((name) => {
|
|
||||||
const sister = getSister(name);
|
|
||||||
const state: AgentState = sister?.state ?? 'idle';
|
|
||||||
const [cx, cy] = SISTER_POS[name];
|
|
||||||
return (
|
|
||||||
<SisterCircle
|
|
||||||
key={`sister-${name}`}
|
|
||||||
cx={cx}
|
|
||||||
cy={cy}
|
|
||||||
r={28}
|
|
||||||
state={state}
|
|
||||||
name={name}
|
|
||||||
selected={isSisterSelected(name)}
|
|
||||||
onClick={() => onSelectSister(name)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{SISTER_ORDER.map((sisterName) => {
|
|
||||||
const sister = getSister(sisterName);
|
|
||||||
const subagents = sister?.subagents ?? [];
|
|
||||||
return subagents.map((sub, i) => {
|
|
||||||
const pos = getSubagentPosition(sisterName, i, sub.state);
|
|
||||||
const motion = getSubagentMotion(sub.state, i);
|
|
||||||
return (
|
|
||||||
<SubagentCircle
|
|
||||||
key={sub.id}
|
|
||||||
cx={pos[0]}
|
|
||||||
cy={pos[1]}
|
|
||||||
r={14}
|
|
||||||
state={sub.state}
|
|
||||||
label={sub.name}
|
|
||||||
selected={isSubSelected(sub.id)}
|
|
||||||
motion={motion}
|
|
||||||
motionBegin={`${i * 0.22}s`}
|
|
||||||
onClick={() => onSelectSubagent(sub.id, sisterName)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
|
|
||||||
{SISTER_ORDER.map((sisterName) => {
|
|
||||||
const sister = getSister(sisterName);
|
|
||||||
const subagents = sister?.subagents ?? [];
|
|
||||||
const [sx, sy] = SISTER_POS[sisterName];
|
|
||||||
return subagents.map((sub, i) => {
|
|
||||||
const pos = getSubagentPosition(sisterName, i, sub.state);
|
|
||||||
const active = sub.state !== 'idle' && sub.state !== 'error';
|
|
||||||
return (
|
|
||||||
<line
|
|
||||||
key={`conn-${sub.id}`}
|
|
||||||
x1={sx}
|
|
||||||
y1={sy}
|
|
||||||
x2={pos[0]}
|
|
||||||
y2={pos[1]}
|
|
||||||
stroke={active ? ZONE_BORDER[sisterName] : 'rgba(255,255,255,0.05)'}
|
|
||||||
strokeWidth={active ? 0.8 : 0.5}
|
|
||||||
strokeDasharray="2 3"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
</svg>
|
|
||||||
</SceneWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user