forge
Explore
Log in

Don't you dare go Hollow

The bell's popover stays open instead of closing as the click also followed its link to the inbox

Browse files at this commit

240478f3c3da80d277a97943f3b211e0d40603a0Ahmet Kaan GümüşParent: 8e5a2cf
Some checks failed
Show checks
  • fix
    • the bell's popover stays open instead of closing as the click also followed its link to the inbox
    • a live page waits to re-render while the reader holds a button or has text selected, so selecting a log line to copy no longer resets
    • a runner's log has a Copy all button, and a line that wraps or holds newlines continues under the message column
    • the runner leaves an HTML error page out of its error (forge answered 503 Service Unavailable) and folds other bodies onto one line
    • a runner's whole row in the list opens its page
    • the repo home puts the branch bar and the tree in a left column, the README beside it and About on the right, filling the screen with each column scrolling on its own (tree and README side by side from 900px, the aside under them until 1200px)
Show full message
🐛 fix: the bell's popover stays open instead of closing as the click also followed its link to the inbox; a live page waits to re-render while the reader holds a button or has text selected, so selecting a log line to copy no longer resets; a runner's log has a Copy all button, and a line that wraps or holds newlines continues under the message column; the runner leaves an HTML error page out of its error (forge answered 503 Service Unavailable) and folds other bodies onto one line; a runner's whole row in the list opens its page; the repo home puts the branch bar and the tree in a left column, the README beside it and About on the right, filling the screen with each column scrolling on its own (tree and README side by side from 900px, the aside under them until 1200px)
crates/forge-runner/src/client.rsmodified+17 -7
@@ -44,7 +44,7 @@ const RUNNER_METRICS_PATH: &str = "/api/v1/ci/runners/metrics";
4444 pub enum ClientError {
4545 #[error("http: {0}")]
4646 Http(#[from] reqwest::Error),
47- #[error("forge answered {status}: {body}")]
47+ #[error("forge answered {status}{}", if body.is_empty() { String::new() } else { format!(": {body}") })]
4848 Status { status: StatusCode, body: String },
4949 #[error("local io: {0}")]
5050 Io(#[from] std::io::Error),
@@ -500,14 +500,24 @@ async fn json_or_error<T: DeserializeOwned>(resp: reqwest::Response) -> Result<T
500500
501501 async fn status_error(resp: reqwest::Response) -> ClientError {
502502 let status = resp.status();
503- let body: String = resp
504- .text()
505- .await
506- .unwrap_or_default()
503+ let body = short_body(&resp.text().await.unwrap_or_default());
504+ ClientError::Status { status, body }
505+}
506+
507+/// The part of an error body worth a log line: an HTML error page (a proxy's or the forge's own 503
508+/// page) says no more than the status does, so it is dropped; any other text is folded onto one line
509+/// and cut at 512 characters.
510+fn short_body(text: &str) -> String {
511+ let text = text.trim_start();
512+ if text.starts_with('<') {
513+ return String::new();
514+ }
515+ text.split_whitespace()
516+ .collect::<Vec<_>>()
517+ .join(" ")
507518 .chars()
508519 .take(512)
509- .collect();
510- ClientError::Status { status, body }
520+ .collect()
511521 }
512522
513523 #[cfg(test)]
crates/forge-web/assets/nav.jsmodified+25 -3
@@ -763,7 +763,9 @@
763763 peekPress = !!(pop && pop.classList.contains('bell-pop') && isPeekOpen(pop));
764764 }, true);
765765
766- document.addEventListener('click', function (e) {
766+ // Capture on window, so it runs before the soft navigation (capture on document) follows the
767+ // bell's link to the inbox, which would swap the page and close the popover it just opened.
768+ window.addEventListener('click', function (e) {
767769 if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; }
768770 var bell = e.target && e.target.closest ? e.target.closest('.corner-bell') : null;
769771 if (!bell) { return; }
@@ -776,7 +778,7 @@
776778 try {
777779 if (was) { pop.hidePopover(); } else { pop.showPopover(); }
778780 } catch (err) { }
779- }, false);
781+ }, true);
780782
781783 // The popover's open state drives its bell's aria-expanded; opening places it and fetches its list.
782784 document.addEventListener('toggle', function (e) {
@@ -2494,6 +2496,26 @@
24942496 if (atEnd) { pre.scrollTop = pre.scrollHeight; }
24952497 }
24962498
2499+ // A re-render replaces the text the reader is selecting (a log line to copy, say), so a live change
2500+ // waits while a button is held or text on the page is selected, and is sent once the selection is
2501+ // gone. A selection inside a field does not count: fields keep their state across a re-render.
2502+ var pressing = false;
2503+ function selecting() {
2504+ if (pressing) { return true; }
2505+ var sel = window.getSelection ? window.getSelection() : null;
2506+ if (!sel || sel.isCollapsed || !sel.rangeCount) { return false; }
2507+ var act = document.activeElement;
2508+ return !(act && (act.tagName === 'INPUT' || act.tagName === 'TEXTAREA'));
2509+ }
2510+ function selectionDone() {
2511+ if (liveDirty && !selecting()) { refreshLive(liveForced); }
2512+ }
2513+ document.addEventListener('pointerdown', function (e) { if (e.button === 0) { pressing = true; } }, true);
2514+ document.addEventListener('pointerup', function () { pressing = false; setTimeout(selectionDone, 0); }, true);
2515+ document.addEventListener('pointercancel', function () { pressing = false; selectionDone(); }, true);
2516+ document.addEventListener('selectionchange', selectionDone);
2517+ window.addEventListener('blur', function () { pressing = false; });
2518+
24972519 // A change re-renders the current page. It waits while a navigation is on the wire, since that
24982520 // response could be superseded: the change is kept and sent after that request completes.
24992521 // `force` re-renders a page that holds no stream of its own (a language change, or a live server
@@ -2503,7 +2525,7 @@
25032525 // A one-time secret (a token, recovery codes) is on screen only in the response that made it: a
25042526 // re-render would take it away. The page is refreshed at the next navigation instead.
25052527 if (document.querySelector('[data-once]')) { return; }
2506- if (userBusy > 0 || liveBusy) { liveDirty = true; if (force) { liveForced = true; } return; }
2528+ if (userBusy > 0 || liveBusy || selecting()) { liveDirty = true; if (force) { liveForced = true; } return; }
25072529 liveDirty = false;
25082530 liveForced = false;
25092531 liveBusy = true;
crates/forge-web/src/pages/admin_runners.rsmodified+7 -3
@@ -31,6 +31,7 @@ use crate::ci::runner_log::Line;
3131 use crate::auth::check_csrf;
3232 use crate::i18n::admin::{self as g, K};
3333 use crate::i18n::{self, Key, Lang};
34+use crate::i18n::releases_ci as rc;
3435 use crate::pages::admin_users::admin_only;
3536 use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text};
3637 use crate::pages::repo_mirrors::stamp_in_tz;
@@ -338,7 +339,7 @@ async fn runners_view(
338339 } else {
339340 <ul class="runner-list">
340341 for row in rows.iter() {
341- <li class="runner-row">
342+ <li class="runner-row is-linked">
342343 <div class="runner-id">
343344 <div class="runner-title">
344345 <span class=(row.dot_class) role="img" aria-label=(row.state_text) title=(row.state_text)></span>
@@ -1679,9 +1680,12 @@ async fn runner_detail_view(
16791680 if log.is_empty() {
16801681 <p class="muted small">(s(lang, "No log lines yet. Only a runner from the version that sends its log does so; an older runner sends nothing.", "Henüz günlük satırı yok. Günlüğünü yalnızca bunu destekleyen sürüm gönderir; eski sürüm hiçbir şey göndermez."))</p>
16811682 } else {
1682- <pre class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))>
1683+ <div class="runner-log-bar">
1684+ <button type="button" class="ci-mini" data-copy="runner-log" data-copied=(rc::t(lang, rc::K::CopyDone)) data-failed=(rc::t(lang, rc::K::CopyFailed))>(s(lang, "Copy all", "Tümünü kopyala"))</button>
1685+ </div>
1686+ <pre id="runner-log" class="ci-log runner-log" role="log" aria-label=(s(lang, "Runner log", "Çalıştırıcı günlüğü"))>
16831687 for row in log.iter() {
1684- <span class=(row.class)><span class="runner-log-time">(row.time.as_str())</span>" "<span class="runner-log-level">(row.level.as_str())</span>" "<span class="runner-log-chip">(row.chip)</span>" "(row.text.as_str())</span>"\n"
1688+ <span class=(row.class)><span class="runner-log-time">(row.time.as_str())</span>" "<span class="runner-log-level">(row.level.as_str())</span>" "<span class="runner-log-chip">(row.chip)</span>" "(row.text.as_str())"\n"</span>
16851689 }
16861690 </pre>
16871691 }
crates/forge-web/src/pages/repo.rsmodified+12 -10
@@ -500,18 +500,20 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
500500 recent_pushes(banners: banners, now: now, lang: lang)
501501 }
502502 if let Some(rows) = tree {
503- <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))>
504- ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags,
505- branches_href: branches_href, tags_href: tags_href)
506- file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),
507- ref_name: branch.clone())
508- archive_links(owner: owner_name, repo: repo_name,
509- ref_name: branch.clone(), lang: lang)
510- clone_popover(https: https, ssh: ssh, lang: lang)
511- </div>
512- <div class="repo-grid">
503+ <div class="repo-grid repo-home">
513504 <div class="repo-main">
505+ <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))>
506+ ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags,
507+ branches_href: branches_href, tags_href: tags_href)
508+ file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),
509+ ref_name: branch.clone())
510+ archive_links(owner: owner_name, repo: repo_name,
511+ ref_name: branch.clone(), lang: lang)
512+ clone_popover(https: https, ssh: ssh, lang: lang)
513+ </div>
514514 tree_table(rows: rows, latest: bar, lang: lang)
515+ </div>
516+ <div class="repo-readme">
515517 if let Some(readme) = readme {
516518 readme_card(name: readme.name, markdown: readme.markdown, body: readme.body)
517519 }
style/_admin_rows.scssmodified+14 -2
@@ -93,9 +93,14 @@
9393 }
9494 }
9595
96-// The runner's own log on its admin page (the logs tab), newest line first. Lines stay inline:
97-// the pre breaks them with its own newlines.
96+// The runner's own log on its admin page (the logs tab), newest line first. Each line is a block
97+// with a hanging indent, so a message that wraps or holds newlines of its own continues under the
98+// message column (past the time and level) instead of at the left edge, where it reads as new lines.
9899 .runner-log-line {
100+ display: block;
101+ padding-left: 15ch;
102+ text-indent: -15ch;
103+
99104 &.is-warn {
100105 color: var(--warn);
101106 }
@@ -122,6 +127,13 @@
122127 padding: 8px 12px;
123128 }
124129
130+// Copy all sits above the log, at its right edge.
131+.runner-log-bar {
132+ display: flex;
133+ justify-content: flex-end;
134+ margin-bottom: 6px;
135+}
136+
125137 // The metrics tab: three small graphs, one under another, each with its caption on the left. Every
126138 // graph is its own SVG with one y axis; colours come from tokens only. A line follows the accent, a
127139 // sent line is dashed in the secondary text colour so it is told apart without colour.
style/_repo.scssmodified+98 -3
@@ -242,8 +242,7 @@
242242 }
243243 }
244244
245-// Two columns at 900px and up: the directory and README take the remaining width, then a
246-// narrow repo-meta aside (280px). Below 900px the aside stacks under the main column.
245+// Grid of the repo-meta aside and the main column. Below 900px the columns stack in normal flow.
247246 .repo-grid {
248247 display: grid;
249248 grid-template-columns: minmax(0, 1fr);
@@ -269,11 +268,107 @@
269268 }
270269 }
271270
271+// Repo home: the browse bar and the tree form a left column, the README fills the middle and the
272+// repo-meta aside sits on the right. The columns scroll inside the grid so the page fits the
273+// viewport; the height is the viewport less the top bar and the page header.
274+.repo-home {
275+ --repo-home-h: max(480px, calc(100dvh - var(--topbar-h) - 200px));
276+ margin-top: 20px;
277+
278+ // The grid's own margin carries the space above the browse bar.
279+ .browse-bar {
280+ margin: 0 0 12px;
281+ }
282+
283+ .repo-main {
284+ display: flex;
285+ flex-direction: column;
286+ min-height: 0;
287+ }
288+
289+ // Only the tree scrolls, not the browse bar: the Clone popover drops over the tree and a scrolling
290+ // ancestor would clip it.
291+ .repo-main .table-wrap {
292+ flex: 1 1 auto;
293+ min-height: 0;
294+ overflow-y: auto;
295+ }
296+
297+ .repo-readme {
298+ min-width: 0;
299+ min-height: 0;
300+ overflow-y: auto;
301+ }
302+
303+ .readme {
304+ margin-top: 0;
305+ }
306+}
307+
308+// 900px to 1199px: the tree and README sit side by side and the aside drops under them at full
309+// width, so the columns keep their own height and the aside flows with the page.
272310 @media (min-width: 900px) {
273311 .repo-grid {
274- grid-template-columns: minmax(0, 1fr) 280px;
275312 gap: 40px;
313+ }
314+
315+ .repo-home {
316+ grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
276317 align-items: start;
318+
319+ .repo-main,
320+ .repo-readme {
321+ max-height: var(--repo-home-h);
322+ }
323+
324+ .repo-meta {
325+ grid-column: 1 / -1;
326+ }
327+
328+ // The name keeps half the narrow column and the last-commit message takes the rest.
329+ .tree-table {
330+ th,
331+ td {
332+ padding-right: 10px;
333+ }
334+
335+ .tree-name {
336+ max-width: 50%;
337+ }
338+
339+ .tree-commit a {
340+ font-size: 13px;
341+ }
342+ }
343+
344+ .latest-commit {
345+ gap: 8px;
346+
347+ .latest-author {
348+ max-width: 8rem;
349+ }
350+ }
351+ }
352+}
353+
354+// 1200px and up: browse bar and tree | README | aside, all filling the viewport height.
355+@media (min-width: 1200px) {
356+ .repo-home {
357+ grid-template-columns: minmax(320px, 420px) minmax(0, 1fr) 260px;
358+ gap: 32px;
359+ align-items: stretch;
360+ height: var(--repo-home-h);
361+
362+ .repo-main,
363+ .repo-readme {
364+ max-height: none;
365+ }
366+
367+ .repo-meta {
368+ grid-column: auto;
369+ min-height: 0;
370+ overflow-y: auto;
371+ }
277372 }
278373 }
279374
style/main.scssmodified+26 -0
@@ -5343,6 +5343,32 @@ $ansi-colours: (
53435343 border-top: 1px solid var(--border);
53445344 }
53455345
5346+// A runner's whole row opens its page: the name's link stretches over the row, and the controls
5347+// in it (the concurrency stepper, the actions menu) sit above that link so they still work. The
5348+// row reaches 12px past the list on each side, so its hover background does not touch the text.
5349+.runner-row.is-linked {
5350+ position: relative;
5351+ margin: 0 -12px;
5352+ padding-inline: 12px;
5353+ border-radius: var(--radius-sm);
5354+
5355+ &:hover {
5356+ background: var(--surface-2);
5357+ }
5358+
5359+ .runner-name::after {
5360+ content: "";
5361+ position: absolute;
5362+ inset: 0;
5363+ }
5364+
5365+ > .runner-load,
5366+ > .row-menu {
5367+ position: relative;
5368+ z-index: 1;
5369+ }
5370+}
5371+
53465372 .runner-id,
53475373 .runner-load,
53485374 .runner-version {