polish(my-deepagent): rebuild Web GUI visual design — cards, pill badges, 8px grid
The first cut of static/*.html + style.css was functional but visually
bare. Rewriting with a modern dev-tool dashboard aesthetic (Linear /
Vercel / Resend palette), still vanilla CSS — no framework, no build
system (DR-3 / plan.md D3 constraint kept).
Changes
- `static/style.css`: full rewrite (192 → ~580 lines). Adds:
- CSS custom-property design tokens: surface 0/1/2/3, accent/success/
warning/danger/info each with a matching `*-bg` rgba.
- Type system: Inter / Pretendard / Apple SD Gothic Neo / Noto Sans KR
stack with tabular-nums + system features cv05/ss01.
- 8 px spacing grid, refined border-radius scale (sm/md/lg).
- `.card` surface with subtle inner highlight + low shadow.
- `.badge` pill component with state-* modifiers and an animated dot
for in-progress states (running / executing / validating /
awaiting_artifact).
- `.meta-panel` + `.meta-row` for key/value run detail.
- `.budget-card` with embedded usage bar (ok/warn/over color states).
- `.events` log with monospace, hover background, per-event-type
accent color (run.completed green, run.failed red, etc.) and themed
scrollbar.
- `.chips` row for per-role persona override input.
- Buttons with `primary` / `danger` variants and subtle press animation.
- Compact responsive break at 720 px (single-column meta rows /
form-grid / chips).
- `static/index.html`: page-title row + `.card` wrapper for runs table +
`.budget-grid` for budget cards. Active nav highlight.
- `static/new.html`: form rebuilt inside a card with form-grid layout
(repo path / branch side-by-side), `.chips` rows for per-role override.
- `static/run.html`: page-title with state badge + `.meta-panel` for
Run ID / Repo / Worktree / Final report + action bar + cards for
phases and live events.
- `static/app.js`: redesigned rendering helpers to match new markup:
- New `badge(state)` helper returning a pill element.
- `emptyCell(colspan, text, ctaHref, ctaText)` for empty-state tables.
- Runs list: short hash + arrow link, basename for repo with full path
in `title`, ISO timestamps trimmed to `YYYY-MM-DD HH:MM:SS`.
- Budget cards: usage bar fill % computed from spent/cap, status class
(ok / warn / over) flows to both the amount color and the bar color.
- New event line uses two-column grid (`.ts` + `.body`), event-line
class derived from event type for per-type accent coloring.
- EventSource singleton to prevent stacking on re-renders.
XSS policy unchanged: textContent only, innerHTML/insertAdjacentHTML/
outerHTML still forbidden. The hardcoded comment at the top of `app.js`
is preserved (and the static test that asserts it).
Gates
- ruff check + mypy --strict: PASS (120 source files)
- pytest 16 API tests (read+write+sse+static): all PASS
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* my-deepagent Web GUI — vanilla JS for v0.2 PR #3.
|
||||
/* my-deepagent Web GUI — v0.2 PR #3 (polish pass).
|
||||
*
|
||||
* SECURITY (XSS policy):
|
||||
* All user-controlled strings MUST be inserted via element.textContent.
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
const API = window.location.origin + "/api";
|
||||
const TERMINAL_STATES = new Set(["completed", "failed", "aborted"]);
|
||||
|
||||
function $(sel) { return document.querySelector(sel); }
|
||||
function $$(sel) { return Array.from(document.querySelectorAll(sel)); }
|
||||
@@ -29,12 +30,47 @@ function setError(msg) {
|
||||
if (!el) return;
|
||||
if (msg) {
|
||||
el.textContent = msg;
|
||||
el.style.display = "block";
|
||||
el.style.display = "flex";
|
||||
} else {
|
||||
el.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function badge(state) {
|
||||
const span = document.createElement("span");
|
||||
span.className = `badge state-${state}`;
|
||||
span.textContent = state;
|
||||
return span;
|
||||
}
|
||||
|
||||
function emptyCell(colspan, text, ctaHref, ctaText) {
|
||||
const tr = document.createElement("tr");
|
||||
const td = document.createElement("td");
|
||||
td.colSpan = colspan;
|
||||
const empty = document.createElement("div");
|
||||
empty.className = "empty";
|
||||
const icon = document.createElement("div");
|
||||
icon.className = "empty-icon";
|
||||
icon.textContent = "◌";
|
||||
const body = document.createElement("div");
|
||||
body.textContent = text;
|
||||
empty.appendChild(icon);
|
||||
empty.appendChild(body);
|
||||
if (ctaHref && ctaText) {
|
||||
const cta = document.createElement("div");
|
||||
cta.className = "cta";
|
||||
const a = document.createElement("a");
|
||||
a.className = "button";
|
||||
a.href = ctaHref;
|
||||
a.textContent = ctaText;
|
||||
cta.appendChild(a);
|
||||
empty.appendChild(cta);
|
||||
}
|
||||
td.appendChild(empty);
|
||||
tr.appendChild(td);
|
||||
return tr;
|
||||
}
|
||||
|
||||
// =============== index.html ===============
|
||||
|
||||
async function renderRunsList() {
|
||||
@@ -49,38 +85,48 @@ async function renderRunsList() {
|
||||
const tbody = $("#runs tbody");
|
||||
tbody.replaceChildren();
|
||||
if (runs.length === 0) {
|
||||
const tr = document.createElement("tr");
|
||||
const td = document.createElement("td");
|
||||
td.colSpan = 6;
|
||||
td.className = "empty";
|
||||
td.textContent = "아직 실행된 run이 없습니다. 신규 run을 시작해 보세요.";
|
||||
tr.appendChild(td);
|
||||
tbody.appendChild(tr);
|
||||
tbody.appendChild(
|
||||
emptyCell(6, "아직 실행된 run이 없습니다.", "/new.html", "새 Run 시작 →")
|
||||
);
|
||||
return;
|
||||
}
|
||||
for (const r of runs) {
|
||||
const tr = document.createElement("tr");
|
||||
const cells = [
|
||||
["id", r.id.slice(0, 8) + "…", { href: `/run.html?id=${r.id}` }],
|
||||
["state", r.state, { state: r.state }],
|
||||
["repo", r.repo_path],
|
||||
["branch", r.base_branch],
|
||||
["created", (r.created_at || "").slice(0, 19)],
|
||||
["ended", (r.ended_at || "—").slice(0, 19)],
|
||||
];
|
||||
for (const [_, v, opts] of cells) {
|
||||
const td = document.createElement("td");
|
||||
if (opts && opts.state) td.className = `state-${opts.state}`;
|
||||
if (opts && opts.href) {
|
||||
const a = document.createElement("a");
|
||||
a.href = opts.href;
|
||||
a.textContent = v;
|
||||
td.appendChild(a);
|
||||
} else {
|
||||
td.textContent = v;
|
||||
}
|
||||
tr.appendChild(td);
|
||||
}
|
||||
|
||||
// Run ID cell — short hash + arrow
|
||||
const idTd = document.createElement("td");
|
||||
const idLink = document.createElement("a");
|
||||
idLink.href = `/run.html?id=${r.id}`;
|
||||
idLink.className = "mono";
|
||||
idLink.textContent = r.id.slice(0, 8) + "…";
|
||||
idTd.appendChild(idLink);
|
||||
|
||||
// State cell — pill badge
|
||||
const stateTd = document.createElement("td");
|
||||
stateTd.appendChild(badge(r.state));
|
||||
|
||||
// Repo cell — basename only, full path on title
|
||||
const repoTd = document.createElement("td");
|
||||
const repoSpan = document.createElement("span");
|
||||
repoSpan.className = "mono";
|
||||
repoSpan.textContent = (r.repo_path || "").split("/").pop() || r.repo_path;
|
||||
repoSpan.title = r.repo_path;
|
||||
repoTd.appendChild(repoSpan);
|
||||
|
||||
// Branch
|
||||
const branchTd = document.createElement("td");
|
||||
branchTd.textContent = r.base_branch;
|
||||
|
||||
// Timestamps
|
||||
const createdTd = document.createElement("td");
|
||||
createdTd.className = "mono";
|
||||
createdTd.textContent = (r.created_at || "").slice(0, 19).replace("T", " ");
|
||||
|
||||
const endedTd = document.createElement("td");
|
||||
endedTd.className = "mono";
|
||||
endedTd.textContent = r.ended_at ? r.ended_at.slice(0, 19).replace("T", " ") : "—";
|
||||
|
||||
tr.append(idTd, stateTd, repoTd, branchTd, createdTd, endedTd);
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
}
|
||||
@@ -91,35 +137,52 @@ async function renderBudgetSummary() {
|
||||
container.replaceChildren();
|
||||
try {
|
||||
const summary = await jsonFetch("/budget");
|
||||
function line(scope, spent, cap, warn) {
|
||||
const div = document.createElement("div");
|
||||
div.className = "budget-line";
|
||||
const left = document.createElement("span");
|
||||
left.className = "scope";
|
||||
left.textContent = scope;
|
||||
const right = document.createElement("span");
|
||||
right.className = "amount";
|
||||
const capStr = cap != null ? ` / $${cap.toFixed(2)}` : "";
|
||||
right.textContent = `$${spent.toFixed(4)}${capStr}`;
|
||||
if (cap != null && spent >= cap) right.classList.add("over");
|
||||
else if (warn != null && spent >= warn) right.classList.add("warn");
|
||||
div.appendChild(left);
|
||||
div.appendChild(right);
|
||||
container.appendChild(div);
|
||||
function card(scope, spent, cap, warn) {
|
||||
const c = document.createElement("div");
|
||||
c.className = "budget-card";
|
||||
const s = document.createElement("div");
|
||||
s.className = "scope";
|
||||
s.textContent = scope;
|
||||
s.title = scope;
|
||||
const a = document.createElement("div");
|
||||
a.className = "amount";
|
||||
const capText = cap != null ? ` / $${cap.toFixed(2)}` : "";
|
||||
a.textContent = `$${spent.toFixed(4)}`;
|
||||
const capSpan = document.createElement("span");
|
||||
capSpan.className = "cap";
|
||||
capSpan.textContent = capText;
|
||||
a.appendChild(capSpan);
|
||||
// Status colour
|
||||
let pct = 0;
|
||||
let status = "ok";
|
||||
if (cap != null && cap > 0) {
|
||||
pct = Math.min(100, (spent / cap) * 100);
|
||||
if (spent >= cap) { status = "over"; a.classList.add("over"); }
|
||||
else if (warn != null && spent >= warn) { status = "warn"; a.classList.add("warn"); }
|
||||
}
|
||||
const bar = document.createElement("div");
|
||||
bar.className = `bar ${status === "ok" ? "" : status}`;
|
||||
const fill = document.createElement("div");
|
||||
fill.style.width = `${pct}%`;
|
||||
bar.appendChild(fill);
|
||||
c.append(s, a, bar);
|
||||
container.appendChild(c);
|
||||
}
|
||||
if (summary.day) line(summary.day.scope, summary.day.spent_usd, summary.day.cap_usd, summary.day.warn_usd);
|
||||
for (const r of summary.runs) line(r.scope, r.spent_usd, r.cap_usd, r.warn_usd);
|
||||
for (const p of summary.personas) line(p.scope, p.spent_usd, p.cap_usd, p.warn_usd);
|
||||
if (summary.day) card(summary.day.scope, summary.day.spent_usd, summary.day.cap_usd, summary.day.warn_usd);
|
||||
for (const r of summary.runs) card(r.scope, r.spent_usd, r.cap_usd, r.warn_usd);
|
||||
for (const p of summary.personas) card(p.scope, p.spent_usd, p.cap_usd, p.warn_usd);
|
||||
if (!summary.day && summary.runs.length === 0 && summary.personas.length === 0) {
|
||||
const empty = document.createElement("div");
|
||||
empty.className = "empty";
|
||||
empty.textContent = "지출 기록이 없습니다.";
|
||||
empty.style.gridColumn = "1 / -1";
|
||||
container.appendChild(empty);
|
||||
}
|
||||
} catch (e) {
|
||||
const err = document.createElement("div");
|
||||
err.className = "empty";
|
||||
err.textContent = `budget 정보를 불러오지 못했습니다: ${e.message}`;
|
||||
err.style.gridColumn = "1 / -1";
|
||||
container.appendChild(err);
|
||||
}
|
||||
}
|
||||
@@ -131,14 +194,10 @@ async function renderNewRunForm() {
|
||||
const tplSelect = $("#template");
|
||||
const overrideContainer = $("#override-fields");
|
||||
let workflows = [];
|
||||
let personas = [];
|
||||
try {
|
||||
[workflows, personas] = await Promise.all([
|
||||
jsonFetch("/workflows"),
|
||||
jsonFetch("/personas"),
|
||||
]);
|
||||
workflows = await jsonFetch("/workflows");
|
||||
} catch (e) {
|
||||
setError(`workflow / persona 목록을 불러오지 못했습니다: ${e.message}`);
|
||||
setError(`workflow 목록을 불러오지 못했습니다: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
for (const w of workflows) {
|
||||
@@ -151,15 +210,33 @@ async function renderNewRunForm() {
|
||||
tplSelect.addEventListener("change", () => {
|
||||
overrideContainer.replaceChildren();
|
||||
const roles = JSON.parse(tplSelect.selectedOptions[0].dataset.roles || "[]");
|
||||
if (roles.length === 0) {
|
||||
const empty = document.createElement("div");
|
||||
empty.className = "empty";
|
||||
empty.style.padding = "20px 16px";
|
||||
empty.textContent = "이 워크플로우엔 역할 정의가 없습니다.";
|
||||
overrideContainer.appendChild(empty);
|
||||
return;
|
||||
}
|
||||
for (const role of roles) {
|
||||
const label = document.createElement("label");
|
||||
label.textContent = `${role} (선택 사항: persona 이름)`;
|
||||
const row = document.createElement("div");
|
||||
row.className = "chips";
|
||||
const label = document.createElement("div");
|
||||
label.className = "role";
|
||||
const roleName = document.createElement("span");
|
||||
roleName.textContent = role;
|
||||
label.appendChild(roleName);
|
||||
const hint = document.createElement("span");
|
||||
hint.className = "hint";
|
||||
hint.textContent = "비우면 자동 선택";
|
||||
label.appendChild(hint);
|
||||
const input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.dataset.role = role;
|
||||
input.className = "override-input";
|
||||
input.placeholder = "openrouter-deepseek-spec-writer@1";
|
||||
overrideContainer.appendChild(label);
|
||||
overrideContainer.appendChild(input);
|
||||
row.append(label, input);
|
||||
overrideContainer.appendChild(row);
|
||||
}
|
||||
});
|
||||
if (tplSelect.options.length > 0) {
|
||||
@@ -211,33 +288,50 @@ async function renderRunDetail() {
|
||||
$("#run-id").textContent = runId;
|
||||
try {
|
||||
const detail = await jsonFetch(`/runs/${runId}`);
|
||||
$("#run-state").textContent = detail.run.state;
|
||||
$("#run-state").className = `state-${detail.run.state}`;
|
||||
|
||||
const stateBadgeHost = $("#run-state-badge");
|
||||
stateBadgeHost.replaceChildren(badge(detail.run.state));
|
||||
|
||||
$("#run-repo").textContent = `${detail.run.repo_path} @ ${detail.run.base_branch}`;
|
||||
$("#run-worktree").textContent = detail.run.worktree_root;
|
||||
$("#run-report").textContent = detail.run.final_report_path || "—";
|
||||
|
||||
const phaseTbody = $("#phases tbody");
|
||||
phaseTbody.replaceChildren();
|
||||
for (const p of detail.phases) {
|
||||
const tr = document.createElement("tr");
|
||||
const cells = [
|
||||
p.phase_key,
|
||||
p.state,
|
||||
String(p.attempts),
|
||||
(p.started_at || "—").slice(0, 19),
|
||||
(p.ended_at || "—").slice(0, 19),
|
||||
];
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
const td = document.createElement("td");
|
||||
td.textContent = cells[i];
|
||||
if (i === 1) td.className = `state-${p.state}`;
|
||||
tr.appendChild(td);
|
||||
if (detail.phases.length === 0) {
|
||||
phaseTbody.appendChild(emptyCell(5, "phase 기록이 없습니다.", null, null));
|
||||
} else {
|
||||
for (const p of detail.phases) {
|
||||
const tr = document.createElement("tr");
|
||||
|
||||
const keyTd = document.createElement("td");
|
||||
keyTd.className = "mono";
|
||||
keyTd.textContent = p.phase_key;
|
||||
|
||||
const stateTd = document.createElement("td");
|
||||
stateTd.appendChild(badge(p.state));
|
||||
|
||||
const attTd = document.createElement("td");
|
||||
attTd.textContent = String(p.attempts);
|
||||
|
||||
const stTd = document.createElement("td");
|
||||
stTd.className = "mono";
|
||||
stTd.textContent = p.started_at
|
||||
? p.started_at.slice(0, 19).replace("T", " ")
|
||||
: "—";
|
||||
|
||||
const endTd = document.createElement("td");
|
||||
endTd.className = "mono";
|
||||
endTd.textContent = p.ended_at
|
||||
? p.ended_at.slice(0, 19).replace("T", " ")
|
||||
: "—";
|
||||
|
||||
tr.append(keyTd, stateTd, attTd, stTd, endTd);
|
||||
phaseTbody.appendChild(tr);
|
||||
}
|
||||
phaseTbody.appendChild(tr);
|
||||
}
|
||||
|
||||
const isTerminal = ["completed", "failed", "aborted"].includes(detail.run.state);
|
||||
const isTerminal = TERMINAL_STATES.has(detail.run.state);
|
||||
$("#resume-btn").disabled = isTerminal;
|
||||
$("#abort-btn").disabled = isTerminal;
|
||||
} catch (e) {
|
||||
@@ -248,39 +342,55 @@ async function renderRunDetail() {
|
||||
startEventStream(runId);
|
||||
}
|
||||
|
||||
function appendEventLine(eventsContainer, data) {
|
||||
const line = document.createElement("div");
|
||||
const cls = (data.type || "").replace(/\./g, "-");
|
||||
line.className = `event-line ${cls}`;
|
||||
const ts = document.createElement("div");
|
||||
ts.className = "ts";
|
||||
ts.textContent = (data.ts || "").slice(11, 19);
|
||||
const body = document.createElement("div");
|
||||
body.className = "body";
|
||||
const type = document.createElement("span");
|
||||
type.className = "type";
|
||||
type.textContent = data.type;
|
||||
body.appendChild(type);
|
||||
if (data.payload && Object.keys(data.payload).length > 0) {
|
||||
const payload = document.createElement("span");
|
||||
payload.className = "payload";
|
||||
payload.textContent = JSON.stringify(data.payload);
|
||||
body.appendChild(payload);
|
||||
}
|
||||
line.appendChild(ts);
|
||||
line.appendChild(body);
|
||||
eventsContainer.appendChild(line);
|
||||
eventsContainer.scrollTop = eventsContainer.scrollHeight;
|
||||
}
|
||||
|
||||
let _eventSource = null;
|
||||
|
||||
function startEventStream(runId) {
|
||||
if (_eventSource) {
|
||||
_eventSource.close();
|
||||
}
|
||||
const eventsContainer = $("#events");
|
||||
eventsContainer.replaceChildren();
|
||||
const src = new EventSource(`${API}/runs/${runId}/events`);
|
||||
_eventSource = src;
|
||||
src.addEventListener("event", (ev) => {
|
||||
try {
|
||||
const data = JSON.parse(ev.data);
|
||||
const line = document.createElement("div");
|
||||
line.className = "event-line";
|
||||
const ts = document.createElement("span");
|
||||
ts.className = "ts";
|
||||
ts.textContent = (data.ts || "").slice(0, 19);
|
||||
const type = document.createElement("span");
|
||||
type.className = "type";
|
||||
type.textContent = ` ${data.type}`;
|
||||
line.appendChild(ts);
|
||||
line.appendChild(type);
|
||||
if (data.payload && Object.keys(data.payload).length > 0) {
|
||||
const payload = document.createElement("span");
|
||||
payload.textContent = " " + JSON.stringify(data.payload);
|
||||
line.appendChild(payload);
|
||||
}
|
||||
eventsContainer.appendChild(line);
|
||||
eventsContainer.scrollTop = eventsContainer.scrollHeight;
|
||||
} catch (_) { /* ignore */ }
|
||||
appendEventLine(eventsContainer, data);
|
||||
} catch (_) { /* ignore parse errors */ }
|
||||
});
|
||||
src.addEventListener("done", () => {
|
||||
src.close();
|
||||
// Refresh the detail panel one last time to pick up final state.
|
||||
if (_eventSource === src) _eventSource = null;
|
||||
setTimeout(() => renderRunDetail(), 300);
|
||||
});
|
||||
src.onerror = () => {
|
||||
src.close();
|
||||
if (_eventSource === src) _eventSource = null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user