From b5360113018e6ba11b9c83abf8e210ecaf2ce58f Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 20:08:02 +0100 Subject: [PATCH 1/8] Add license informations for github-markdown-css --- src/gh_comments/github-markdown@5.8.1.css | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gh_comments/github-markdown@5.8.1.css b/src/gh_comments/github-markdown@5.8.1.css index bc8e12bb..47712e2b 100644 --- a/src/gh_comments/github-markdown@5.8.1.css +++ b/src/gh_comments/github-markdown@5.8.1.css @@ -1,3 +1,18 @@ +/* SPDX-License-Identifier: MIT */ +/** + * https://github.com/sindresorhus/github-markdown-css + * + * MIT License + * + * Copyright (c) Sindre Sorhus (https://sindresorhus.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + .markdown-body { --base-size-4: 0.25rem; --base-size-8: 0.5rem; From beebfdcc5ca9eaa1486ecb9cd30b2d81cec42e59 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 20:36:17 +0100 Subject: [PATCH 2/8] Extract GitHubComments cache into a re-usable cache --- src/cache.rs | 86 ++++++++++++++++++++++++++++++++++++++++++++++ src/gh_comments.rs | 62 +++++---------------------------- src/lib.rs | 1 + src/main.rs | 6 ++-- 4 files changed, 100 insertions(+), 55 deletions(-) create mode 100644 src/cache.rs diff --git a/src/cache.rs b/src/cache.rs new file mode 100644 index 00000000..c0247d1f --- /dev/null +++ b/src/cache.rs @@ -0,0 +1,86 @@ +use std::{collections::VecDeque, sync::Arc}; + +pub trait EstimatedSize { + fn estimated_size(&self) -> usize; +} + +/// Simple LRU cache. +/// +/// Evicts the Least Recently Used entry when space is needed. +pub struct LeastRecentlyUsedCache { + size: usize, + capacity: usize, + entries: VecDeque<(K, Arc)>, +} + +impl LeastRecentlyUsedCache { + /// Creates the cache with a maxmimum capacity + pub fn new(capacity: usize) -> Self { + LeastRecentlyUsedCache { + size: 0, + capacity, + entries: VecDeque::default(), + } + } +} + +#[cfg(test)] +impl Default for LeastRecentlyUsedCache { + fn default() -> Self { + Self::new(1 * 1024 * 1024) + } +} + +impl, V: EstimatedSize> LeastRecentlyUsedCache { + /// Get a handle to the value. + /// + /// Also move the entry in the cache to the first place. + pub(crate) fn get(&mut self, key: &K) -> Option> { + if let Some(pos) = self.entries.iter().position(|(k, _)| k == key) { + // Move previously cached entry to the front + let entry = self.entries.remove(pos).unwrap(); + self.entries.push_front(entry); + Some(self.entries[0].1.clone()) + } else { + None + } + } + + /// Inserts a new value to the cache + pub(crate) fn put(&mut self, key: K, value: Arc) -> Arc { + let estimated_size = value.estimated_size(); + + if estimated_size > self.capacity { + // Entry is too large, don't cache, return as is + return value; + } + + // Remove duplicate or last entry when necessary + let removed = if let Some(pos) = self.entries.iter().position(|(k, _)| k == &key) { + self.entries.remove(pos) + } else if self.size + estimated_size >= self.capacity { + self.entries.pop_back() + } else { + None + }; + if let Some(removed) = removed { + self.size -= removed.1.estimated_size(); + } + + // Add entry the front of the list and return it + self.size += estimated_size; + self.entries.push_front((key, value.clone())); + value + } + + /// Removes a value from the cache + pub(crate) fn prune(&mut self, key: &K) -> bool { + if let Some(pos) = self.entries.iter().position(|(k, _)| k == key) { + let entry = self.entries.remove(pos).unwrap(); + self.size -= entry.1.estimated_size(); + true + } else { + false + } + } +} diff --git a/src/gh_comments.rs b/src/gh_comments.rs index 2016c7fe..69d8c577 100644 --- a/src/gh_comments.rs +++ b/src/gh_comments.rs @@ -1,4 +1,3 @@ -use std::collections::VecDeque; use std::fmt::Write; use std::sync::Arc; use std::time::Instant; @@ -15,7 +14,10 @@ use hyper::{ header::{CACHE_CONTROL, CONTENT_SECURITY_POLICY, CONTENT_TYPE}, }; -use crate::github::{GitHubGraphQlComment, GitHubIssueWithComments}; +use crate::{ + cache, + github::{GitHubGraphQlComment, GitHubIssueWithComments}, +}; use crate::{ errors::AppError, github::GitHubSimplifiedAuthor, @@ -26,15 +28,9 @@ use crate::{ pub const STYLE_URL: &str = "/gh-comments/style@0.0.1.css"; pub const MARKDOWN_URL: &str = "/gh-comments/github-markdown@5.8.1.css"; -const MAX_CACHE_CAPACITY_BYTES: u64 = 35 * 1024 * 1024; // 35 Mb +pub const GH_COMMENTS_CACHE_CAPACITY_BYTES: usize = 35 * 1024 * 1024; // 35 Mb -type CacheKey = (String, String, u64); - -#[derive(Default)] -pub struct GitHubCommentsCache { - capacity: u64, - entries: VecDeque<(CacheKey, Arc)>, -} +pub type GitHubCommentsCache = cache::LeastRecentlyUsedCache<(String, String, u64), CachedComments>; pub struct CachedComments { estimated_size: usize, @@ -42,49 +38,9 @@ pub struct CachedComments { issue_with_comments: GitHubIssueWithComments, } -impl GitHubCommentsCache { - pub fn get(&mut self, key: &CacheKey) -> Option> { - if let Some(pos) = self.entries.iter().position(|(k, _)| k == key) { - // Move previously cached entry to the front - let entry = self.entries.remove(pos).unwrap(); - self.entries.push_front(entry.clone()); - Some(entry.1) - } else { - None - } - } - - pub fn put(&mut self, key: CacheKey, value: Arc) -> Arc { - if value.estimated_size as u64 > MAX_CACHE_CAPACITY_BYTES { - // Entry is too large, don't cache, return as is - return value; - } - - // Remove duplicate or last entry when necessary - let removed = if let Some(pos) = self.entries.iter().position(|(k, _)| k == &key) { - self.entries.remove(pos) - } else if self.capacity + value.estimated_size as u64 >= MAX_CACHE_CAPACITY_BYTES { - self.entries.pop_back() - } else { - None - }; - if let Some(removed) = removed { - self.capacity -= removed.1.estimated_size as u64; - } - - // Add entry the front of the list and return it - self.capacity += value.estimated_size as u64; - self.entries.push_front((key, value.clone())); - value - } - - pub fn prune(&mut self, key: &CacheKey) -> bool { - if let Some(pos) = self.entries.iter().position(|(k, _)| k == key) { - self.entries.remove(pos); - true - } else { - false - } +impl cache::EstimatedSize for CachedComments { + fn estimated_size(&self) -> usize { + self.estimated_size } } diff --git a/src/lib.rs b/src/lib.rs index cd6ed0ba..58dd61e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ mod actions; pub mod agenda; pub mod bors; +mod cache; mod changelogs; mod config; pub mod db; diff --git a/src/main.rs b/src/main.rs index 2cc0f406..340bcb45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ use tower_http::compression::CompressionLayer; use tower_http::request_id::{MakeRequestUuid, PropagateRequestIdLayer, SetRequestIdLayer}; use tower_http::trace::TraceLayer; use tracing::{self as log, info_span}; -use triagebot::gh_comments::GitHubCommentsCache; +use triagebot::gh_comments::{GH_COMMENTS_CACHE_CAPACITY_BYTES, GitHubCommentsCache}; use triagebot::gha_logs::GitHubActionLogsCache; use triagebot::handlers::Context; use triagebot::handlers::pr_tracking::ReviewerWorkqueue; @@ -97,7 +97,9 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> { octocrab: oc, workqueue: Arc::new(RwLock::new(workqueue)), gha_logs: Arc::new(RwLock::new(GitHubActionLogsCache::default())), - gh_comments: Arc::new(RwLock::new(GitHubCommentsCache::default())), + gh_comments: Arc::new(RwLock::new(GitHubCommentsCache::new( + GH_COMMENTS_CACHE_CAPACITY_BYTES, + ))), zulip, }); From 5d041180738acb2c4b87b84413dc13c8b687d289 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 20:45:31 +0100 Subject: [PATCH 3/8] Make GHA Logs use our `LeastRecentlyUsedCache` --- src/gha_logs.rs | 47 ++++++----------------------------------------- src/main.rs | 6 ++++-- 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/src/gha_logs.rs b/src/gha_logs.rs index 0051ad8e..e3b70592 100644 --- a/src/gha_logs.rs +++ b/src/gha_logs.rs @@ -1,3 +1,4 @@ +use crate::cache; use crate::errors::AppError; use crate::github::{self, WorkflowRunJob}; use crate::handlers::Context; @@ -9,7 +10,6 @@ use axum::http::HeaderValue; use axum::response::IntoResponse; use hyper::header::{CONTENT_SECURITY_POLICY, CONTENT_TYPE}; use hyper::{HeaderMap, StatusCode}; -use std::collections::VecDeque; use std::sync::Arc; use uuid::Uuid; @@ -18,13 +18,9 @@ pub const ANSI_UP_URL: &str = "/gha_logs/ansi_up@0.0.1-custom.js"; pub const SUCCESS_URL: &str = "/gha_logs/success@1.svg"; pub const FAILURE_URL: &str = "/gha_logs/failure@1.svg"; -const MAX_CACHE_CAPACITY_BYTES: u64 = 50 * 1024 * 1024; // 50 Mb +pub const GHA_LOGS_CACHE_CAPACITY_BYTES: usize = 50 * 1024 * 1024; // 50 Mb -#[derive(Default)] -pub struct GitHubActionLogsCache { - capacity: u64, - entries: VecDeque<(String, Arc)>, -} +pub type GitHubActionLogsCache = cache::LeastRecentlyUsedCache; pub struct CachedLog { job: WorkflowRunJob, @@ -32,40 +28,9 @@ pub struct CachedLog { logs: String, } -impl GitHubActionLogsCache { - pub fn get(&mut self, key: &str) -> Option> { - if let Some(pos) = self.entries.iter().position(|(k, _)| k == key) { - // Move previously cached entry to the front - let entry = self.entries.remove(pos).unwrap(); - self.entries.push_front(entry.clone()); - Some(entry.1) - } else { - None - } - } - - pub fn put(&mut self, key: String, value: Arc) -> Arc { - if value.logs.len() as u64 > MAX_CACHE_CAPACITY_BYTES { - // Entry is too large, don't cache, return as is - return value; - } - - // Remove duplicate or last entry when necessary - let removed = if let Some(pos) = self.entries.iter().position(|(k, _)| k == &key) { - self.entries.remove(pos) - } else if self.capacity + value.logs.len() as u64 >= MAX_CACHE_CAPACITY_BYTES { - self.entries.pop_back() - } else { - None - }; - if let Some(removed) = removed { - self.capacity -= removed.1.logs.len() as u64; - } - - // Add entry the front of the list ane return it - self.capacity += value.logs.len() as u64; - self.entries.push_front((key, value.clone())); - value +impl cache::EstimatedSize for CachedLog { + fn estimated_size(&self) -> usize { + std::mem::size_of::() + self.tree_roots.len() + self.logs.len() } } diff --git a/src/main.rs b/src/main.rs index 340bcb45..471cd3dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ use tower_http::request_id::{MakeRequestUuid, PropagateRequestIdLayer, SetReques use tower_http::trace::TraceLayer; use tracing::{self as log, info_span}; use triagebot::gh_comments::{GH_COMMENTS_CACHE_CAPACITY_BYTES, GitHubCommentsCache}; -use triagebot::gha_logs::GitHubActionLogsCache; +use triagebot::gha_logs::{GHA_LOGS_CACHE_CAPACITY_BYTES, GitHubActionLogsCache}; use triagebot::handlers::Context; use triagebot::handlers::pr_tracking::ReviewerWorkqueue; use triagebot::handlers::pr_tracking::load_workqueue; @@ -96,7 +96,9 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> { team: team_api, octocrab: oc, workqueue: Arc::new(RwLock::new(workqueue)), - gha_logs: Arc::new(RwLock::new(GitHubActionLogsCache::default())), + gha_logs: Arc::new(RwLock::new(GitHubActionLogsCache::new( + GHA_LOGS_CACHE_CAPACITY_BYTES, + ))), gh_comments: Arc::new(RwLock::new(GitHubCommentsCache::new( GH_COMMENTS_CACHE_CAPACITY_BYTES, ))), From 07eb8408deeecc8c859c66580f0b052c8f4b75c0 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 20:49:53 +0100 Subject: [PATCH 4/8] Add alias for our GH Comment endpoint to simplify access from GitHub url --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 471cd3dc..05cee624 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,7 +205,11 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> { get(triagebot::gh_changes_since::gh_changes_since), ) .route( - "/gh-comments/{owner}/{repo}/{pr}", + "/gh-comments/{owner}/{repo}/{issue}", + get(triagebot::gh_comments::gh_comments), + ) + .route( + "/gh-comments/{owner}/{repo}/issues/{issue}", get(triagebot::gh_comments::gh_comments), ) .layer(GovernorLayer::new(ratelimit_config)); From 7b5fad7a0f900766d22234e765d2ea1719aea69c Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 20:52:34 +0100 Subject: [PATCH 5/8] Add message about pull-requests being not yet supported --- src/gh_comments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gh_comments.rs b/src/gh_comments.rs index 69d8c577..e4f336b9 100644 --- a/src/gh_comments.rs +++ b/src/gh_comments.rs @@ -74,7 +74,7 @@ pub async fn gh_comments( .github .issue_with_comments(&owner, &repo, issue_id) .await - .context("unable to fetch the issue and it's comments")?; + .context("unable to fetch the issue and it's comments (PRs are not yet supported)")?; let duration = start.elapsed(); let duration_secs = duration.as_secs_f64(); From 958c54725ab298ee0ada08b6d6bb30e85a8ff435 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 23:07:59 +0100 Subject: [PATCH 6/8] Regenerate our copy of GitHub's Markdown css --- src/gh_comments.rs | 4 +- ...5.8.1.css => github-markdown@20260115.css} | 472 +++++++++++++++--- 2 files changed, 393 insertions(+), 83 deletions(-) rename src/gh_comments/{github-markdown@5.8.1.css => github-markdown@20260115.css} (77%) diff --git a/src/gh_comments.rs b/src/gh_comments.rs index e4f336b9..020e8849 100644 --- a/src/gh_comments.rs +++ b/src/gh_comments.rs @@ -26,7 +26,7 @@ use crate::{ }; pub const STYLE_URL: &str = "/gh-comments/style@0.0.1.css"; -pub const MARKDOWN_URL: &str = "/gh-comments/github-markdown@5.8.1.css"; +pub const MARKDOWN_URL: &str = "/gh-comments/github-markdown@20260115.css"; pub const GH_COMMENTS_CACHE_CAPACITY_BYTES: usize = 35 * 1024 * 1024; // 35 Mb @@ -199,7 +199,7 @@ pub async fn style_css() -> impl IntoResponse { } pub async fn markdown_css() -> impl IntoResponse { - const MARKDOWN_CSS: &str = include_str!("gh_comments/github-markdown@5.8.1.css"); + const MARKDOWN_CSS: &str = include_str!("gh_comments/github-markdown@20260115.css"); (immutable_headers("text/css; charset=utf-8"), MARKDOWN_CSS) } diff --git a/src/gh_comments/github-markdown@5.8.1.css b/src/gh_comments/github-markdown@20260115.css similarity index 77% rename from src/gh_comments/github-markdown@5.8.1.css rename to src/gh_comments/github-markdown@20260115.css index 47712e2b..9c8f134a 100644 --- a/src/gh_comments/github-markdown@5.8.1.css +++ b/src/gh_comments/github-markdown@20260115.css @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT */ /** - * https://github.com/sindresorhus/github-markdown-css + * https://github.com/sindresorhus/generate-github-markdown-css * * MIT License * @@ -14,137 +14,153 @@ */ .markdown-body { - --base-size-4: 0.25rem; - --base-size-8: 0.5rem; --base-size-16: 1rem; --base-size-24: 1.5rem; + --base-size-4: 0.25rem; --base-size-40: 2.5rem; - --base-text-weight-normal: 400; + --base-size-8: 0.5rem; --base-text-weight-medium: 500; + --base-text-weight-normal: 400; --base-text-weight-semibold: 600; + --borderRadius-full: 624.9375rem; + --borderRadius-medium: 0.375rem; + --borderWidth-thin: 0.0625rem; + --stack-padding-condensed: 0.5rem; + --stack-padding-normal: 1rem; --fontStack-monospace: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace; + --fontStack-sansSerif: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; + --h6-size: 0.75rem; --fgColor-accent: Highlight; } @media (prefers-color-scheme: dark) { .markdown-body, [data-theme="dark"] { - /* dark */ + /*dark */ color-scheme: dark; - --focus-outlineColor: #1f6feb; - --fgColor-default: #f0f6fc; - --fgColor-muted: #9198a1; --fgColor-accent: #4493f8; - --fgColor-success: #3fb950; - --fgColor-attention: #d29922; - --fgColor-danger: #f85149; - --fgColor-done: #ab7df8; + --bgColor-attention-muted: #bb800926; --bgColor-default: #0d1117; --bgColor-muted: #151b23; --bgColor-neutral-muted: #656c7633; - --bgColor-attention-muted: #bb800926; - --borderColor-default: #3d444d; - --borderColor-muted: #3d444db3; - --borderColor-neutral-muted: #3d444db3; --borderColor-accent-emphasis: #1f6feb; - --borderColor-success-emphasis: #238636; --borderColor-attention-emphasis: #9e6a03; + --borderColor-attention-muted: #bb800966; --borderColor-danger-emphasis: #da3633; + --borderColor-default: #3d444d; --borderColor-done-emphasis: #8957e5; + --borderColor-success-emphasis: #238636; + --color-prettylights-syntax-brackethighlighter-angle: #9198a1; + --color-prettylights-syntax-brackethighlighter-unmatched: #f85149; + --color-prettylights-syntax-carriage-return-bg: #b62324; + --color-prettylights-syntax-carriage-return-text: #f0f6fc; --color-prettylights-syntax-comment: #9198a1; --color-prettylights-syntax-constant: #79c0ff; --color-prettylights-syntax-constant-other-reference-link: #a5d6ff; --color-prettylights-syntax-entity: #d2a8ff; - --color-prettylights-syntax-storage-modifier-import: #f0f6fc; --color-prettylights-syntax-entity-tag: #7ee787; --color-prettylights-syntax-keyword: #ff7b72; - --color-prettylights-syntax-string: #a5d6ff; - --color-prettylights-syntax-variable: #ffa657; - --color-prettylights-syntax-brackethighlighter-unmatched: #f85149; - --color-prettylights-syntax-brackethighlighter-angle: #9198a1; - --color-prettylights-syntax-invalid-illegal-text: #f0f6fc; - --color-prettylights-syntax-invalid-illegal-bg: #8e1519; - --color-prettylights-syntax-carriage-return-text: #f0f6fc; - --color-prettylights-syntax-carriage-return-bg: #b62324; - --color-prettylights-syntax-string-regexp: #7ee787; - --color-prettylights-syntax-markup-list: #f2cc60; - --color-prettylights-syntax-markup-heading: #1f6feb; - --color-prettylights-syntax-markup-italic: #f0f6fc; --color-prettylights-syntax-markup-bold: #f0f6fc; - --color-prettylights-syntax-markup-deleted-text: #ffdcd7; - --color-prettylights-syntax-markup-deleted-bg: #67060c; - --color-prettylights-syntax-markup-inserted-text: #aff5b4; - --color-prettylights-syntax-markup-inserted-bg: #033a16; - --color-prettylights-syntax-markup-changed-text: #ffdfb6; --color-prettylights-syntax-markup-changed-bg: #5a1e02; - --color-prettylights-syntax-markup-ignored-text: #f0f6fc; + --color-prettylights-syntax-markup-changed-text: #ffdfb6; + --color-prettylights-syntax-markup-deleted-bg: #67060c; + --color-prettylights-syntax-markup-deleted-text: #ffdcd7; + --color-prettylights-syntax-markup-heading: #1f6feb; --color-prettylights-syntax-markup-ignored-bg: #1158c7; + --color-prettylights-syntax-markup-ignored-text: #f0f6fc; + --color-prettylights-syntax-markup-inserted-bg: #033a16; + --color-prettylights-syntax-markup-inserted-text: #aff5b4; + --color-prettylights-syntax-markup-italic: #f0f6fc; + --color-prettylights-syntax-markup-list: #f2cc60; --color-prettylights-syntax-meta-diff-range: #d2a8ff; + --color-prettylights-syntax-storage-modifier-import: #f0f6fc; + --color-prettylights-syntax-string: #a5d6ff; + --color-prettylights-syntax-string-regexp: #7ee787; --color-prettylights-syntax-sublimelinter-gutter-mark: #3d444d; + --color-prettylights-syntax-variable: #ffa657; + --fgColor-attention: #d29922; + --fgColor-danger: #f85149; + --fgColor-default: #f0f6fc; + --fgColor-done: #ab7df8; + --fgColor-muted: #9198a1; + --fgColor-success: #3fb950; + --borderColor-muted: #3d444db3; + --color-prettylights-syntax-invalid-illegal-bg: var(--bgColor-danger-muted); + --color-prettylights-syntax-invalid-illegal-text: var(--fgColor-danger); + --focus-outlineColor: var(--borderColor-accent-emphasis); + --selection-bgColor: #1f6febb3; + --borderColor-neutral-muted: var(--borderColor-muted); } } @media (prefers-color-scheme: light) { .markdown-body, [data-theme="light"] { - /* light */ + /*light */ color-scheme: light; - --focus-outlineColor: #0969da; - --fgColor-default: #1f2328; - --fgColor-muted: #59636e; - --fgColor-accent: #0969da; - --fgColor-success: #1a7f37; - --fgColor-attention: #9a6700; --fgColor-danger: #d1242f; - --fgColor-done: #8250df; - --bgColor-default: #ffffff; + --bgColor-attention-muted: #fff8c5; --bgColor-muted: #f6f8fa; --bgColor-neutral-muted: #818b981f; - --bgColor-attention-muted: #fff8c5; - --borderColor-default: #d1d9e0; - --borderColor-muted: #d1d9e0b3; - --borderColor-neutral-muted: #d1d9e0b3; --borderColor-accent-emphasis: #0969da; - --borderColor-success-emphasis: #1a7f37; --borderColor-attention-emphasis: #9a6700; + --borderColor-attention-muted: #d4a72c66; --borderColor-danger-emphasis: #cf222e; + --borderColor-default: #d1d9e0; --borderColor-done-emphasis: #8250df; + --borderColor-success-emphasis: #1a7f37; + --color-prettylights-syntax-brackethighlighter-angle: #59636e; + --color-prettylights-syntax-brackethighlighter-unmatched: #82071e; + --color-prettylights-syntax-carriage-return-bg: #cf222e; + --color-prettylights-syntax-carriage-return-text: #f6f8fa; --color-prettylights-syntax-comment: #59636e; --color-prettylights-syntax-constant: #0550ae; --color-prettylights-syntax-constant-other-reference-link: #0a3069; --color-prettylights-syntax-entity: #6639ba; - --color-prettylights-syntax-storage-modifier-import: #1f2328; --color-prettylights-syntax-entity-tag: #0550ae; + --color-prettylights-syntax-invalid-illegal-text: var(--fgColor-danger); --color-prettylights-syntax-keyword: #cf222e; - --color-prettylights-syntax-string: #0a3069; - --color-prettylights-syntax-variable: #953800; - --color-prettylights-syntax-brackethighlighter-unmatched: #82071e; - --color-prettylights-syntax-brackethighlighter-angle: #59636e; - --color-prettylights-syntax-invalid-illegal-text: #f6f8fa; - --color-prettylights-syntax-invalid-illegal-bg: #82071e; - --color-prettylights-syntax-carriage-return-text: #f6f8fa; - --color-prettylights-syntax-carriage-return-bg: #cf222e; - --color-prettylights-syntax-string-regexp: #116329; - --color-prettylights-syntax-markup-list: #3b2300; - --color-prettylights-syntax-markup-heading: #0550ae; - --color-prettylights-syntax-markup-italic: #1f2328; - --color-prettylights-syntax-markup-bold: #1f2328; - --color-prettylights-syntax-markup-deleted-text: #82071e; - --color-prettylights-syntax-markup-deleted-bg: #ffebe9; - --color-prettylights-syntax-markup-inserted-text: #116329; - --color-prettylights-syntax-markup-inserted-bg: #dafbe1; - --color-prettylights-syntax-markup-changed-text: #953800; --color-prettylights-syntax-markup-changed-bg: #ffd8b5; - --color-prettylights-syntax-markup-ignored-text: #d1d9e0; + --color-prettylights-syntax-markup-changed-text: #953800; + --color-prettylights-syntax-markup-deleted-bg: #ffebe9; + --color-prettylights-syntax-markup-deleted-text: #82071e; + --color-prettylights-syntax-markup-heading: #0550ae; --color-prettylights-syntax-markup-ignored-bg: #0550ae; + --color-prettylights-syntax-markup-ignored-text: #d1d9e0; + --color-prettylights-syntax-markup-inserted-bg: #dafbe1; + --color-prettylights-syntax-markup-inserted-text: #116329; + --color-prettylights-syntax-markup-list: #3b2300; --color-prettylights-syntax-meta-diff-range: #8250df; + --color-prettylights-syntax-string: #0a3069; + --color-prettylights-syntax-string-regexp: #116329; --color-prettylights-syntax-sublimelinter-gutter-mark: #818b98; + --color-prettylights-syntax-variable: #953800; + --fgColor-accent: #0969da; + --fgColor-attention: #9a6700; + --fgColor-done: #8250df; + --fgColor-muted: #59636e; + --fgColor-success: #1a7f37; + --bgColor-default: #ffffff; + --borderColor-muted: #d1d9e0b3; + --color-prettylights-syntax-invalid-illegal-bg: var(--bgColor-danger-muted); + --color-prettylights-syntax-markup-bold: #1f2328; + --color-prettylights-syntax-markup-italic: #1f2328; + --color-prettylights-syntax-storage-modifier-import: #1f2328; + --fgColor-default: #1f2328; + --focus-outlineColor: var(--borderColor-accent-emphasis); + --selection-bgColor: #0969da33; + --borderColor-neutral-muted: var(--borderColor-muted); } } .markdown-body { + /** Ideal for movement that starts on the page and ends off the page. */ + /** Ideal for movement that starts and ends on the page. */ + /** Ideal for movement that starts off the page and ends on the page. */ + /** Ideal for non-movement properties, like opacity or background color. */ -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; margin: 0; + font-weight: var(--base-text-weight-normal, 400); color: var(--fgColor-default); background-color: var(--bgColor-default); - font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; + font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"); font-size: 16px; line-height: 1.5; word-wrap: break-word; @@ -186,7 +202,7 @@ } .markdown-body a { - background-color: transparent; + background-color: rgba(0,0,0,0); color: var(--fgColor-accent); text-decoration: none; } @@ -260,7 +276,7 @@ .markdown-body hr { box-sizing: content-box; overflow: hidden; - background: transparent; + background: rgba(0,0,0,0); border-bottom: 1px solid var(--borderColor-muted); height: .25em; padding: 0; @@ -365,7 +381,7 @@ .markdown-body [role=button]:focus:not(:focus-visible), .markdown-body input[type=radio]:focus:not(:focus-visible), .markdown-body input[type=checkbox]:focus:not(:focus-visible) { - outline: solid 1px transparent; + outline: solid 1px rgba(0,0,0,0); } .markdown-body a:focus-visible, @@ -497,16 +513,102 @@ fill: currentColor; } +.markdown-body .Box-body.scrollable-overlay { + max-height: 400px; + overflow-y: scroll; +} + +.markdown-body .Box-body .help { + padding-top: var(--base-size-8); + margin: 0; + color: var(--fgColor-muted); + text-align: center; +} + .markdown-body input::-webkit-outer-spin-button, .markdown-body input::-webkit-inner-spin-button { margin: 0; appearance: none; } +.markdown-body .border { + border: var(--borderWidth-thin, 1px) solid var(--borderColor-default) !important; +} + +.markdown-body .border-0 { + border: 0 !important; +} + +.markdown-body .circle { + border-radius: var(--borderRadius-full, 50%) !important; +} + +.markdown-body .color-fg-muted { + color: var(--fgColor-muted) !important; +} + +.markdown-body .color-bg-default { + background-color: var(--bgColor-default) !important; +} + +.markdown-body .color-border-subtle { + border-color: var(--borderColor-muted) !important; +} + +.markdown-body .mb-0 { + margin-bottom: 0 !important; +} + +.markdown-body .ml-1 { + margin-left: var(--base-size-4, 4px) !important; +} + .markdown-body .mr-2 { margin-right: var(--base-size-8, 8px) !important; } +.markdown-body .my-2 { + margin-top: var(--base-size-8, 8px) !important; + margin-bottom: var(--base-size-8, 8px) !important; +} + +.markdown-body .p-0 { + padding: 0 !important; +} + +.markdown-body .py-0 { + padding-top: 0 !important; + padding-bottom: 0 !important; +} + +.markdown-body .px-3 { + padding-right: var(--base-size-16, 16px) !important; + padding-left: var(--base-size-16, 16px) !important; +} + +.markdown-body .f6 { + font-size: var(--h6-size, 12px) !important; +} + +.markdown-body .text-bold { + font-weight: var(--base-text-weight-semibold, 600) !important; +} + +.markdown-body .d-inline-block { + display: inline-block !important; +} + +.markdown-body .sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + overflow: hidden; + clip-path: rect(0 0 0 0); + overflow-wrap: normal; + border: 0; +} + .markdown-body::before { display: table; content: ""; @@ -722,7 +824,7 @@ } .markdown-body table img { - background-color: transparent; + background-color: rgba(0,0,0,0); } .markdown-body img[align=right] { @@ -736,7 +838,7 @@ .markdown-body .emoji { max-width: none; vertical-align: text-top; - background-color: transparent; + background-color: rgba(0,0,0,0); } .markdown-body span.frame { @@ -859,7 +961,7 @@ margin: 0; word-break: normal; white-space: pre; - background: transparent; + background: rgba(0,0,0,0); border: 0; } @@ -886,13 +988,12 @@ .markdown-body pre code, .markdown-body pre tt { display: inline; - max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; - background-color: transparent; + background-color: rgba(0,0,0,0); border: 0; } @@ -971,8 +1072,48 @@ font-family: monospace; } -.markdown-body body:has(:modal) { - padding-right: var(--dialog-scrollgutter) !important; +.markdown-body .Box { + background-color: var(--bgColor-default); + border-color: var(--borderColor-default); + border-radius: var(--borderRadius-medium); + border-style: solid; + border-width: var(--borderWidth-thin); +} + +.markdown-body .Box--condensed { + line-height: 1.25; +} + +.markdown-body .Box--condensed .Box-body, +.markdown-body .Box--condensed .Box-footer, +.markdown-body .Box--condensed .Box-header { + padding: var(--stack-padding-condensed) var(--stack-padding-normal); +} + +.markdown-body .Box--condensed .Box-row { + padding: var(--stack-padding-condensed) var(--stack-padding-normal); +} + +.markdown-body .Box-header { + background-color: var(--bgColor-muted); + border-color: var(--borderColor-default); + border-style: solid; + border-top-left-radius: var(--borderRadius-medium); + border-top-right-radius: var(--borderRadius-medium); + border-width: var(--borderWidth-thin); + margin: calc(var(--borderWidth-thin)*-1) calc(var(--borderWidth-thin)*-1) 0; + padding: var(--stack-padding-normal); +} + +.markdown-body .Box-body { + border-bottom: var(--borderWidth-thin) solid var(--borderColor-default); + padding: var(--stack-padding-normal); +} + +.markdown-body .Box-body:last-of-type { + border-bottom-left-radius: var(--borderRadius-medium); + border-bottom-right-radius: var(--borderRadius-medium); + margin-bottom: calc(var(--borderWidth-thin)*-1); } .markdown-body .pl-c { @@ -1125,6 +1266,119 @@ height: 1em; } +.markdown-body .commit-tease-sha { + display: inline-block; + font-family: var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace); + font-size: 90%; + color: var(--fgColor-default); +} + +.markdown-body .blob-wrapper { + overflow-x: auto; + overflow-y: hidden; +} + +.markdown-body .blob-wrapper table tr:nth-child(2n) { + background-color: rgba(0,0,0,0); +} + +.markdown-body .blob-wrapper-embedded { + max-height: 240px; + overflow-y: auto; +} + +.markdown-body .blob-num { + position: relative; + width: 1%; + min-width: 50px; + padding-right: 10px; + padding-left: 10px; + font-family: var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace); + font-size: 12px; + line-height: 20px; + color: var(--fgColor-muted); + text-align: right; + white-space: nowrap; + vertical-align: top; + cursor: pointer; + -webkit-user-select: none; + user-select: none; +} + +.markdown-body .blob-num:hover { + color: var(--fgColor-default); +} + +.markdown-body .blob-num::before { + content: attr(data-line-number); +} + +.markdown-body .blob-num.non-expandable { + cursor: default; +} + +.markdown-body .blob-num.non-expandable:hover { + color: var(--fgColor-muted); +} + +.markdown-body .blob-code { + position: relative; + padding-right: 10px; + padding-left: 10px; + line-height: 20px; + vertical-align: top; +} + +.markdown-body .blob-code-inner { + display: table-cell; + overflow: visible; + font-family: var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace); + font-size: 12px; + color: var(--fgColor-default); + word-wrap: anywhere; + white-space: pre; +} + +.markdown-body .blob-code-inner .x-first { + border-top-left-radius: .2em; + border-bottom-left-radius: .2em; +} + +.markdown-body .blob-code-inner .x-last { + border-top-right-radius: .2em; + border-bottom-right-radius: .2em; +} + +.markdown-body .blob-code-inner.highlighted, +.markdown-body .blob-code-inner .highlighted { + background-color: var(--bgColor-attention-muted); + box-shadow: inset 2px 0 0 var(--borderColor-attention-muted); +} + +.markdown-body .blob-code-inner::selection, +.markdown-body .blob-code-inner *::selection { + background-color: var(--selection-bgColor); +} + +.markdown-body .blob-code-inner.blob-code-addition, +.markdown-body .blob-code-inner.blob-code-deletion { + position: relative; + padding-left: 22px !important; +} + +.markdown-body a:has(>p,>div,>pre,>blockquote) { + display: block; +} + +.markdown-body a:has(>p,>div,>pre,>blockquote):not(:has(.snippet-clipboard-content,>pre)) { + width: fit-content; +} + +.markdown-body a:has(>p,>div,>pre,>blockquote):has(.snippet-clipboard-content,>pre):focus-visible { + outline: 2px solid var(--focus-outlineColor); + outline-offset: 2px; +} + .markdown-body .task-list-item { list-style-type: none; } @@ -1237,6 +1491,62 @@ margin-top: 0 !important; } +.markdown-body .tab-size[data-tab-size="1"] { + tab-size: 1; +} + +.markdown-body .tab-size[data-tab-size="2"] { + tab-size: 2; +} + +.markdown-body .tab-size[data-tab-size="3"] { + tab-size: 3; +} + +.markdown-body .tab-size[data-tab-size="4"] { + tab-size: 4; +} + +.markdown-body .tab-size[data-tab-size="5"] { + tab-size: 5; +} + +.markdown-body .tab-size[data-tab-size="6"] { + tab-size: 6; +} + +.markdown-body .tab-size[data-tab-size="7"] { + tab-size: 7; +} + +.markdown-body .tab-size[data-tab-size="8"] { + tab-size: 8; +} + +.markdown-body .tab-size[data-tab-size="9"] { + tab-size: 9; +} + +.markdown-body .tab-size[data-tab-size="10"] { + tab-size: 10; +} + +.markdown-body .tab-size[data-tab-size="11"] { + tab-size: 11; +} + +.markdown-body .tab-size[data-tab-size="12"] { + tab-size: 12; +} + +.markdown-body .Box .section-focus .preview-section { + display: none; +} + +.markdown-body .Box .section-focus .edit-section { + display: block; +} + .markdown-body .highlight pre:has(+.zeroclipboard-container) { min-height: 52px; } From 1d3c367780e641dbd9a1aaec198e4eb0394a8d73 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 15 Jan 2026 23:11:16 +0100 Subject: [PATCH 7/8] Allow inline style attributes to fix CSP violations in GH comments --- src/gh_comments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gh_comments.rs b/src/gh_comments.rs index 020e8849..4433b653 100644 --- a/src/gh_comments.rs +++ b/src/gh_comments.rs @@ -185,7 +185,7 @@ pub async fn gh_comments( headers.insert( CONTENT_SECURITY_POLICY, HeaderValue::from_static( - "default-src 'none'; script-src 'nonce-triagebot-gh-comments'; style-src 'self'; img-src *", + "default-src 'none'; script-src 'nonce-triagebot-gh-comments'; style-src 'self' 'unsafe-inline'; img-src *", ), ); From 7416964242d6d2aa51f4069965ed7756f361d728 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 16 Jan 2026 07:40:47 +0100 Subject: [PATCH 8/8] Use a more reasonable font-size like GitHub --- src/gh_comments/github-markdown@20260115.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gh_comments/github-markdown@20260115.css b/src/gh_comments/github-markdown@20260115.css index 9c8f134a..99e4e877 100644 --- a/src/gh_comments/github-markdown@20260115.css +++ b/src/gh_comments/github-markdown@20260115.css @@ -161,7 +161,7 @@ color: var(--fgColor-default); background-color: var(--bgColor-default); font-family: var(--fontStack-sansSerif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"); - font-size: 16px; + font-size: 14px; line-height: 1.5; word-wrap: break-word; }