Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(lan-webui): give every phone page native-grade motion and feedback

vastsae32fafac3363
diff --git a/apps/desktop/resources/lan-webui/app.js b/apps/desktop/resources/lan-webui/app.js
index c919c1352..10473a5a2 100644
--- a/apps/desktop/resources/lan-webui/app.js
+++ b/apps/desktop/resources/lan-webui/app.js
@@ -54,6 +54,7 @@
const range = keep && typeof active.selectionStart === "number" ? [active.selectionStart, active.selectionEnd] : null;
app.replaceChildren(...nodes.filter(Boolean));
app.dataset.view = view;
+ if (!same && view !== "loading") enterPage();
const next = keep ? document.getElementById(keep) : null;
if (next) {
next.focus({ preventScroll: true });
@@ -67,6 +68,21 @@
}
return !same;
}
+ /** A new page slides in from the side it was reached from; refreshes never move. */
+ let direction = "push";
+ function enterPage() {
+ app.classList.remove("enter-push", "enter-pop");
+ void app.offsetWidth;
+ app.classList.add(`enter-${direction}`);
+ }
+ app.addEventListener("animationend", (event) => {
+ if (event.animationName.startsWith("page-")) app.classList.remove("enter-push", "enter-pop");
+ });
+ // Safari only paints :active feedback once the page listens for touches.
+ document.addEventListener("touchstart", () => {}, { passive: true });
+ // The sticky header gains its hairline only once content scrolls beneath it.
+ const syncScrolled = () => document.documentElement.classList.toggle("scrolled", window.scrollY > 2);
+ window.addEventListener("scroll", syncScrolled, { passive: true });
let toastTimer = null;
function notify(message, duration = 4000) {
toast.textContent = message;
@@ -211,6 +227,7 @@
}
state.scroll.set(routeKey(new URL(event.oldURL).hash), window.scrollY);
const restoreScroll = !state.forward;
+ direction = state.forward ? "push" : "pop";
state.forward = false;
state.route = parseRoute();
render({ restoreScroll });
@@ -288,6 +305,28 @@
sheetReturn = null;
}
sheet.addEventListener("click", (event) => { if (event.target === sheet) closeSheet(); });
+ // Pull the sheet down from its top to dismiss it, like a native action sheet.
+ const sheetPanel = sheet.querySelector(".sheet-panel");
+ let drag = null;
+ sheetPanel.addEventListener("touchstart", (event) => {
+ drag = sheetPanel.scrollTop <= 0 && event.touches.length === 1 ? { y: event.touches[0].clientY, dy: 0 } : null;
+ }, { passive: true });
+ sheetPanel.addEventListener("touchmove", (event) => {
+ if (!drag) return;
+ drag.dy = Math.max(0, event.touches[0].clientY - drag.y);
+ sheetPanel.style.transition = "none";
+ sheetPanel.style.translate = `0 ${drag.dy}px`;
+ }, { passive: true });
+ const endDrag = () => {
+ if (!drag) return;
+ const dismiss = drag.dy > 72;
+ drag = null;
+ sheetPanel.style.transition = "";
+ sheetPanel.style.translate = "";
+ if (dismiss) closeSheet();
+ };
+ sheetPanel.addEventListener("touchend", endDrag);
+ sheetPanel.addEventListener("touchcancel", endDrag);
document.addEventListener("keydown", (event) => { if (event.key === "Escape" && !sheet.hidden) closeSheet(); });
function organize(kind, item, patch) {
@@ -827,6 +866,12 @@
if (!state.me) return;
const token = ++state.renderToken;
const route = state.route;
+ // A slow first load shows the page's shape instead of a blank screen.
+ const key = route.view === "home" ? `home${route.archived ? ":archived" : ""}`
+ : route.view === "sessions" ? `sessions:${route.projectId}${route.archived ? ":archived" : ""}` : `chat:${route.sessionId}`;
+ const skeletonTimer = options.refresh || app.dataset.view === key ? null : setTimeout(() => {
+ if (token === state.renderToken) show("loading", skeleton(route));
+ }, 160);
try {
let changed;
if (route.view === "home") changed = await renderHome(token, route.archived);
@@ -847,9 +892,25 @@
return;
}
fail(error);
+ } finally {
+ clearTimeout(skeletonTimer);
}
}
+ function skeleton(route) {
+ const bar = (cls) => el("span", { class: `skeleton ${cls}` });
+ const body = route.view === "chat"
+ ? el("div", { class: "messages skeleton-chat" }, [bar("bubble user"), bar("line wide"), bar("line"), bar("line short"), bar("bubble user narrow"), bar("line wide"), bar("line")])
+ : el("ul", { class: "list skeleton-list" }, Array.from({ length: 6 }, () => el("li", { class: "skeleton-row" }, [bar("title"), bar("meta")])));
+ return el("div", { class: "skeleton-page", "aria-busy": "true", "aria-label": t("loading") }, [
+ el("div", { class: "header" + (route.view === "home" ? " root" : "") }, [
+ route.view === "home" ? null : el("button", { type: "button", class: "icon-btn", "aria-label": t("back"), onclick: () => back("#/projects") }, icon("back")),
+ el("div", { class: "header-title" }, bar("heading")),
+ ]),
+ body,
+ ]);
+ }
+
// ---------- pairing ----------
function takePairingCode() {
if (!location.hash.startsWith("#pair=")) return "";
diff --git a/apps/desktop/resources/lan-webui/locale.js b/apps/desktop/resources/lan-webui/locale.js
index fbcd94c0b..dbc43a6b6 100644
--- a/apps/desktop/resources/lan-webui/locale.js
+++ b/apps/desktop/resources/lan-webui/locale.js
@@ -38,6 +38,7 @@ window.LAN_LOCALES = {
waiting: "Waiting",
readOnly: "Read-only here",
loadOlder: "Load older messages",
+ loading: "Loading…",
you: "You",
assistant: "Assistant",
tool: "Tool",
@@ -132,6 +133,7 @@ window.LAN_LOCALES = {
waiting: "等待中",
readOnly: "此处只读",
loadOlder: "加载更早的消息",
+ loading: "正在加载…",
you: "你",
assistant: "助手",
tool: "工具",
diff --git a/apps/desktop/resources/lan-webui/model-picker.js b/apps/desktop/resources/lan-webui/model-picker.js
index 46fb0d4f0..742b820bb 100644
--- a/apps/desktop/resources/lan-webui/model-picker.js
+++ b/apps/desktop/resources/lan-webui/model-picker.js
@@ -29,7 +29,7 @@
type: "button", class: "icon-btn", "aria-label": t("cancel"), onclick: () => dismiss(true),
}, icon("close"));
const search = el("input", {
- type: "search", placeholder: t("searchModels"), "aria-label": t("searchModels"), autocomplete: "off", enterkeyhint: "search",
+ class: "model-search", type: "search", placeholder: t("searchModels"), "aria-label": t("searchModels"), autocomplete: "off", enterkeyhint: "search",
});
const status = el("p", { class: "model-picker-status", role: "status" });
const retry = el("button", { type: "button", class: "secondary", text: t("retry"), onclick: () => void reload() });
diff --git a/apps/desktop/resources/lan-webui/styles.css b/apps/desktop/resources/lan-webui/styles.css
index 850beae02..b2996c8e1 100644
--- a/apps/desktop/resources/lan-webui/styles.css
+++ b/apps/desktop/resources/lan-webui/styles.css
@@ -380,8 +380,15 @@ label {
margin: 0 calc(-1 * var(--pad-right)) 0 calc(-1 * var(--pad-left));
padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
background: var(--ds-header-bg);
- -webkit-backdrop-filter: saturate(180%) blur(16px);
- backdrop-filter: saturate(180%) blur(16px);
+ -webkit-backdrop-filter: saturate(180%) blur(20px);
+ backdrop-filter: saturate(180%) blur(20px);
+ transition: box-shadow var(--motion-duration-normal) var(--motion-ease-out);
+}
+.scrolled .header {
+ box-shadow: 0 0.5px 0 color-mix(in oklab, var(--ds-text-primary) 12%, transparent);
+}
+.header.root {
+ min-height: calc(60px + env(safe-area-inset-top));
}
.header-title {
display: flex;
@@ -403,7 +410,7 @@ label {
white-space: nowrap;
}
.header.root h1 {
- font-size: var(--text-xl);
+ font-size: 26px;
font-weight: var(--font-weight-strong);
letter-spacing: var(--tracking-tight);
}
@@ -476,6 +483,12 @@ label {
}
.row:has(.row-main:active) {
background-color: var(--ds-bg-active);
+ scale: 0.985;
+}
+.row {
+ transition:
+ background-color var(--motion-duration-fast) var(--motion-ease-out),
+ scale var(--motion-duration-fast) var(--motion-ease-out);
}
@media (hover: hover) {
.row:hover {
@@ -499,8 +512,19 @@ label {
}
.row-icon {
display: inline-flex;
+ flex: none;
+ align-items: center;
+ justify-content: center;
+ width: 36px;
+ height: 36px;
+ border-radius: var(--radius-sm);
+ background: var(--ds-tile-hover);
color: var(--ds-text-secondary);
}
+.row-icon .icon {
+ width: 18px;
+ height: 18px;
+}
.row-text {
display: flex;
flex: 1;
@@ -571,15 +595,23 @@ label {
font-size: var(--text-md-plus);
text-align: center;
}
-.empty .icon {
- color: var(--ds-text-faint);
+.empty .icon,
+.chat-empty .icon {
+ box-sizing: content-box;
+ width: 28px;
+ height: 28px;
+ padding: 18px;
+ border-radius: var(--radius-round);
+ background: var(--ds-tile);
+ color: var(--ds-text-muted);
}
.section {
margin-bottom: 16px;
}
.section-label {
- margin: 6px 12px 4px;
+ margin: 14px 12px 6px;
+ letter-spacing: 0.01em;
color: var(--ds-text-muted);
font-size: var(--text-sm);
font-weight: var(--font-weight-medium);
@@ -634,6 +666,9 @@ main > button.fab {
box-shadow: var(--ds-shadow-fab);
font-size: var(--text-base-plus);
}
+main > button.fab:active:not(:disabled) {
+ scale: 0.96;
+}
.fab-spacer {
flex: none;
height: calc(88px + env(safe-area-inset-bottom));
@@ -1010,8 +1045,7 @@ main > button.fab {
text-align: center;
}
.chat-empty .icon {
- margin-bottom: 10px;
- color: var(--ds-text-faint);
+ margin-bottom: 12px;
}
.chat-empty-title {
color: var(--ds-text-primary);
@@ -1225,8 +1259,12 @@ main > button.fab {
box-shadow: var(--ds-elevation-stroke), var(--ds-shadow-dialog);
color: var(--ds-text-primary);
}
+.model-picker[open] {
+ animation: sheet-in 280ms var(--motion-ease-out);
+}
.model-picker::backdrop {
background: var(--ds-scrim);
+ animation: fade-in var(--motion-duration-normal) var(--motion-ease-out);
}
.model-picker-body {
display: flex;
@@ -1261,11 +1299,18 @@ main > button.fab {
.model-options button {
justify-content: space-between;
width: 100%;
+ min-height: 52px;
padding: 8px 12px;
+ border-radius: var(--radius-md);
+ font-weight: var(--font-weight-normal);
text-align: start;
}
.model-options button[aria-current="true"] {
- background: var(--ds-tile);
+ background: var(--ds-tile-hover);
+ font-weight: var(--font-weight-medium);
+}
+.model-search {
+ border-radius: var(--radius-full);
}
.model-option-copy {
display: grid;
@@ -1313,10 +1358,11 @@ main > button.fab {
right: var(--pad-right);
bottom: calc(96px + env(safe-area-inset-bottom));
left: var(--pad-left);
- max-width: 480px;
+ width: max-content;
+ max-width: min(480px, calc(100% - var(--pad-left) - var(--pad-right)));
margin: 0 auto;
- padding: 12px 16px;
- border-radius: var(--radius-md-plus);
+ padding: 11px 18px;
+ border-radius: var(--radius-xl);
background: var(--ds-bg-elevated-opaque);
box-shadow: var(--ds-elevation-stroke), var(--ds-shadow-dialog);
color: var(--ds-text-primary);
@@ -1345,7 +1391,20 @@ main > button.fab {
border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
background: var(--ds-bg-elevated-opaque);
box-shadow: var(--ds-elevation-stroke), var(--ds-shadow-dialog);
- animation: rise-in var(--motion-duration-normal) var(--motion-ease-out);
+ animation: sheet-in 280ms var(--motion-ease-out);
+ transition: translate var(--motion-duration-normal) var(--motion-ease-out);
+ overscroll-behavior: contain;
+}
+.sheet-panel::before,
+.model-picker-body::before {
+ content: "";
+ display: block;
+ flex: none;
+ width: 36px;
+ height: 5px;
+ margin: 2px auto 0;
+ border-radius: var(--radius-full);
+ background: color-mix(in oklab, var(--ds-text-primary) 20%, transparent);
}
.sheet-title {
display: -webkit-box;
@@ -1428,8 +1487,14 @@ main > button.fab {
padding: calc(32px + env(safe-area-inset-top)) 0 calc(32px + env(safe-area-inset-bottom));
}
.pair .icon.lg {
- margin-bottom: 20px;
- color: var(--ds-text-secondary);
+ box-sizing: content-box;
+ width: 32px;
+ height: 32px;
+ margin-bottom: 24px;
+ padding: 16px;
+ border-radius: var(--radius-xl);
+ background: var(--ds-tile-hover);
+ color: var(--ds-text-primary);
}
.pair h1 {
font-size: var(--text-2xl);
@@ -1444,8 +1509,9 @@ main > button.fab {
line-height: var(--leading-relaxed);
}
.pair .code {
- min-height: 60px;
- border-radius: var(--radius-md);
+ min-height: 64px;
+ border-radius: var(--radius-md-plus);
+ font-weight: var(--font-weight-medium);
font-family: var(--font-mono);
font-size: var(--text-2xl);
font-variant-numeric: tabular-nums;
@@ -1457,9 +1523,9 @@ main > button.fab {
}
.pair button[type="submit"] {
width: 100%;
- min-height: 50px;
+ min-height: 52px;
margin-top: 28px;
- border-radius: var(--radius-md);
+ border-radius: var(--radius-full);
font-size: var(--text-base-plus);
}
.pair-status {
@@ -1471,7 +1537,100 @@ main > button.fab {
text-align: center;
}
+/* ---------- loading skeleton ---------- */
+.skeleton {
+ display: block;
+ border-radius: var(--radius-xs);
+ background:
+ linear-gradient(100deg, transparent 30%, color-mix(in oklab, var(--ds-text-primary) 6%, transparent) 50%, transparent 70%) 0 0 / 200% 100%,
+ var(--ds-tile-hover);
+ animation: shimmer 1.4s linear infinite;
+}
+.skeleton.heading {
+ width: 46%;
+ height: 18px;
+}
+.header.root .skeleton.heading {
+ height: 24px;
+}
+.skeleton-list {
+ gap: 6px;
+ padding-top: 64px;
+}
+.skeleton-row {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ padding: 12px;
+}
+.skeleton.title {
+ width: 62%;
+ height: 14px;
+}
+.skeleton.meta {
+ width: 34%;
+ height: 11px;
+}
+.skeleton-list > li:nth-child(even) .skeleton.title {
+ width: 48%;
+}
+.skeleton-chat {
+ gap: 12px;
+}
+.skeleton.bubble {
+ align-self: flex-end;
+ width: 58%;
+ height: 40px;
+ border-radius: var(--radius-xl);
+}
+.skeleton.bubble.narrow {
+ width: 36%;
+}
+.skeleton.line {
+ width: 72%;
+ height: 13px;
+}
+.skeleton.line.wide {
+ width: 92%;
+}
+.skeleton.line.short {
+ width: 40%;
+}
+
+/* ---------- page transitions ---------- */
+main.enter-push > :not(.fab, .chat-dock, .header) {
+ animation: page-push 260ms var(--motion-ease-out);
+}
+main.enter-pop > :not(.fab, .chat-dock, .header) {
+ animation: page-pop 260ms var(--motion-ease-out);
+}
+main:is(.enter-push, .enter-pop) > :is(.header, .chat-dock, .fab) {
+ animation: fade-in var(--motion-duration-normal) var(--motion-ease-out);
+}
+
/* ---------- motion ---------- */
+@keyframes page-push {
+ from {
+ opacity: 0;
+ translate: 24px 0;
+ }
+}
+@keyframes page-pop {
+ from {
+ opacity: 0;
+ translate: -24px 0;
+ }
+}
+@keyframes sheet-in {
+ from {
+ translate: 0 100%;
+ }
+}
+@keyframes shimmer {
+ to {
+ background-position: -200% 0, 0 0;
+ }
+}
@keyframes fade-in {
from {
opacity: 0;