Skip to content

Commit 3c5dc1b

Browse files
authored
Merge branch 'master' into feat/g502-hero-support
2 parents dac50ea + aec0dee commit 3c5dc1b

8 files changed

Lines changed: 383 additions & 80 deletions

File tree

‎.agents/rules/ci.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,12 @@ warning that host clippy `-D warnings` does not surface still fails CI.
166166
CI always sets `CARGO_TERM_COLOR=always`, `CARGO_INCREMENTAL=0`, and
167167
`RUSTFLAGS=-D warnings`. Compilation jobs also set `RUSTC_WRAPPER=sccache`;
168168
`cargo-deny` clears it because metadata probes rustc without compiling and the
169-
job deliberately skips sccache setup. `rust-cache` stores only Cargo registry/git
170-
inputs (`cache-targets: false`); sccache owns compiler outputs. PRs read the
169+
job deliberately skips sccache setup. The Linux `clippy`, `MSRV`, `rustdoc`, and
170+
`tests (linux)` jobs keep Cargo's registry, git sources, and `target/` on a
171+
per-job Namespace cache volume that only a push to master commits; each empties
172+
`target/` once it passes `CACHED_TARGET_LIMIT_MB`, because Cargo never prunes it.
173+
In the other jobs `rust-cache` stores only Cargo registry/git inputs
174+
(`cache-targets: false`). sccache owns compiler outputs everywhere. PRs read the
171175
default branch's sccache objects but do not write their isolated merge-ref cache.
172176

173177
The `fmt` job selects all workspace test jobs with the path filter in `ci.yml`. Source, fixture, test-resource, dependency, toolchain, and CI changes run those jobs; pure Markdown and unrelated design assets skip them. The workflow still reports each skipped job, so required checks do not remain pending. PRs use the full PR diff; pushes use the full pushed range. Local test commands always run, regardless of changed paths.

‎.github/workflows/ci.yml‎

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ env:
2525
# 10 GB allowance. Let PRs reuse master's compiler objects without filling
2626
# the cache with entries no other PR can read.
2727
SCCACHE_GHA_RW_MODE: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'READ_WRITE' || 'READ_ONLY' }}
28+
# Cargo never deletes a stale artifact, so a cached target/ only grows. The
29+
# cache-volume jobs empty it past this size: the volume is the default
30+
# 20 GB, and it also holds about 2 GB of registry and git sources plus up to
31+
# 6 GB that one cold build adds.
32+
CACHED_TARGET_LIMIT_MB: 10240
2833

2934
# Runners: every job runs on Namespace (namespace.so), which sponsors
3035
# OpenLogi's CI. Labels pick the shape: 2x4 for jobs that compile nothing,
@@ -33,8 +38,17 @@ env:
3338
# so the macOS x86_64 tests run on Apple Silicon under Rosetta 2.
3439
#
3540
# Cache policy:
36-
# - rust-cache keeps Cargo's registry/git inputs only; caching target/ produced
37-
# 0.8-1.4 GB archives whose transfer often cost more than the cache saved.
41+
# - The Linux compile jobs (clippy, MSRV, rustdoc, tests) each attach their own
42+
# Namespace cache volume, tagged per job because a shared one would be
43+
# overwritten by whichever job finished last. nscloud-cache-action keeps
44+
# Cargo's registry, git sources and target/ on it, so unchanged dependencies
45+
# are fresh and never reach rustc. Only a push to master commits the volume:
46+
# every other run gets nscloud-cache-exp-do-not-commit, because a fork's PR
47+
# branch can be called master too.
48+
# - rust-cache keeps Cargo's registry/git inputs only for the other jobs;
49+
# caching target/ through the GitHub cache produced 0.8-1.4 GB archives
50+
# whose transfer often cost more than the cache saved. publish closure and
51+
# wasm still save the linux-stable-debug key that stale-allows.yml restores.
3852
# - sccache stores compiler outputs individually, so jobs fetch only objects
3953
# they need and can share unchanged dependencies across Cargo commands.
4054
# - only master/main writes CI caches; PR-scoped entries cannot warm other PRs.
@@ -150,7 +164,10 @@ jobs:
150164
clippy:
151165
name: clippy
152166
# Peaked at 86% of 16 GB on 8x16, the most of any Linux job in this file.
153-
runs-on: nscloud-ubuntu-24.04-amd64-8x32
167+
runs-on:
168+
- nscloud-ubuntu-24.04-amd64-8x32-with-cache
169+
- nscloud-cache-tag-openlogi-clippy
170+
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 'nscloud-cache-allow-commit-from-master' || 'nscloud-cache-exp-do-not-commit' }}
154171
steps:
155172
- uses: actions/checkout@v7
156173
- uses: dtolnay/rust-toolchain@stable
@@ -159,12 +176,11 @@ jobs:
159176
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
160177
with:
161178
version: "v0.16.0"
162-
- uses: Swatinem/rust-cache@v2
179+
- uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
163180
with:
164-
prefix-key: v2-cargo
165-
shared-key: linux-stable-debug
166-
cache-targets: false
167-
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
181+
cache: rust
182+
- name: Bound the cached target directory
183+
run: if [ "$(du -sm target | cut -f1)" -gt "$CACHED_TARGET_LIMIT_MB" ]; then find target -mindepth 1 -delete; fi
168184
- run: |
169185
sudo apt-get update
170186
sudo apt-get install -y \
@@ -199,17 +215,20 @@ jobs:
199215
runner: nscloud-macos-tahoe-arm64-6x14
200216
# 32 GB: on 8x16 a rustc in this check was killed by signal 9.
201217
- os: linux
202-
runner: nscloud-ubuntu-24.04-amd64-8x32
218+
runner:
219+
- nscloud-ubuntu-24.04-amd64-8x32-with-cache
220+
- nscloud-cache-tag-openlogi-msrv-linux
221+
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 'nscloud-cache-allow-commit-from-master' || 'nscloud-cache-exp-do-not-commit' }}
203222
steps:
204223
- uses: actions/checkout@v7
205224
- uses: dtolnay/rust-toolchain@1.99
206225
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
207226
with:
208227
version: "v0.16.0"
209-
- uses: Swatinem/rust-cache@v2
228+
- if: runner.os == 'macOS'
229+
uses: Swatinem/rust-cache@v2
210230
with:
211231
prefix-key: v2-cargo
212-
# Host OS splits Linux vs macOS; the rustc version is already in the key.
213232
shared-key: msrv-debug
214233
cache-targets: false
215234
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
@@ -221,6 +240,13 @@ jobs:
221240
gcc g++ clang libfontconfig-dev libwayland-dev \
222241
libxkbcommon-x11-dev libx11-xcb-dev \
223242
libssl-dev libzstd-dev pkg-config
243+
- if: runner.os == 'Linux'
244+
uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
245+
with:
246+
cache: rust
247+
- if: runner.os == 'Linux'
248+
name: Bound the cached target directory
249+
run: if [ "$(du -sm target | cut -f1)" -gt "$CACHED_TARGET_LIMIT_MB" ]; then find target -mindepth 1 -delete; fi
224250
- run: cargo check --workspace --all-targets
225251

226252
# Stable Linux typecheck is covered by `clippy` above (clippy subsumes
@@ -229,21 +255,21 @@ jobs:
229255

230256
docs:
231257
name: rustdoc (non-GUI crates)
232-
runs-on: nscloud-ubuntu-24.04-amd64-8x16
258+
runs-on:
259+
- nscloud-ubuntu-24.04-amd64-8x16-with-cache
260+
- nscloud-cache-tag-openlogi-rustdoc
261+
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 'nscloud-cache-allow-commit-from-master' || 'nscloud-cache-exp-do-not-commit' }}
233262
steps:
234263
- uses: actions/checkout@v7
235264
- uses: dtolnay/rust-toolchain@stable
236265
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
237266
with:
238267
version: "v0.16.0"
239-
- uses: Swatinem/rust-cache@v2
268+
- uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
240269
with:
241-
prefix-key: v2-cargo
242-
# Share debug deps with clippy/test-linux; RUSTDOCFLAGS is step-scoped
243-
# below so it does not fork the rust-cache env hash.
244-
shared-key: linux-stable-debug
245-
cache-targets: false
246-
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
270+
cache: rust
271+
- name: Bound the cached target directory
272+
run: if [ "$(du -sm target | cut -f1)" -gt "$CACHED_TARGET_LIMIT_MB" ]; then find target -mindepth 1 -delete; fi
247273
- run: |
248274
sudo apt-get update
249275
sudo apt-get install -y \
@@ -273,19 +299,21 @@ jobs:
273299
# A formatting failure must not suppress tests after successful path detection.
274300
if: ${{ !cancelled() && needs.fmt.outputs.tests == 'true' }}
275301
name: tests (linux)
276-
runs-on: nscloud-ubuntu-24.04-amd64-8x16
302+
runs-on:
303+
- nscloud-ubuntu-24.04-amd64-8x16-with-cache
304+
- nscloud-cache-tag-openlogi-tests-linux
305+
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 'nscloud-cache-allow-commit-from-master' || 'nscloud-cache-exp-do-not-commit' }}
277306
steps:
278307
- uses: actions/checkout@v7
279308
- uses: dtolnay/rust-toolchain@stable
280309
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
281310
with:
282311
version: "v0.16.0"
283-
- uses: Swatinem/rust-cache@v2
312+
- uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
284313
with:
285-
prefix-key: v2-cargo
286-
shared-key: linux-stable-debug
287-
cache-targets: false
288-
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
314+
cache: rust
315+
- name: Bound the cached target directory
316+
run: if [ "$(du -sm target | cut -f1)" -gt "$CACHED_TARGET_LIMIT_MB" ]; then find target -mindepth 1 -delete; fi
289317
- run: |
290318
sudo apt-get update
291319
sudo apt-get install -y \

‎.github/workflows/nix.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ jobs:
7373
fail-fast: false
7474
matrix:
7575
# Most of the build is the serial fat-LTO tail of the release
76-
# profile, so 16 vCPUs bought little over 8. Memory peaked at 12 GB,
76+
# profile, so 16 vCPUs bought little over 8. Memory peaked at 14 GB,
7777
# hence 32 GB rather than 16.
7878
include:
7979
- system: x86_64-linux
8080
machine: x86_64
8181
runner: nscloud-ubuntu-24.04-amd64-8x32
8282
- system: aarch64-linux
8383
machine: aarch64
84-
runner: nscloud-ubuntu-24.04-arm64-8x32
84+
runner: nscloud-ubuntu-24.04-arm64-16x32;linux-on-apple-silicon=true
8585
steps:
8686
- name: Checkout
8787
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

‎crates/openlogi-desktop/src/services/assets.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use walkdir::WalkDir;
4343

4444
use self::images::{
4545
buttons_image_for, find_variant_in_manifest, is_drawable_image, load_manifest, metadata_for,
46-
read_png_dimensions, side_image_for, variant_image_for,
46+
read_image_dimensions, side_image_for, variant_image_for,
4747
};
4848
pub(crate) use self::paths::user_cache_root;
4949
use self::paths::{bundle_assets_root, load_index};
@@ -185,7 +185,7 @@ fn resolve_side_view(
185185
.into_iter()
186186
.chain(["side.png".to_string()])
187187
.filter_map(|n| safe_component_path(dir, &n, "asset file").ok())
188-
.find_map(|p| read_png_dimensions(&p).ok().map(|dims| (p, dims)))?;
188+
.find_map(|p| read_image_dimensions(&p).ok().map(|dims| (p, dims)))?;
189189
Some(SideView {
190190
image_path,
191191
png_width,
@@ -431,13 +431,13 @@ impl AssetResolver {
431431
};
432432
let side_view = resolve_side_view(&dir, entry, manifest.as_ref(), ext, &metadata);
433433
let image_path = main_view(image_path, side_view.as_ref(), hero_image_path.as_ref());
434-
let (png_width, png_height) = match read_png_dimensions(&image_path) {
434+
let (png_width, png_height) = match read_image_dimensions(&image_path) {
435435
Ok(dims) => dims,
436436
Err(e) => {
437437
warn!(
438438
path = %image_path.display(),
439439
error = %e,
440-
"could not read PNG dimensions — falling back to metadata origin"
440+
"could not read image dimensions — falling back to metadata origin"
441441
);
442442
let origin = metadata.origin();
443443
(
@@ -503,7 +503,7 @@ impl AssetResolver {
503503
if !image_path.is_file() {
504504
continue;
505505
}
506-
let Ok((png_width, png_height)) = read_png_dimensions(&image_path) else {
506+
let Ok((png_width, png_height)) = read_image_dimensions(&image_path) else {
507507
continue;
508508
};
509509
debug!(

‎crates/openlogi-desktop/src/services/assets/glow.rs‎

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,21 @@ fn load_glow_geometry(dir: &Path) -> Option<GlowGeometry> {
9595
/// transparency (including background reachable through open seams) is
9696
/// "outside" and never glows, which is what keeps the colour inside the
9797
/// silhouette.
98+
///
99+
/// The leading bytes pick the decoder, not the extension: the catalog names
100+
/// many renders by bare UUID, most of them PNG or WebP.
98101
fn compute_glow_geometry(image_path: &Path) -> Option<GlowGeometry> {
99-
let img = image::open(image_path).ok()?.into_rgba8();
102+
let decoded = image::ImageReader::open(image_path)
103+
.and_then(image::ImageReader::with_guessed_format)
104+
.map_err(image::ImageError::from)
105+
.and_then(image::ImageReader::decode);
106+
let img = match decoded {
107+
Ok(img) => img.into_rgba8(),
108+
Err(error) => {
109+
warn!(path = %image_path.display(), %error, "glow: could not decode the render");
110+
return None;
111+
}
112+
};
100113
let (src_w, src_h) = img.dimensions();
101114
if src_w == 0 || src_h == 0 || src_w > MAX_MASK_DIM || src_h > MAX_MASK_DIM {
102115
return None;
@@ -226,6 +239,8 @@ impl GlowGeometry {
226239

227240
#[cfg(test)]
228241
mod tests {
242+
use image::ImageFormat;
243+
229244
use super::*;
230245

231246
#[test]
@@ -271,9 +286,24 @@ mod tests {
271286
assert!(GlowGeometry::from_mask(&mask).is_none());
272287
}
273288

274-
/// Write an RGBA png where `1` cells are solid and the rest fully
275-
/// transparent.
276-
fn write_png(dir: &std::path::Path, name: &str, rows: &[&[u8]]) -> std::path::PathBuf {
289+
/// A ring of opaque pixels around one transparent pixel (a hole), with
290+
/// border-connected transparency everywhere else.
291+
const RING: &[&[u8]] = &[
292+
&[0, 0, 0, 0, 0],
293+
&[0, 1, 1, 1, 0],
294+
&[0, 1, 0, 1, 0],
295+
&[0, 1, 1, 1, 0],
296+
&[0, 0, 0, 0, 0],
297+
];
298+
299+
/// Write an RGBA render in `format` where `1` cells are solid and the rest
300+
/// fully transparent. The format is explicit, so `name` needs no extension.
301+
fn write_render(
302+
dir: &std::path::Path,
303+
name: &str,
304+
format: ImageFormat,
305+
rows: &[&[u8]],
306+
) -> std::path::PathBuf {
277307
let h = u32::try_from(rows.len()).expect("test image height fits u32");
278308
let w = u32::try_from(rows[0].len()).expect("test image width fits u32");
279309
let mut img = image::RgbaImage::new(w, h);
@@ -288,26 +318,14 @@ mod tests {
288318
}
289319
}
290320
let path = dir.join(name);
291-
img.save(&path).expect("write png");
321+
img.save_with_format(&path, format).expect("write render");
292322
path
293323
}
294324

295325
#[test]
296326
fn computed_geometry_finds_only_enclosed_holes() {
297327
let dir = tempfile::tempdir().expect("tempdir");
298-
// A ring of opaque pixels around one transparent pixel (a hole), with
299-
// border-connected transparency everywhere else.
300-
let path = write_png(
301-
dir.path(),
302-
"ring.png",
303-
&[
304-
&[0, 0, 0, 0, 0],
305-
&[0, 1, 1, 1, 0],
306-
&[0, 1, 0, 1, 0],
307-
&[0, 1, 1, 1, 0],
308-
&[0, 0, 0, 0, 0],
309-
],
310-
);
328+
let path = write_render(dir.path(), "ring.png", ImageFormat::Png, RING);
311329
let geom = compute_glow_geometry(&path).expect("hole found");
312330
assert_eq!(geom.segments.len(), 1);
313331
let seg = geom.segments[0];
@@ -316,13 +334,38 @@ mod tests {
316334
assert!((geom.aspect - 1.0).abs() < 1e-6);
317335
}
318336

337+
#[test]
338+
fn computed_geometry_reads_a_render_named_without_an_extension() {
339+
let dir = tempfile::tempdir().expect("tempdir");
340+
// The catalog names renders by bare UUID, e.g. the G316 X's WebP ones.
341+
// WebP decoding reaches this crate through gpui's `image/webp`.
342+
for (name, format) in [
343+
("45a9d07d-91e8-47d6-92b3-f3827d951246", ImageFormat::Png),
344+
("88c7bb4c-5dd5-4a24-b4f4-8141e3ff2972", ImageFormat::WebP),
345+
] {
346+
let path = write_render(dir.path(), name, format, RING);
347+
let segments = compute_glow_geometry(&path).map(|geom| geom.segments.len());
348+
assert_eq!(segments, Some(1), "{format:?} render named {name}");
349+
}
350+
}
351+
352+
#[test]
353+
fn computed_geometry_skips_a_render_no_decoder_reads() {
354+
let dir = tempfile::tempdir().expect("tempdir");
355+
// The head of a G HUB encrypted asset, under a bare UUID name.
356+
let path = dir.path().join("58ee56b0-5ca6-4e7b-b764-2d1746094b78");
357+
std::fs::write(&path, b"!\x05! \x82\0\0\0{\"key-id\": \"ad3e4085\"}").expect("write blob");
358+
assert!(compute_glow_geometry(&path).is_none());
359+
}
360+
319361
#[test]
320362
fn computed_geometry_ignores_border_connected_transparency() {
321363
let dir = tempfile::tempdir().expect("tempdir");
322364
// A C-shape: the notch opens to the border, so nothing is enclosed.
323-
let path = write_png(
365+
let path = write_render(
324366
dir.path(),
325367
"open.png",
368+
ImageFormat::Png,
326369
&[&[1, 1, 1], &[1, 0, 0], &[1, 1, 1]],
327370
);
328371
assert!(compute_glow_geometry(&path).is_none());
@@ -331,7 +374,12 @@ mod tests {
331374
#[test]
332375
fn computed_geometry_skips_fully_opaque_renders() {
333376
let dir = tempfile::tempdir().expect("tempdir");
334-
let path = write_png(dir.path(), "solid.png", &[&[1, 1], &[1, 1]]);
377+
let path = write_render(
378+
dir.path(),
379+
"solid.png",
380+
ImageFormat::Png,
381+
&[&[1, 1], &[1, 1]],
382+
);
335383
assert!(compute_glow_geometry(&path).is_none());
336384
}
337385
}

0 commit comments

Comments
 (0)