diff --git a/crates/forge-runner/src/client.rs b/crates/forge-runner/src/client.rs index 35001b8..4ed73f0 100644 --- a/crates/forge-runner/src/client.rs +++ b/crates/forge-runner/src/client.rs @@ -44,7 +44,7 @@ const RUNNER_METRICS_PATH: &str = "/api/v1/ci/runners/metrics"; pub enum ClientError { #[error("http: {0}")] Http(#[from] reqwest::Error), - #[error("forge answered {status}: {body}")] + #[error("forge answered {status}{}", if body.is_empty() { String::new() } else { format!(": {body}") })] Status { status: StatusCode, body: String }, #[error("local io: {0}")] Io(#[from] std::io::Error), @@ -500,14 +500,24 @@ async fn json_or_error(resp: reqwest::Response) -> Result ClientError { let status = resp.status(); - let body: String = resp - .text() - .await - .unwrap_or_default() + let body = short_body(&resp.text().await.unwrap_or_default()); + ClientError::Status { status, body } +} + +/// The part of an error body worth a log line: an HTML error page (a proxy's or the forge's own 503 +/// page) says no more than the status does, so it is dropped; any other text is folded onto one line +/// and cut at 512 characters. +fn short_body(text: &str) -> String { + let text = text.trim_start(); + if text.starts_with('<') { + return String::new(); + } + text.split_whitespace() + .collect::>() + .join(" ") .chars() .take(512) - .collect(); - ClientError::Status { status, body } + .collect() } #[cfg(test)] diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index d4e6cb6..915127f 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -763,7 +763,9 @@ peekPress = !!(pop && pop.classList.contains('bell-pop') && isPeekOpen(pop)); }, true); - document.addEventListener('click', function (e) { + // Capture on window, so it runs before the soft navigation (capture on document) follows the + // bell's link to the inbox, which would swap the page and close the popover it just opened. + window.addEventListener('click', function (e) { if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; } var bell = e.target && e.target.closest ? e.target.closest('.corner-bell') : null; if (!bell) { return; } @@ -776,7 +778,7 @@ try { if (was) { pop.hidePopover(); } else { pop.showPopover(); } } catch (err) { } - }, false); + }, true); // The popover's open state drives its bell's aria-expanded; opening places it and fetches its list. document.addEventListener('toggle', function (e) { @@ -2494,6 +2496,26 @@ if (atEnd) { pre.scrollTop = pre.scrollHeight; } } + // A re-render replaces the text the reader is selecting (a log line to copy, say), so a live change + // waits while a button is held or text on the page is selected, and is sent once the selection is + // gone. A selection inside a field does not count: fields keep their state across a re-render. + var pressing = false; + function selecting() { + if (pressing) { return true; } + var sel = window.getSelection ? window.getSelection() : null; + if (!sel || sel.isCollapsed || !sel.rangeCount) { return false; } + var act = document.activeElement; + return !(act && (act.tagName === 'INPUT' || act.tagName === 'TEXTAREA')); + } + function selectionDone() { + if (liveDirty && !selecting()) { refreshLive(liveForced); } + } + document.addEventListener('pointerdown', function (e) { if (e.button === 0) { pressing = true; } }, true); + document.addEventListener('pointerup', function () { pressing = false; setTimeout(selectionDone, 0); }, true); + document.addEventListener('pointercancel', function () { pressing = false; selectionDone(); }, true); + document.addEventListener('selectionchange', selectionDone); + window.addEventListener('blur', function () { pressing = false; }); + // A change re-renders the current page. It waits while a navigation is on the wire, since that // response could be superseded: the change is kept and sent after that request completes. // `force` re-renders a page that holds no stream of its own (a language change, or a live server @@ -2503,7 +2525,7 @@ // A one-time secret (a token, recovery codes) is on screen only in the response that made it: a // re-render would take it away. The page is refreshed at the next navigation instead. if (document.querySelector('[data-once]')) { return; } - if (userBusy > 0 || liveBusy) { liveDirty = true; if (force) { liveForced = true; } return; } + if (userBusy > 0 || liveBusy || selecting()) { liveDirty = true; if (force) { liveForced = true; } return; } liveDirty = false; liveForced = false; liveBusy = true; diff --git a/crates/forge-web/src/pages/admin_runners.rs b/crates/forge-web/src/pages/admin_runners.rs index 6c6f8d3..65a53a1 100644 --- a/crates/forge-web/src/pages/admin_runners.rs +++ b/crates/forge-web/src/pages/admin_runners.rs @@ -31,6 +31,7 @@ use crate::ci::runner_log::Line; use crate::auth::check_csrf; use crate::i18n::admin::{self as g, K}; use crate::i18n::{self, Key, Lang}; +use crate::i18n::releases_ci as rc; use crate::pages::admin_users::admin_only; use crate::pages::ci_runs::{age_text, duration_text, events_response, run_href, state_text}; use crate::pages::repo_mirrors::stamp_in_tz; @@ -338,7 +339,7 @@ async fn runners_view( } else {
    for row in rows.iter() { -
  • +
  • @@ -1679,9 +1680,12 @@ async fn runner_detail_view( if log.is_empty() {

    (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."))

    } else { -
    +                    
    + +
    +
                             for row in log.iter() {
    -                            (row.time.as_str())" "(row.level.as_str())" "(row.chip)" "(row.text.as_str())"\n"
    +                            (row.time.as_str())" "(row.level.as_str())" "(row.chip)" "(row.text.as_str())"\n"
                             }
                         
    } diff --git a/crates/forge-web/src/pages/repo.rs b/crates/forge-web/src/pages/repo.rs index 3dd2f06..6f7c5f6 100644 --- a/crates/forge-web/src/pages/repo.rs +++ b/crates/forge-web/src/pages/repo.rs @@ -500,18 +500,20 @@ async fn repo_page(cx: &Cx) -> Result { recent_pushes(banners: banners, now: now, lang: lang) } if let Some(rows) = tree { -
    - ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, - branches_href: branches_href, tags_href: tags_href) - file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), - ref_name: branch.clone()) - archive_links(owner: owner_name, repo: repo_name, - ref_name: branch.clone(), lang: lang) - clone_popover(https: https, ssh: ssh, lang: lang) -
    -
    +
    +
    + ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags, + branches_href: branches_href, tags_href: tags_href) + file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), + ref_name: branch.clone()) + archive_links(owner: owner_name, repo: repo_name, + ref_name: branch.clone(), lang: lang) + clone_popover(https: https, ssh: ssh, lang: lang) +
    tree_table(rows: rows, latest: bar, lang: lang) +
    +
    if let Some(readme) = readme { readme_card(name: readme.name, markdown: readme.markdown, body: readme.body) } diff --git a/style/_admin_rows.scss b/style/_admin_rows.scss index c84b477..c0c35c5 100644 --- a/style/_admin_rows.scss +++ b/style/_admin_rows.scss @@ -93,9 +93,14 @@ } } -// The runner's own log on its admin page (the logs tab), newest line first. Lines stay inline: -// the pre breaks them with its own newlines. +// The runner's own log on its admin page (the logs tab), newest line first. Each line is a block +// with a hanging indent, so a message that wraps or holds newlines of its own continues under the +// message column (past the time and level) instead of at the left edge, where it reads as new lines. .runner-log-line { + display: block; + padding-left: 15ch; + text-indent: -15ch; + &.is-warn { color: var(--warn); } @@ -122,6 +127,13 @@ padding: 8px 12px; } +// Copy all sits above the log, at its right edge. +.runner-log-bar { + display: flex; + justify-content: flex-end; + margin-bottom: 6px; +} + // The metrics tab: three small graphs, one under another, each with its caption on the left. Every // graph is its own SVG with one y axis; colours come from tokens only. A line follows the accent, a // sent line is dashed in the secondary text colour so it is told apart without colour. diff --git a/style/_repo.scss b/style/_repo.scss index eb5d296..d020762 100644 --- a/style/_repo.scss +++ b/style/_repo.scss @@ -242,8 +242,7 @@ } } -// Two columns at 900px and up: the directory and README take the remaining width, then a -// narrow repo-meta aside (280px). Below 900px the aside stacks under the main column. +// Grid of the repo-meta aside and the main column. Below 900px the columns stack in normal flow. .repo-grid { display: grid; grid-template-columns: minmax(0, 1fr); @@ -269,11 +268,107 @@ } } +// Repo home: the browse bar and the tree form a left column, the README fills the middle and the +// repo-meta aside sits on the right. The columns scroll inside the grid so the page fits the +// viewport; the height is the viewport less the top bar and the page header. +.repo-home { + --repo-home-h: max(480px, calc(100dvh - var(--topbar-h) - 200px)); + margin-top: 20px; + + // The grid's own margin carries the space above the browse bar. + .browse-bar { + margin: 0 0 12px; + } + + .repo-main { + display: flex; + flex-direction: column; + min-height: 0; + } + + // Only the tree scrolls, not the browse bar: the Clone popover drops over the tree and a scrolling + // ancestor would clip it. + .repo-main .table-wrap { + flex: 1 1 auto; + min-height: 0; + overflow-y: auto; + } + + .repo-readme { + min-width: 0; + min-height: 0; + overflow-y: auto; + } + + .readme { + margin-top: 0; + } +} + +// 900px to 1199px: the tree and README sit side by side and the aside drops under them at full +// width, so the columns keep their own height and the aside flows with the page. @media (min-width: 900px) { .repo-grid { - grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; + } + + .repo-home { + grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; + + .repo-main, + .repo-readme { + max-height: var(--repo-home-h); + } + + .repo-meta { + grid-column: 1 / -1; + } + + // The name keeps half the narrow column and the last-commit message takes the rest. + .tree-table { + th, + td { + padding-right: 10px; + } + + .tree-name { + max-width: 50%; + } + + .tree-commit a { + font-size: 13px; + } + } + + .latest-commit { + gap: 8px; + + .latest-author { + max-width: 8rem; + } + } + } +} + +// 1200px and up: browse bar and tree | README | aside, all filling the viewport height. +@media (min-width: 1200px) { + .repo-home { + grid-template-columns: minmax(320px, 420px) minmax(0, 1fr) 260px; + gap: 32px; + align-items: stretch; + height: var(--repo-home-h); + + .repo-main, + .repo-readme { + max-height: none; + } + + .repo-meta { + grid-column: auto; + min-height: 0; + overflow-y: auto; + } } } diff --git a/style/main.scss b/style/main.scss index 65f8ef6..af1eab1 100644 --- a/style/main.scss +++ b/style/main.scss @@ -5343,6 +5343,32 @@ $ansi-colours: ( border-top: 1px solid var(--border); } +// A runner's whole row opens its page: the name's link stretches over the row, and the controls +// in it (the concurrency stepper, the actions menu) sit above that link so they still work. The +// row reaches 12px past the list on each side, so its hover background does not touch the text. +.runner-row.is-linked { + position: relative; + margin: 0 -12px; + padding-inline: 12px; + border-radius: var(--radius-sm); + + &:hover { + background: var(--surface-2); + } + + .runner-name::after { + content: ""; + position: absolute; + inset: 0; + } + + > .runner-load, + > .row-menu { + position: relative; + z-index: 1; + } +} + .runner-id, .runner-load, .runner-version {