fix: CodeGit looked like an empty black box - hardcoded panel height + cache
Reported as "why can't i see anything from codegit its just a black box".
NOT a codegit bug. Verified first, exhaustively, through the authenticated API:
overview 200 940 bytes
log 200 79596 bytes (full commit history)
transfer 200 1460 bytes
config 200 1174 bytes
no JS errors in the console; every DOM helper codegit calls exists.
ROOT CAUSE 1 - a generic CSS rule hardcodes a height
theme/modules/common/_panel.scss -> theme/main.min.css:
panel { ... height: 500px; ... }
That forces EVERY modal panel to a fixed 500px box. Measured live:
#dialog 404px (clamped by max-height:70vh + overflow-y:auto)
#codegit panel 500px, while its content is only 119px
toolbar ("Branch") top 620 vs dialog bottom 490 -> OUTSIDE the modal
So ~380px of the dialog was empty dead space and the Branch line rendered below the
modal, invisible. Fixed to height:auto with max-height:58vh (long content still scrolls):
before: panel 500 -> toolbar top 620, dialog bottom 490 (outside)
after: panel 136 -> toolbar top 256, dialog bottom 279 (inside)
_panel.scss updated too so the source does not contradict the shipped CSS.
ROOT CAUSE 2 - the fix was invisible because of the browser cache
Atheos serves theme/main.min.css and the generated bundles from stable URLs with no cache
headers, so browsers legitimately reuse their cached copy - which is why the first attempt
appeared to do nothing. nginx now sends Cache-Control: no-cache, must-revalidate for
*.css/*.js: caching still works (cheap 304s) but changes are always picked up.
Adds
scripts/fix-panel-layout.sh idempotent re-apply for both fixes (lost on update-atheos)
docs/known-issues.md §4, §5 both findings, with the measurements
Tests (44 passed, 1 failed - the failure is branch protection, a genuine open item)
+ panel must not be fixed at 500px
+ theme CSS must send Cache-Control: no-cache
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
# Re-apply the UI/layout fixes to a rebuilt or updated Atheos tree.
|
||||
#
|
||||
# Why this exists: Atheos has no releases and `scripts/update-atheos.sh` replaces the whole
|
||||
# application directory, so any local patch is lost on update. These are the two that were
|
||||
# needed to make the editor usable. Both are IDEMPOTENT - run it as often as you like.
|
||||
#
|
||||
# 1. panel { height: 500px } -> height:auto; max-height:58vh
|
||||
# Every modal panel was forced to a fixed 500px box, so dialogs with short content showed
|
||||
# a large empty black region and anything after the panel (codegit's "Branch:" toolbar)
|
||||
# was pushed OUTSIDE the modal. See docs/known-issues.md §4.
|
||||
#
|
||||
# 2. nginx: Cache-Control: no-cache for *.css/*.js
|
||||
# Theme/bundle changes were invisible behind the browser cache. §5.
|
||||
#
|
||||
# Usage: sh scripts/fix-panel-layout.sh (run ON the guest, as root)
|
||||
set -e
|
||||
|
||||
ATH=/var/www/atheos
|
||||
CSS=$ATH/theme/main.min.css
|
||||
SCSS=$ATH/theme/modules/common/_panel.scss
|
||||
NGX=/etc/nginx/http.d/atheos.conf
|
||||
|
||||
echo "=== 1. panel layout ==="
|
||||
OLD='height:500px;position:relative;border-left:var(--borderLight)'
|
||||
NEW='height:auto;max-height:58vh;position:relative;border-left:var(--borderLight)'
|
||||
if [ ! -f "$CSS" ]; then
|
||||
echo " !! $CSS not found - is Atheos installed?"
|
||||
elif grep -qF "$NEW" "$CSS"; then
|
||||
echo " already applied"
|
||||
elif grep -qF "$OLD" "$CSS"; then
|
||||
[ -f "$CSS.orig" ] || cp -a "$CSS" "$CSS.orig"
|
||||
php83 -r '$f=$argv[1];$o=$argv[2];$n=$argv[3];$s=file_get_contents($f);
|
||||
if(strpos($s,$o)===false){exit(1);} file_put_contents($f,str_replace($o,$n,$s));' "$CSS" "$OLD" "$NEW"
|
||||
echo " applied to main.min.css"
|
||||
else
|
||||
echo " !! expected panel rule not found - inspect manually"
|
||||
echo " (upstream may have changed it; diff against $CSS.orig)"
|
||||
fi
|
||||
|
||||
# keep the SCSS source consistent so the shipped CSS is not contradicted by the source
|
||||
if [ -f "$SCSS" ] && grep -q 'height: 500px;' "$SCSS"; then
|
||||
[ -f "$SCSS.orig" ] || cp -a "$SCSS" "$SCSS.orig"
|
||||
php83 -r '$f=$argv[1];$s=file_get_contents($f);
|
||||
$s=str_replace("height: 500px;","height: auto;\n\tmax-height: 58vh;",$s);
|
||||
file_put_contents($f,$s);' "$SCSS"
|
||||
echo " synchronised _panel.scss"
|
||||
fi
|
||||
|
||||
echo "=== 2. nginx cache headers ==="
|
||||
if [ ! -f "$NGX" ]; then
|
||||
echo " !! $NGX not found"
|
||||
elif grep -q 'must-revalidate' "$NGX"; then
|
||||
echo " already applied"
|
||||
else
|
||||
[ -f "$NGX.orig" ] || cp -a "$NGX" "$NGX.orig"
|
||||
cat > /tmp/.cacheblock <<'EOF'
|
||||
|
||||
# Atheos serves theme/main.min.css and the generated *.min.js/css bundles from STABLE URLs
|
||||
# with no cache headers, so a CSS/JS fix stays invisible behind the browser cache until a
|
||||
# hard refresh. "no-cache" permits caching but forces revalidation: normal loads still get a
|
||||
# cheap 304, and a change is guaranteed to be picked up on the next load.
|
||||
location ~* \.(css|js)$ {
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
try_files $uri =404;
|
||||
}
|
||||
EOF
|
||||
php83 -r '$f=$argv[1];$b=$argv[2];$s=file_get_contents($f);
|
||||
$p=strrpos($s,"}"); if($p===false){exit(1);}
|
||||
file_put_contents($f,substr($s,0,$p).file_get_contents($b).substr($s,$p));' "$NGX" /tmp/.cacheblock
|
||||
rm -f /tmp/.cacheblock
|
||||
nginx -t >/dev/null 2>&1 && rc-service nginx reload >/dev/null 2>&1 && echo " applied + nginx reloaded" \
|
||||
|| echo " !! nginx -t failed - restore $NGX.orig"
|
||||
fi
|
||||
|
||||
echo "=== done ==="
|
||||
Reference in New Issue
Block a user