Compare commits
2 Commits
main
...
fix/logs-f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b72a3674a7 | ||
|
|
8bf1af35de |
@ -25,6 +25,7 @@ Docs: https://docs.clawd.bot
|
|||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- BlueBubbles: stop typing indicator on idle/no-reply. (#1439) Thanks @Nicell.
|
- BlueBubbles: stop typing indicator on idle/no-reply. (#1439) Thanks @Nicell.
|
||||||
|
- CLI: suppress progress spinner noise for `logs --follow` and JSON output. (#1472) Thanks @czekaj.
|
||||||
- Auto-reply: only report a model switch when session state is available. (#1465) Thanks @robbyczgw-cla.
|
- Auto-reply: only report a model switch when session state is available. (#1465) Thanks @robbyczgw-cla.
|
||||||
- Control UI: resolve local avatar URLs with basePath across injection + identity RPC. (#1457) Thanks @dlauer.
|
- Control UI: resolve local avatar URLs with basePath across injection + identity RPC. (#1457) Thanks @dlauer.
|
||||||
- Agents: surface concrete API error details instead of generic AI service errors.
|
- Agents: surface concrete API error details instead of generic AI service errors.
|
||||||
|
|||||||
@ -23,13 +23,14 @@ export async function callGatewayFromCli(
|
|||||||
method: string,
|
method: string,
|
||||||
opts: GatewayRpcOpts,
|
opts: GatewayRpcOpts,
|
||||||
params?: unknown,
|
params?: unknown,
|
||||||
extra?: { expectFinal?: boolean },
|
extra?: { expectFinal?: boolean; progress?: boolean },
|
||||||
) {
|
) {
|
||||||
|
const showProgress = (extra?.progress ?? true) && opts.json !== true;
|
||||||
return await withProgress(
|
return await withProgress(
|
||||||
{
|
{
|
||||||
label: `Gateway ${method}`,
|
label: `Gateway ${method}`,
|
||||||
indeterminate: true,
|
indeterminate: true,
|
||||||
enabled: opts.json !== true,
|
enabled: showProgress,
|
||||||
},
|
},
|
||||||
async () =>
|
async () =>
|
||||||
await callGateway({
|
await callGateway({
|
||||||
|
|||||||
@ -82,4 +82,21 @@ describe("logs cli", () => {
|
|||||||
|
|
||||||
expect(stderrWrites.join("")).toContain("output stdout closed");
|
expect(stderrWrites.join("")).toContain("output stdout closed");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("disables progress spinner in json mode", async () => {
|
||||||
|
callGatewayFromCli.mockResolvedValueOnce({
|
||||||
|
file: "/tmp/clawdbot.log",
|
||||||
|
lines: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { registerLogsCli } = await import("./logs-cli.js");
|
||||||
|
const program = new Command();
|
||||||
|
program.exitOverride();
|
||||||
|
registerLogsCli(program);
|
||||||
|
|
||||||
|
await program.parseAsync(["logs", "--json"], { from: "user" });
|
||||||
|
|
||||||
|
const extra = callGatewayFromCli.mock.calls[0]?.[3];
|
||||||
|
expect(extra).toEqual({ progress: false });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -41,14 +41,16 @@ function parsePositiveInt(value: string | undefined, fallback: number): number {
|
|||||||
async function fetchLogs(
|
async function fetchLogs(
|
||||||
opts: LogsCliOptions,
|
opts: LogsCliOptions,
|
||||||
cursor: number | undefined,
|
cursor: number | undefined,
|
||||||
|
showProgress: boolean,
|
||||||
): Promise<LogsTailPayload> {
|
): Promise<LogsTailPayload> {
|
||||||
const limit = parsePositiveInt(opts.limit, 200);
|
const limit = parsePositiveInt(opts.limit, 200);
|
||||||
const maxBytes = parsePositiveInt(opts.maxBytes, 250_000);
|
const maxBytes = parsePositiveInt(opts.maxBytes, 250_000);
|
||||||
const payload = await callGatewayFromCli("logs.tail", opts, {
|
const payload = await callGatewayFromCli(
|
||||||
cursor,
|
"logs.tail",
|
||||||
limit,
|
opts,
|
||||||
maxBytes,
|
{ cursor, limit, maxBytes },
|
||||||
});
|
{ progress: showProgress },
|
||||||
|
);
|
||||||
if (!payload || typeof payload !== "object") {
|
if (!payload || typeof payload !== "object") {
|
||||||
throw new Error("Unexpected logs.tail response");
|
throw new Error("Unexpected logs.tail response");
|
||||||
}
|
}
|
||||||
@ -194,8 +196,10 @@ export function registerLogsCli(program: Command) {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
let payload: LogsTailPayload;
|
let payload: LogsTailPayload;
|
||||||
|
// Show progress spinner only on first fetch for non-follow, non-JSON output.
|
||||||
|
const showProgress = first && !opts.follow && !jsonMode;
|
||||||
try {
|
try {
|
||||||
payload = await fetchLogs(opts, cursor);
|
payload = await fetchLogs(opts, cursor, showProgress);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
emitGatewayError(err, opts, jsonMode ? "json" : "text", rich, emitJsonLine, errorLine);
|
emitGatewayError(err, opts, jsonMode ? "json" : "text", rich, emitJsonLine, errorLine);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user