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

View File

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

View File

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

View File

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

View File

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

View File

@ -113,5 +113,5 @@ export async function compute() {
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 uptimeSec = Math.round(uptime());
return {
const data = {
ts,
cpuLoad1m: load1,
cpuLoad5m: load5,
@ -99,6 +99,7 @@ async function compute() {
tcpAlloc: tcp.tcpAlloc,
tcpMemPages: tcp.tcpMemPages
};
return { signal: data, workflow: null };
}
export {
compute,

View File

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

View File

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

View File

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