feat: update senses to return ComputeResult<T>

Wrap compute return values in { signal, workflow: null }
to match new SenseComputeFn contract.

— 小橘 🍊(NEKO Team)
This commit is contained in:
小橘 2026-04-30 00:38:34 +00:00
parent 1d9e574c94
commit 8774d71d57
10 changed files with 14 additions and 48 deletions

View File

@ -55,16 +55,7 @@ async function compute() {
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim(); const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
if (inside !== "true") { if (inside !== "true") {
gitError = "not a git work tree"; gitError = "not a git work tree";
return { return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
ts,
branch,
headShort,
porcelainLines,
hasUpstream,
aheadCount,
behindCount,
gitError
};
} }
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]); branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
headShort = runGit(root, ["rev-parse", "--short", "HEAD"]); headShort = runGit(root, ["rev-parse", "--short", "HEAD"]);
@ -86,16 +77,7 @@ async function compute() {
} catch (e) { } catch (e) {
gitError = gitErrorMessage(e); gitError = gitErrorMessage(e);
} }
return { return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
ts,
branch,
headShort,
porcelainLines,
hasUpstream,
aheadCount,
behindCount,
gitError
};
} }
export { export {
compute, compute,

View File

@ -47,16 +47,7 @@ export async function compute() {
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim(); const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
if (inside !== "true") { if (inside !== "true") {
gitError = "not a git work tree"; gitError = "not a git work tree";
return { return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
ts,
branch,
headShort,
porcelainLines,
hasUpstream,
aheadCount,
behindCount,
gitError,
};
} }
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]); branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
@ -81,14 +72,5 @@ export async function compute() {
gitError = gitErrorMessage(e); gitError = gitErrorMessage(e);
} }
return { return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
ts,
branch,
headShort,
porcelainLines,
hasUpstream,
aheadCount,
behindCount,
gitError,
};
} }

View File

@ -353,7 +353,7 @@ async function compute() {
httpLatencyMs, httpLatencyMs,
httpError httpError
}; };
return row; return { signal: row, workflow: null };
} }
export { export {
compute, compute,

View File

@ -404,5 +404,5 @@ export async function compute() {
httpError, httpError,
}; };
return row; return { signal: row, workflow: null };
} }

View File

@ -102,7 +102,7 @@ async function compute() {
activeSessions, activeSessions,
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS
}; };
return row; return { signal: row, workflow: null };
} }
export { export {
compute, compute,

View File

@ -113,5 +113,5 @@ export async function compute() {
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS, measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS,
}; };
return row; return { signal: row, workflow: null };
} }

View File

@ -80,7 +80,7 @@ async function compute() {
} }
const ts = Date.now(); const ts = Date.now();
const uptimeSec = Math.round(uptime()); const uptimeSec = Math.round(uptime());
return { const data = {
ts, ts,
cpuLoad1m: load1, cpuLoad1m: load1,
cpuLoad5m: load5, cpuLoad5m: load5,
@ -99,6 +99,7 @@ async function compute() {
tcpAlloc: tcp.tcpAlloc, tcpAlloc: tcp.tcpAlloc,
tcpMemPages: tcp.tcpMemPages tcpMemPages: tcp.tcpMemPages
}; };
return { signal: data, workflow: null };
} }
export { export {
compute, compute,

View File

@ -72,7 +72,7 @@ export async function compute() {
const ts = Date.now(); const ts = Date.now();
const uptimeSec = Math.round(uptime()); const uptimeSec = Math.round(uptime());
return { const data = {
ts, cpuLoad1m: load1, cpuLoad5m: load5, cpuLoad15m: load15, ts, cpuLoad1m: load1, cpuLoad5m: load5, cpuLoad15m: load15,
memTotalMB, memUsedMB, memUsedPct, memTotalMB, memUsedMB, memUsedPct,
diskTotalGB, diskUsedGB, diskUsedPct, diskTotalGB, diskUsedGB, diskUsedPct,
@ -84,4 +84,5 @@ export async function compute() {
tcpAlloc: tcp.tcpAlloc, tcpAlloc: tcp.tcpAlloc,
tcpMemPages: tcp.tcpMemPages, tcpMemPages: tcp.tcpMemPages,
}; };
return { signal: data, workflow: null };
} }

View File

@ -29,7 +29,7 @@ async function compute() {
rssMB, rssMB,
externalMB externalMB
}; };
return row; return { signal: row, workflow: null };
} }
export { export {
compute, compute,

View File

@ -22,5 +22,5 @@ export async function compute() {
externalMB, externalMB,
}; };
return row; return { signal: row, workflow: null };
} }