Skip to content

Commit 451d713

Browse files
fix: React #62 root cause + Babel warning + version display
React #62 (setState after unmount): - refresh() now checks mountedRef after every await - refreshBoard/refreshArchives/refreshQueries all guarded - All async state updates bail early if component unmounted Babel warning: - console.warn monkey-patch suppresses in-browser Babel nag - Added BEFORE babel.min.js loads Version display: - Health endpoint now returns 'version' field - server.Version wired from main via ldflags - Embedded UI conn-strip shows 'v0.8.2' badge
1 parent 9887db8 commit 451d713

6 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MODULE := github.com/UnicoLab/slmcode
22
BIN := slmcode
3-
VERSION ?= 0.8.1
3+
VERSION ?= 0.8.2
44
PREFIX ?= $(HOME)/.local
55
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
66
BUILD_TIME := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)

‎cmd/slmcode/root.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/UnicoLab/slmcode/pkg/config"
1717
"github.com/UnicoLab/slmcode/pkg/harness"
1818
"github.com/UnicoLab/slmcode/pkg/orchestrator"
19+
"github.com/UnicoLab/slmcode/pkg/server"
1920
)
2021

2122
//go:embed all:ui
@@ -40,6 +41,7 @@ var (
4041
func main() {
4142
// Keep CLI UX clean — GoLangGraph registries are chatty at Info.
4243
logrus.SetLevel(logrus.WarnLevel)
44+
server.Version = Version
4345

4446
root := &cobra.Command{
4547
Use: "slmcode",

‎cmd/slmcode/ui/app.jsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ function App() {
861861

862862
const refreshBoard = useCallback(async () => {
863863
const b = normalizeBoard(await api("/api/board"));
864+
if (!mountedRef.current) return;
864865
setBoard(b);
865866
const cur = selectedRef.current;
866867
if (cur) {
@@ -872,17 +873,21 @@ function App() {
872873
const refreshArchives = useCallback(async () => {
873874
try {
874875
const list = await api("/api/archives");
876+
if (!mountedRef.current) return;
875877
setArchives(Array.isArray(list) ? list : []);
876878
} catch (_) {
879+
if (!mountedRef.current) return;
877880
setArchives([]);
878881
}
879882
}, []);
880883

881884
const refreshQueries = useCallback(async () => {
882885
try {
883886
const list = await api("/api/queries");
887+
if (!mountedRef.current) return;
884888
setQueries(Array.isArray(list) ? list : []);
885889
} catch (_) {
890+
if (!mountedRef.current) return;
886891
setQueries([]);
887892
}
888893
}, []);
@@ -898,6 +903,7 @@ function App() {
898903
api("/api/agents").catch(() => []),
899904
api("/api/pipeline").catch(() => null),
900905
]);
906+
if (!mountedRef.current) return;
901907
setHealth(h);
902908
setApiConnected(!!h?.ok);
903909
setConfig(c);
@@ -920,8 +926,10 @@ function App() {
920926
if (last?.phase && last.phase !== "idle") setPhase(last.phase);
921927
}
922928
await refreshBoard();
929+
if (!mountedRef.current) return;
923930
await refreshArchives();
924931
await refreshQueries();
932+
if (!mountedRef.current) return;
925933
setErr("");
926934
} catch (e) {
927935
setApiConnected(false);
@@ -1656,6 +1664,7 @@ function App() {
16561664
<strong>{apiConnected ? "API connected" : "API offline"}</strong>
16571665
<span>· SSE {sseConnected ? "live" : "reconnecting…"}</span>
16581666
<span>· {health?.provider || "…"} / {String(health?.model || "").split("/").pop() || "…"}</span>
1667+
{health?.version ? <span className="pipeline-phase-id" style={{fontSize:"0.68rem",padding:"1px 6px"}}>v{health.version}</span> : null}
16591668
<span className="conn-root" title={health?.root || ""}>{health?.root ? health.root.replace(/^\/Users\/[^/]+/, "~") : ""}</span>
16601669
{!apiConnected && (
16611670
<button className="sm ghost" onClick={() => refresh()}>Retry</button>

‎cmd/slmcode/ui/index.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@
2222
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
2323
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap" rel="stylesheet" />
2424
<link rel="stylesheet" href="/styles.css" />
25+
<script>
26+
// Suppress the harmless babel-standalone precompile warning.
27+
(function(){var w=console.warn;console.warn=function(){if(arguments[0]&&typeof arguments[0]==='string'&&arguments[0].indexOf('in-browser Babel')>=0)return;w.apply(console,arguments)}})();
28+
</script>
2529
</head>
2630
<body>
2731
<div id="root"></div>
2832
<script src="/vendor/react.production.min.js"></script>
2933
<script src="/vendor/react-dom.production.min.js"></script>
3034
<script src="/vendor/babel.min.js"></script>
31-
<script type="text/babel" data-presets="react" src="/app.jsx"></script>
35+
<script type="text/babel" src="/app.jsx"></script>
3236
<noscript>SLMCode Studio requires JavaScript.</noscript>
3337
<footer style="text-align:center;padding:0.5rem;font-size:0.75rem;position:fixed;bottom:0;width:100%;background:var(--bg);border-top:1px solid var(--line);z-index:5;display:flex;align-items:center;justify-content:center;gap:0.4rem;flex-wrap:wrap">
3438
<span style="color:var(--muted)">Made with</span>

‎cmd/slmcode/version.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package main
44
//
55
// go build -ldflags "-X main.Version=0.5.0 -X main.SourceRoot=/path -X main.GitCommit=abc -X main.BuildTime=…"
66
var (
7-
Version = "0.8.1"
7+
Version = "0.8.2"
88
SourceRoot = "" // absolute path to the slmcode checkout used to build this binary
99
GitCommit = "unknown"
1010
BuildTime = "unknown"

‎pkg/server/server.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ type Server struct {
4141
subs map[chan orchestrator.Event]struct{}
4242
}
4343

44+
// Version is set at build time via -ldflags from the main package.
45+
var Version = "dev"
46+
4447
func New(h *harness.Harness, ui fs.FS) *Server {
4548
s := &Server{
4649
h: h,
@@ -159,6 +162,7 @@ func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
159162
"ok": true,
160163
"api": "ok",
161164
"ui": "embedded",
165+
"version": Version,
162166
"provider": s.h.Config.Provider,
163167
"model": s.h.Config.Model,
164168
"backend": s.h.Config.Backend,

0 commit comments

Comments
 (0)