mirror of https://github.com/openclaw/openclaw.git
Doctor: ignore slash sessions in transcript integrity check
This commit is contained in:
parent
30fd2bbe19
commit
6ae0fa4f0a
|
|
@ -171,4 +171,28 @@ describe("doctor state integrity oauth dir checks", () => {
|
|||
expect(text).not.toContain("--active");
|
||||
expect(text).not.toContain(" ls ");
|
||||
});
|
||||
|
||||
it("ignores slash-routing sessions for recent missing transcript warnings", async () => {
|
||||
const cfg: OpenClawConfig = {};
|
||||
setupSessionState(cfg, process.env, process.env.HOME ?? "");
|
||||
const storePath = resolveStorePath(cfg.session?.store, { agentId: "main" });
|
||||
fs.writeFileSync(
|
||||
storePath,
|
||||
JSON.stringify(
|
||||
{
|
||||
"agent:main:telegram:slash:6790081233": {
|
||||
sessionId: "missing-slash-transcript",
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
await noteStateIntegrity(cfg, { confirmSkipInNonInteractive: vi.fn(async () => false) });
|
||||
|
||||
const text = stateIntegrityText();
|
||||
expect(text).not.toContain("recent sessions are missing transcripts");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
resolveStorePath,
|
||||
} from "../config/sessions.js";
|
||||
import { resolveRequiredHomeDir } from "../infra/home-dir.js";
|
||||
import { parseAgentSessionKey } from "../sessions/session-key-utils.js";
|
||||
import { note } from "../terminal/note.js";
|
||||
import { shortenHomePath } from "../utils.js";
|
||||
|
||||
|
|
@ -165,6 +166,15 @@ function hasPairingPolicy(value: unknown): boolean {
|
|||
return false;
|
||||
}
|
||||
|
||||
function isSlashRoutingSessionKey(sessionKey: string): boolean {
|
||||
const raw = sessionKey.trim().toLowerCase();
|
||||
if (!raw) {
|
||||
return false;
|
||||
}
|
||||
const scoped = parseAgentSessionKey(raw)?.rest ?? raw;
|
||||
return /^[^:]+:slash:[^:]+(?:$|:)/.test(scoped);
|
||||
}
|
||||
|
||||
function shouldRequireOAuthDir(cfg: OpenClawConfig, env: NodeJS.ProcessEnv): boolean {
|
||||
if (env.OPENCLAW_OAUTH_DIR?.trim()) {
|
||||
return true;
|
||||
|
|
@ -413,7 +423,8 @@ export async function noteStateIntegrity(
|
|||
return bUpdated - aUpdated;
|
||||
})
|
||||
.slice(0, 5);
|
||||
const missing = recent.filter(([, entry]) => {
|
||||
const recentTranscriptCandidates = recent.filter(([key]) => !isSlashRoutingSessionKey(key));
|
||||
const missing = recentTranscriptCandidates.filter(([, entry]) => {
|
||||
const sessionId = entry.sessionId;
|
||||
if (!sessionId) {
|
||||
return false;
|
||||
|
|
@ -424,7 +435,7 @@ export async function noteStateIntegrity(
|
|||
if (missing.length > 0) {
|
||||
warnings.push(
|
||||
[
|
||||
`- ${missing.length}/${recent.length} recent sessions are missing transcripts.`,
|
||||
`- ${missing.length}/${recentTranscriptCandidates.length} recent sessions are missing transcripts.`,
|
||||
` Verify sessions in store: ${formatCliCommand(`openclaw sessions --store "${absoluteStorePath}"`)}`,
|
||||
` Preview cleanup impact: ${formatCliCommand(`openclaw sessions cleanup --store "${absoluteStorePath}" --dry-run`)}`,
|
||||
].join("\n"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue