<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Canic fleet console</title>
<style>
:root {
--bg: #f7f7f8; --panel: #ffffff; --line: #e4e4e7; --line-strong: #d4d4d8;
--text: #18181b; --muted: #71717a; --faint: #a1a1aa;
--accent: #3b5bdb; --accent-soft: #edf2ff;
--query: #2b8a3e; --query-soft: #ebfbee; --update: #c2410c; --update-soft: #fff4e6;
--ok: #2b8a3e; --err: #c92a2a; --err-soft: #fff5f5;
--sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
--mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
--radius: 8px;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #111113; --panel: #18181b; --line: #27272a; --line-strong: #3f3f46;
--text: #f4f4f5; --muted: #a1a1aa; --faint: #71717a;
--accent: #748ffc; --accent-soft: #1c2142;
--query: #69db7c; --query-soft: #132a19; --update: #ffa94d; --update-soft: #2e1e0d;
--ok: #69db7c; --err: #ff8787; --err-soft: #2c1515;
color-scheme: dark;
}
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 var(--sans); color: var(--text); background: var(--bg); }
code, pre, input, select, textarea { font-family: var(--mono); }
a { color: var(--accent); }
#app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
header h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
header .links { display: flex; gap: 12px; font-size: 12px; }
#fleet { font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
#status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
#status.up .dot { background: var(--ok); }
#status.down .dot { background: var(--err); }
#target { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
#id { width: 250px; font-size: 12px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); color: var(--text); }
#id.edited { border-color: var(--update); }
#load { position: relative; font-size: 12px; }
#load summary { cursor: pointer; color: var(--muted); }
#load .panel { position: fixed; right: 16px; top: 52px; z-index: 2; width: min(320px, calc(100vw - 32px)); padding: 10px 12px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 4px 12px rgb(0 0 0 / 0.12); }
#load label { display: block; margin: 6px 0; }
#load input { width: 100%; font-size: 11px; }
#container { display: grid; grid-template-columns: 240px 1fr 360px; min-height: 0; }
#sidebar { border-right: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 12px 8px; }
.section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 8px 6px; }
#actors button { display: flex; width: 100%; justify-content: space-between; border: none; background: none; color: var(--text);
font: 13px var(--mono); padding: 6px 8px; border-radius: 6px; cursor: pointer; text-align: left; }
#actors button:hover { background: var(--bg); }
#actors button.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
#actors .count { color: var(--faint); }
#search { width: calc(100% - 16px); margin: 12px 8px 4px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px;
background: var(--panel); color: var(--text); font-size: 13px; }
#mode { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 8px 10px; }
#mode button { border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted); border-radius: 999px;
padding: 2px 8px; font: 11px var(--sans); cursor: pointer; }
#mode button.active { background: var(--text); border-color: var(--text); color: var(--panel); }
#mode .n { opacity: 0.7; }
#method-links a { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 6px; color: var(--text);
text-decoration: none; font: 12px var(--mono); overflow-wrap: anywhere; }
#method-links a:hover { background: var(--bg); }
#method-links a.unknown { color: var(--faint); }
.mode-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.mode-dot.query, .mode-dot.composite_query { background: var(--query); }
.mode-dot.update { background: var(--update); }
main { overflow: auto; padding: 16px 24px 48px; }
#notice { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
#notice.error { color: var(--err); }
#methods { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#canister-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; }
#canister-title { margin: 0; font: 600 15px var(--mono); }
#canister-bar button, .types-actions button { border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
border-radius: 6px; padding: 4px 10px; font: 12px var(--sans); cursor: pointer; }
#canister-bar button.active { background: var(--text); border-color: var(--text); color: var(--panel); }
#types-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; }
.types-actions { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line);
color: var(--muted); font-size: 12px; }
.types-actions span { flex: 1; }
.ts-code { margin: 0; padding: 12px; max-height: 60vh; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre; tab-size: 2; }
.ts { margin-top: 12px; }
.ts summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.ts .ts-code { margin-top: 6px; background: var(--bg); border-radius: 6px; max-height: 40vh; }
.ts button { margin-top: 6px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); border-radius: 6px; padding: 3px 10px; font: 12px var(--sans); cursor: pointer; }
.method { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.method[open] { border-color: var(--line-strong); box-shadow: 0 1px 3px rgb(0 0 0 / 0.06); }
.method summary { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
.method summary::-webkit-details-marker { display: none; }
.method summary::before { content: '›'; color: var(--faint); transition: transform 0.15s; display: inline-block; }
.method[open] summary::before { transform: rotate(90deg); }
.name { font: 500 13px var(--mono); }
.sig { font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; flex: 1; }
.badge { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; color: var(--muted); background: var(--bg); }
.badge.query, .badge.composite_query { color: var(--query); background: var(--query-soft); }
.badge.update { color: var(--update); background: var(--update-soft); }
.body { padding: 4px 14px 14px 32px; border-top: 1px solid var(--line); }
.body > p { color: var(--muted); }
.record { border-left: 2px solid var(--line); padding-left: 12px; }
.field { margin: 12px 0; }
.field-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; font-size: 13px; }
.field-label strong { font: 500 13px var(--mono); }
.field-label small { color: var(--muted); font-size: 12px; }
.tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.tag.required { background: var(--err-soft); color: var(--err); }
.tag.optional { background: var(--bg); color: var(--muted); }
.body input:not([type=checkbox]), .body select, .body textarea {
width: min(420px, 100%); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px;
background: var(--panel); color: var(--text); font-size: 13px; }
.body textarea { width: 100%; }
.body input:focus, .body select:focus, .body textarea:focus, #search:focus, #id:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { font-size: 13px; color: var(--muted); }
.body em { color: var(--muted); }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.btn { border: none; border-radius: 6px; padding: 7px 16px; font: 500 13px var(--sans); cursor: pointer; color: #fff; background: var(--query); }
.btn.update { background: var(--update); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.json-toggle { margin-left: auto; font-size: 12px; color: var(--muted); }
.result { display: none; margin-top: 14px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.result.shown { display: block; }
.result-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 12px; }
.chip { font-weight: 600; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.chip.ok { color: var(--ok); background: var(--query-soft); }
.chip.err { color: var(--err); background: var(--err-soft); }
.chip.wait { color: var(--muted); background: var(--panel); }
.elapsed { margin-left: auto; color: var(--faint); }
.result pre { margin: 0; padding: 10px; font-size: 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.result.error pre { color: var(--err); }
.j-key { color: var(--accent); } .j-str { color: var(--query); } .j-num { color: var(--update); } .j-lit { color: var(--muted); }
#history { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#history .head { display: flex; align-items: center; padding: 10px 14px 6px; }
#history .head .section-title { margin: 0; }
#clear-history { margin-left: auto; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
#clear-history:disabled { cursor: default; opacity: 0.5; }
#history-list { overflow: auto; flex: 1; margin: 0; padding: 0; list-style: none; font: 11.5px/1.5 var(--mono); }
#history-list li { border-bottom: 1px solid var(--line); }
#history-list summary { padding: 6px 14px; cursor: pointer; overflow-wrap: anywhere; }
#history-list li.error summary { color: var(--err); }
#history-list li.pending summary { color: var(--muted); }
#history-list .entry { padding: 0 14px 8px; }
#history-list strong { display: block; margin-top: 6px; font: 600 11px var(--sans); color: var(--muted); }
#history-list pre { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
#container { grid-template-columns: 220px 1fr; grid-template-rows: 1fr auto; }
#history { grid-column: 1 / -1; max-height: 35vh; border-left: none; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
header { padding: 10px 16px; }
#target { margin-left: 0; width: 100%; } #id { flex: 1; width: auto; }
#container { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
#sidebar { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
main { padding: 12px 16px 40px; }
.body { padding-left: 14px; }
}
</style>
</head>
<body>
<div id="app">
<header>
<h1>Fleet console</h1>
<div class="links"><a href="/">Fleet report</a><a id="application" hidden rel="noreferrer noopener">Open application</a></div>
<div id="status"><span class="dot"></span><span id="status-text">checking…</span></div>
<span id="fleet"></span>
<label id="target">Canister ID <input id="id" spellcheck="false" aria-label="Target canister principal"></label>
<details id="load"><summary>Load fleet or contracts</summary>
<div class="panel">
<label>Local fleet connection <input id="connection" type="file" accept=".json"></label>
<label>Wire contracts or endpoint manifests <input id="contracts" type="file" accept=".json" multiple></label>
</div>
</details>
</header>
<div id="container">
<nav id="sidebar">
<div class="section-title">Canisters</div>
<div id="actors"></div>
<input id="search" type="search" placeholder="Filter endpoints" aria-label="Filter endpoints">
<div id="mode" role="group" aria-label="Filter by call mode">
<button class="active" data-mode="">All <span class="n"></span></button>
<button data-mode="query">Queries <span class="n"></span></button>
<button data-mode="update">Updates <span class="n"></span></button>
</div>
<div id="method-links"></div>
</nav>
<main>
<p role="status" id="notice">Calls use the browser’s anonymous identity. Endpoints that need a signed caller refuse them; use the application for signed calls.</p>
<div id="canister-bar">
<h2 id="canister-title"></h2>
<button id="show-types" title="Readable declarations for every endpoint of this canister">TypeScript</button>
</div>
<section id="types-panel" hidden>
<div class="types-actions">
<span>Shapes match the client from <code>canic app export-wire</code>.</span>
<button id="copy-types">Copy</button>
<button id="download-types">Download</button>
</div>
<pre id="types-code" class="ts-code"></pre>
</section>
<p id="no-matches" hidden>No matching endpoints.</p>
<ul id="methods"></ul>
</main>
<aside id="history">
<div class="head"><div class="section-title">Call history (<span id="history-count">0</span>)</div><button id="clear-history" disabled>Clear</button></div>
<ol id="history-list"></ol>
</aside>
</div>
</div>
<script type="module" src="/console.js"></script>
</body>
</html>