You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Catch the staleness the bundle guard could not see (#391)
The Stop-hook guard rebuilt web_ui/dist/app whenever the bundle was older
than web_ui/src. That solves one staleness problem and is silent, by
construction, about a second one.
If the CHECKOUT is behind the branch work lands on, merged code is not in
the working tree at all - so the bundle is perfectly consistent with the
source, the mtime walk finds nothing newer, and the guard correctly says
nothing while the running app is missing features that already shipped. A
canvas went on spawning placeholder nodes on double-click for hours after
the commit removing that gesture had merged, because the checkout sat five
commits behind origin/main and every local file legitimately matched the
bundle built from it.
Two additions:
- The bundle records the commit it was built from
(dist/app/.built-from-commit) and is rebuilt when HEAD no longer matches
it. A pull or branch switch that happens to leave mtimes alone is
invisible to an mtime walk; a recorded HEAD is not.
- When HEAD is behind origin/main the hook says so, naming the branch and
the commit count, whether or not it also rebuilt. Reported, never
auto-merged - the working tree belongs to the developer, and a Stop hook
has no business rewriting it. It reads only already-fetched refs, so it
never blocks on the network.
Co-authored-by: Claude <noreply@anthropic.com>
[ "$built_from"="$head_sha" ] || newest="(built from a different commit)"
71
+
fi
47
72
48
-
if (cd "$root/web_ui"&& npm run build >/tmp/graphlink-spa-build.log 2>&1);then
49
-
emit '"web_ui/dist/app rebuilt - the desktop app and :8765 now serve the current source."'
50
-
else
51
-
emit '"web_ui/dist/app is STALE: npm run build failed. See /tmp/graphlink-spa-build.log. The desktop app and :8765 are still serving the previous bundle."'
73
+
rebuilt=""
74
+
if [ -n"$newest" ];then
75
+
if (cd "$root/web_ui"&& npm run build >/tmp/graphlink-spa-build.log 2>&1);then
emit '"web_ui/dist/app is STALE: npm run build failed. See /tmp/graphlink-spa-build.log. The desktop app and :8765 are still serving the previous bundle."'
80
+
exit 0
81
+
fi
52
82
fi
83
+
84
+
# -- 2. Is the checkout itself behind what has already merged? --------------
85
+
#
86
+
# Reported, never acted on. Reads only refs already fetched - no network, so
87
+
# a Stop hook never blocks on one.
88
+
89
+
behind=""
90
+
if [ -n"$head_sha" ];then
91
+
upstream=""
92
+
forcandidatein origin/main origin/master;do
93
+
if git -C "$root" rev-parse --verify --quiet "$candidate">/dev/null 2>&1;then
branch="$(git -C "$root" rev-parse --abbrev-ref HEAD 2>/dev/null ||echo'?')"
106
+
if [ -n"$rebuilt" ];then
107
+
emit "\"web_ui/dist/app rebuilt. BUT this checkout ($branch) is $behind commit(s) behind origin/main, so the running app is still missing work that has already merged - the bundle can only ever be as current as the source it is built from. Merge or rebase when your working tree allows it.\""
108
+
else
109
+
emit "\"web_ui/dist/app matches this source, but the checkout ($branch) is $behind commit(s) behind origin/main - the running app is missing work that has already merged. Merge or rebase when your working tree allows it.\""
110
+
fi
111
+
exit 0
112
+
fi
113
+
114
+
[ -n"$rebuilt" ] && emit '"web_ui/dist/app rebuilt - the desktop app and :8765 now serve the current source."'
0 commit comments