惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
罗磊的独立博客
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
V
V2EX
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
量子位
MyScale Blog
MyScale Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(control-ui): rotate service worker cache per build (#...
steipete · 2026-05-15 · via Recent Commits to openclaw:main

@@ -1,8 +1,12 @@

1+

import { execFileSync } from "node:child_process";

2+

import fs from "node:fs";

13

import path from "node:path";

24

import { fileURLToPath } from "node:url";

3-

import { defineConfig } from "vite";

5+

import { defineConfig, type Plugin } from "vite";

4657

const here = path.dirname(fileURLToPath(import.meta.url));

8+

const repoRoot = path.resolve(here, "..");

9+

const outDir = path.resolve(here, "../dist/control-ui");

610711

function normalizeBase(input: string): string {

812

const trimmed = input.trim();

@@ -18,17 +22,78 @@ function normalizeBase(input: string): string {

1822

return `${trimmed}/`;

1923

}

202425+

function normalizeBuildId(input: string): string {

26+

const normalized = input.trim().replace(/[^a-zA-Z0-9._-]+/g, "-");

27+

return normalized.slice(0, 96) || "dev";

28+

}

29+30+

function readPackageVersion(): string {

31+

try {

32+

const raw = fs.readFileSync(path.join(repoRoot, "package.json"), "utf8");

33+

const parsed = JSON.parse(raw) as { version?: unknown };

34+

return typeof parsed.version === "string" && parsed.version.trim()

35+

? parsed.version.trim()

36+

: "dev";

37+

} catch {

38+

return "dev";

39+

}

40+

}

41+42+

function readGitShortSha(): string | null {

43+

try {

44+

const raw = execFileSync("git", ["-C", repoRoot, "rev-parse", "--short=12", "HEAD"], {

45+

encoding: "utf8",

46+

stdio: ["ignore", "pipe", "ignore"],

47+

});

48+

return raw.trim() || null;

49+

} catch {

50+

return null;

51+

}

52+

}

53+54+

function resolveControlUiBuildId(): string {

55+

const explicit =

56+

process.env.OPENCLAW_CONTROL_UI_BUILD_ID?.trim() || process.env.OPENCLAW_VERSION?.trim();

57+

if (explicit) {

58+

return normalizeBuildId(explicit);

59+

}

60+

const version = readPackageVersion();

61+

const gitSha = readGitShortSha();

62+

return normalizeBuildId(gitSha ? `${version}-${gitSha}` : version);

63+

}

64+65+

function controlUiServiceWorkerBuildIdPlugin(buildId: string): Plugin {

66+

return {

67+

name: "control-ui-service-worker-build-id",

68+

apply: "build",

69+

closeBundle() {

70+

const swPath = path.join(outDir, "sw.js");

71+

const source = fs.readFileSync(swPath, "utf8");

72+

const placeholder = '"__OPENCLAW_CONTROL_UI_BUILD_ID__"';

73+

const updated = source.replace(placeholder, JSON.stringify(buildId));

74+

if (updated === source) {

75+

throw new Error(`Control UI service worker build id placeholder missing in ${swPath}`);

76+

}

77+

fs.writeFileSync(swPath, updated);

78+

},

79+

};

80+

}

81+2182

export default defineConfig(() => {

2283

const envBase = process.env.OPENCLAW_CONTROL_UI_BASE_PATH?.trim();

2384

const base = envBase ? normalizeBase(envBase) : "./";

85+

const controlUiBuildId = resolveControlUiBuildId();

2486

return {

2587

base,

88+

define: {

89+

__OPENCLAW_CONTROL_UI_BUILD_ID__: JSON.stringify(controlUiBuildId),

90+

},

2691

publicDir: path.resolve(here, "public"),

2792

optimizeDeps: {

2893

include: ["lit/directives/repeat.js"],

2994

},

3095

build: {

31-

outDir: path.resolve(here, "../dist/control-ui"),

96+

outDir,

3297

emptyOutDir: true,

3398

sourcemap: true,

3499

// Keep CI/onboard logs clean; current control UI chunking is intentionally above 500 kB.

@@ -40,6 +105,7 @@ export default defineConfig(() => {

40105

strictPort: true,

41106

},

42107

plugins: [

108+

controlUiServiceWorkerBuildIdPlugin(controlUiBuildId),

43109

{

44110

name: "control-ui-dev-stubs",

45111

configureServer(server) {