openhop

srcSource code

Source code

Every file of openhop's latest version, exactly as published. Read anything, or download it all as a zip.

Commit
c8cfb4c
Date
16 Nov 2026
Files
62 files
Download the source (zip)

zip · 758 KB · SHA-256 6ce65b028777bf92…

notify.html

405 lines · 79 KB · HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>openhop notice</title>
<!--
openhop notification popup.
Meant for a small frameless, transparent, topmost, non-activating window in the bottom-right
corner (suggested window size 400 x 136 CSS px: a 360 x 96 card plus room for its shadow).
Use it either way:
- query string: notify.html?kind=problem&title=...&body=...&action=Fix&id=abc&timeout=0
- JavaScript: showNotice({ kind: "hop", title: "...", body: "...", action_label: "Open", id: "abc", timeout: 8000 })
kind: problem | hop | update | info (missing title/body fall back to a sensible default per kind)
timeout: ms before it fades out by itself; 0 = stays until closed. Default: problems stay, others 8 s.
Optional backend hooks (only called if they exist; the page works without any pywebview API):
window.pywebview.api.notice_action(id) -> the action button was clicked (popup then closes)
window.pywebview.api.notice_close(id) -> the popup finished closing (× / timeout / after action)
-->
<style>
/* Inter (latin subset, SIL Open Font License) embedded so it works offline */
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: local("Inter"), local("Inter Variable"), url(data:font/woff2;base64,d09GMgABAAAAALyAABUAAAAB4CAAALwFAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGoZeG4KyRBzVcD9IVkFSi2k/TVZBUl4GYD9TVEFUgU4nJgCFNi9sEQgKgbtAgaEUC4gOADCCnD4BNgIkA5AYBCAFhi4HoQQMB1tzzZFCvBvP7u3DbGpQpdsQgMqps1L7r3ADN3ekcLpSd3VjDvdRxlSwXT24HeDivrPV7P/////PTiZjjG6zbhuAgIaVWf//oFG6m0fKpZa1GtEM3hHeiRiGTOHDNEtW1uphm9xD8Yfsc845xSOllI6MZ0bgBa6OXQbsGPkQKYlQqD3X9YVVvH2KntB6YJwvZMXkp+C5yra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
:root {
--surface: #1d1f23;
--surface-2: #26292e;
--line: rgba(236, 233, 222, 0.14);
--text: #ecebe4;
--muted: #a8a59b;
--dim: #7a776f;
--amber: #f2b318;
--amber-hi: #ffc535;
--ink: #1f2125;
--paper: #efede6;
--ok: #3fb97a;
--bad: #e5534b;
--info: #6fa8d6;
--tone: var(--amber);
--ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
--ease-in: cubic-bezier(0.5, 0, 0.75, 0);
--ease-land: cubic-bezier(0.25, 0.8, 0.3, 1);
--ease-firm: cubic-bezier(0.34, 1.45, 0.64, 1);
--t-fast: 120ms;
--sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
--display: "Bahnschrift", "DIN Alternate", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: transparent; height: 100%; overflow: hidden; }
body {
font-family: var(--sans);
color: var(--text);
user-select: none;
-webkit-font-smoothing: antialiased;
display: flex;
align-items: center;
justify-content: center;
}
.notice {
--c: 12px;
position: relative;
width: 360px;
height: 96px;
display: grid;
grid-template-columns: 4px 44px minmax(0, 1fr) auto;
align-items: center;
column-gap: 12px;
padding-right: 12px;
background:
radial-gradient(240px 90px at 0% 0%, color-mix(in srgb, var(--tone) 13%, transparent), transparent 70%),
linear-gradient(180deg, #25272c 0%, #1c1e22 100%);
clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
opacity: 0;
transform: translateX(72px);
transition: opacity 260ms var(--ease-out), transform 560ms var(--ease-land);
}
/* hairline frame that follows the chamfer */
.frame {
position: absolute;
inset: 0;
pointer-events: none;
}
.notice.in { opacity: 1; transform: none; }
.notice.out { opacity: 0; transform: translateX(48px); transition: opacity 200ms var(--ease-in), transform 220ms var(--ease-in); }
/* after the card arrives: logo is stamped, the status badge pops, the text follows */
.notice.in .mark { animation: markIn 640ms var(--ease-firm) 120ms both; }
.notice.in .badge { animation: badgePop 420ms var(--ease-firm) 420ms both; }
.notice.in .content > * { animation: textIn 480ms var(--ease-land) both; }
.notice.in .content > :nth-child(1) { animation-delay: 160ms; }
.notice.in .content > :nth-child(2) { animation-delay: 220ms; }
.notice.in .content > :nth-child(3) { animation-delay: 280ms; }
.notice.in .act { animation: textIn 480ms var(--ease-land) 340ms both; }
@keyframes markIn {
0% { opacity: 0; transform: scale(0.4) rotate(-20deg); }
60% { opacity: 1; transform: scale(1.1) rotate(3deg); }
100% { opacity: 1; transform: none; }
}
@keyframes badgePop { from { transform: scale(0); } to { transform: none; } }
@keyframes textIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.notice[data-kind="problem"] { --tone: var(--bad); }
.notice[data-kind="hop"] { --tone: var(--amber); }
.notice[data-kind="update"] { --tone: var(--info); }
.notice[data-kind="info"] { --tone: var(--paper); }
.band { align-self: stretch; background: var(--tone); }
.notice[data-kind="problem"] .band { background: repeating-linear-gradient(-45deg, var(--bad) 0 6px, #3a1d1c 6px 12px); }
.mark { width: 44px; height: 44px; position: relative; }
.mark svg { width: 44px; height: 44px; display: block; }
.badge {
position: absolute;
right: -5px;
bottom: -5px;
width: 19px;
height: 19px;
display: grid;
place-items: center;
background: var(--tone);
color: var(--ink);
border: 2px solid var(--surface);
border-radius: 2px;
}
.notice[data-kind="problem"] .badge { color: #fff; }
.notice[data-kind="hop"] .badge { background: var(--paper); }
.badge::before {
content: "";
width: 11px;
height: 11px;
background: currentColor;
-webkit-mask: var(--bicon) center / contain no-repeat;
mask: var(--bicon) center / contain no-repeat;
}
.notice[data-kind="problem"] { --bicon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='square'><path d='M12 4v10M12 19v1'/></svg>"); }
.notice[data-kind="hop"] { --bicon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'><path d='M3 20c1-8 6-12 10-12s6.5 3 7.5 7'/><path d='M21.5 9.5 20.5 15l-5.3-1.6'/></svg>"); }
.notice[data-kind="update"] { --bicon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='square' stroke-linejoin='miter'><path d='M12 20V5M5 12l7-7 7 7'/></svg>"); }
.notice[data-kind="info"] { --bicon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='square'><path d='M12 10v10M12 4v1'/></svg>"); }
.content { min-width: 0; padding-right: 10px; }
.kicker {
display: flex;
align-items: center;
gap: 6px;
font-family: var(--display);
font-size: 11px;
font-weight: 600;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--dim);
white-space: nowrap;
}
.kicker .kind { color: var(--tone); }
.notice[data-kind="info"] .kicker .kind { color: var(--muted); }
.title {
margin-top: 2px;
font-family: var(--display);
font-size: 16px;
font-weight: 600;
line-height: 1.2;
color: var(--paper);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.body {
margin-top: 2px;
font-size: 12.5px;
color: var(--muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.act {
--c: 6px;
align-self: end;
margin-bottom: 14px;
height: 30px;
padding: 0 14px;
border: 0;
background: linear-gradient(180deg, #f9c537 0%, #f2b318 52%, #e4a60f 100%);
color: var(--ink);
font-family: var(--sans);
font-size: 12.5px;
font-weight: 600;
cursor: pointer;
white-space: nowrap;
clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
transition: box-shadow var(--t-fast) var(--ease-out), transform 70ms var(--ease-out);
}
.act:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 99px rgba(255, 255, 255, 0.14); }
.act:active { transform: translateY(1px); box-shadow: inset 0 0 0 99px rgba(0, 0, 0, 0.1); }
.act:focus-visible { outline: 2px solid var(--paper); outline-offset: -4px; }
.act[hidden] { display: none; }
.close {
position: absolute;
top: 6px;
right: 6px;
width: 24px;
height: 24px;
border: 0;
border-radius: 2px;
background: transparent;
color: var(--dim);
cursor: pointer;
display: grid;
place-items: center;
transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.close::before {
content: "";
width: 10px;
height: 10px;
background: currentColor;
-webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' stroke='black' stroke-width='1.4'><path d='M1 1l8 8M9 1L1 9'/></svg>") center / contain no-repeat;
mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' stroke='black' stroke-width='1.4'><path d='M1 1l8 8M9 1L1 9'/></svg>") center / contain no-repeat;
}
.close:hover { background-color: var(--surface-2); color: var(--text); }
.close:focus-visible { outline: 2px solid var(--amber); outline-offset: 0; }
/* auto-dismiss countdown */
.timer {
position: absolute;
left: 4px;
right: 0;
bottom: 0;
height: 2px;
background: var(--tone);
opacity: 0.55;
transform-origin: left center;
transform: scaleX(0);
}
.timer.run { animation: countdown var(--dur, 8000ms) linear forwards; }
.notice:hover .timer.run { animation-play-state: paused; }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
.notice, .notice.out { transition: opacity 120ms linear; transform: none; }
.timer.run { animation: none; transform: scaleX(0); }
.notice.in .mark, .notice.in .badge, .notice.in .content > *, .notice.in .act { animation: none; }
}
/* Opaque window version: pywebview can't make a Windows window truly transparent (the form's light-grey
background showed around the chamfered corners), so the card fills the window and Windows 11 rounds
the corners natively. */
html, body { background: #1f2125; }
.notice { width: 100vw; height: 100vh; clip-path: none; filter: none; transform: none;
box-shadow: inset 0 0 0 1px rgba(236, 233, 222, 0.10); }
.notice.out { transform: none; }
.notice { cursor: pointer; }
.frame { display: none; }
</style>
</head>
<body>
<div id="notice" class="notice" data-kind="info" role="status" aria-live="polite">
<svg class="frame" viewBox="0 0 360 96" preserveAspectRatio="none" aria-hidden="true">
<path d="M12 0.5 H359.5 V84 L348 95.5 H0.5 V12 Z" fill="none" stroke="rgba(236,233,222,0.14)" stroke-width="1" vector-effect="non-scaling-stroke"/>
</svg>
<div class="band"></div>
<div class="mark">
<svg viewBox="0 0 100 100" aria-label="openhop">
<path d="M8 1 L92 1 L99 8 L99 92 L92 99 L8 99 L1 92 L1 8 Z" fill="#f2b318"/>
<rect x="22" y="17" width="15" height="66" fill="#1f2125"/>
<path d="M41 41.5 H51 Q68.5 41.5 68.5 59 V83" fill="none" stroke="#1f2125" stroke-width="15"/>
</svg>
<span class="badge"></span>
</div>
<div class="content">
<div class="kicker"><span class="kind" id="nKind"></span><span>·</span><span>openhop</span></div>
<div class="title" id="nTitle"></div>
<div class="body" id="nBody"></div>
</div>
<button class="act" id="nAction" hidden></button>
<button class="close" id="nClose"></button>
<div class="timer" id="nTimer"></div>
</div>
<script>
const STRINGS = {
en: {
"kind.problem": "Problem",
"kind.hop": "New IP",
"kind.update": "Update",
"kind.info": "Info",
"close": "Close",
"problem.title": "OpenCode can't connect",
"problem.body": "Background service stopped.",
"problem.action": "Fix",
"hop.title": "Limit hit → new IP",
"hop.body": "Fresh IP · sent 'continue' to your chat",
"update.title": "New version available",
"update.body": "A newer openhop is ready.",
"update.action": "Open",
"info.title": "openhop",
"info.body": ""
}
};
let LANG = "en";
const t = (k) => (STRINGS[LANG] && k in STRINGS[LANG] ? STRINGS[LANG][k] : (STRINGS.en[k] !== undefined ? STRINGS.en[k] : k));
const KINDS = ["problem", "hop", "update", "info"];
const $ = (id) => document.getElementById(id);
const hook = (name, ...args) => {
try {
const fn = window.pywebview && window.pywebview.api && window.pywebview.api[name];
if (typeof fn === "function") return fn(...args);
} catch (e) { /* hooks are optional */ }
return undefined;
};
let current = { id: "" };
let closeTimer = null;
let closing = false;
function showNotice(opts = {}) {
const kind = KINDS.includes(opts.kind) ? opts.kind : "info";
const card = $("notice");
clearTimeout(closeTimer);
closing = false;
current = { id: opts.id != null ? String(opts.id) : kind };
card.dataset.kind = kind;
$("nKind").textContent = t("kind." + kind);
$("nTitle").textContent = opts.title || t(kind + ".title");
$("nBody").textContent = opts.body != null ? opts.body : t(kind + ".body");
$("nTitle").title = $("nTitle").textContent;
$("nBody").title = $("nBody").textContent;
$("nClose").title = t("close");
$("nClose").setAttribute("aria-label", t("close"));
const actionLabel = opts.action_label !== undefined ? opts.action_label : (STRINGS.en[kind + ".action"] ? t(kind + ".action") : "");
const act = $("nAction");
act.textContent = actionLabel || "";
act.hidden = !actionLabel;
const timeout = opts.timeout != null ? Number(opts.timeout) : (kind === "problem" ? 0 : 8000);
const timer = $("nTimer");
timer.classList.remove("run");
void timer.offsetWidth; // restart the countdown animation
if (timeout > 0) {
timer.style.setProperty("--dur", timeout + "ms");
timer.classList.add("run");
}
card.classList.remove("out");
requestAnimationFrame(() => requestAnimationFrame(() => card.classList.add("in")));
}
function closeNotice() {
if (closing) return;
closing = true;
const card = $("notice");
card.classList.remove("in");
card.classList.add("out");
setTimeout(() => hook("notice_close", current.id), 240);
}
$("nClose").onclick = closeNotice;
// Clicking the card itself (not a button) opens openhop at the right place.
$("notice").addEventListener("click", (e) => {
if (closing || e.target.closest("button")) return;
hook("notice_body", current.id);
closeNotice();
});
$("nAction").onclick = () => { hook("notice_action", current.id); closeNotice(); };
$("nTimer").addEventListener("animationend", closeNotice);
document.addEventListener("keydown", (e) => { if (e.key === "Escape") closeNotice(); });
// Query string: ?kind=hop&title=...&body=...&action=Open&id=...&timeout=8000
(function fromQuery() {
const q = new URLSearchParams(location.search);
if (!q.has("kind") && !q.has("title")) return;
showNotice({
kind: q.get("kind") || "info",
title: q.get("title") || undefined,
body: q.has("body") ? q.get("body") : undefined,
action_label: q.has("action") ? q.get("action") : undefined,
id: q.get("id") || undefined,
timeout: q.has("timeout") ? Number(q.get("timeout")) : undefined,
});
})();
// Used by tools/preview_ui.py --page notify (shows the countdown frozen half-way)
window.__previewNotice = (kind) => {
showNotice({ kind });
const timer = $("nTimer");
if (timer.classList.contains("run")) { timer.style.animationDelay = "-3000ms"; timer.style.animationPlayState = "paused"; }
};
window.showNotice = showNotice;
window.closeNotice = closeNotice;
</script>
</body>
</html>