Skip to content

feat(cli): add sessions tail progress view - #83956

Merged
steipete merged 6 commits into
openclaw:mainfrom
spacegeologist:sessions-tail-progress-view
May 30, 2026
Merged

steipete merged 6 commits into
openclaw:mainfrom
spacegeologist:sessions-tail-progress-view

Conversation

@spacegeologist

@spacegeologist spacegeologist commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MVP for #83441.

This adds a human-readable trajectory progress tail under:

openclaw sessions tail --follow

The command renders session trajectory JSONL events into compact operator-facing lines instead of requiring users to find the latest *.trajectory.jsonl file and hand-write jq.

Follow-ups after ClawSweeper review:

  • explicit fully qualified --session-key values now resolve the target agent store, so non-default-agent sessions can be tailed without also passing --agent or --all-agents
  • --follow carries the initial trajectory read offset forward, so events appended during the initial render-to-follow handoff are not dropped
  • sessions tail now resolves runtime trajectory files through the same pointer-aware trajectory resolver used by export, so sessions with OPENCLAW_TRAJECTORY_DIR relocated runtime files can be tailed from their session-adjacent pointer

Scope

  • Adds openclaw sessions tail
  • Supports --session-key, --tail, --follow, --store, --agent, and --all-agents
  • Selects the requested session, otherwise running sessions, otherwise the latest session
  • Renders concise progress lines with timestamp, event type, session key, and safe status/model/tool preview
  • Redacts prompt text, tool arguments, and tool results by default
  • Resolves the agent store from an explicit fully qualified session key when no store/agent/all-agents override is provided
  • Carries the initial trajectory read offset into follow mode so appended events are not dropped between initial tail rendering and polling
  • Honors session trajectory pointer files before falling back to the default/current trajectory path

Maintainer Decision Point

This PR is ready for maintainer review, with one intentional product/API decision point: whether the public command shape should be openclaw sessions tail or another surface such as openclaw logs --source sessions --follow.

I used sessions tail because this renders session trajectory activity rather than gateway/process logs. If maintainers prefer a different command shape, I can adapt this branch.

Real Behavior Proof

  • Behavior or issue addressed: openclaw sessions tail should render live human-readable trajectory progress, follow appended trajectory events, redact tool arguments/results, resolve a fully qualified non-default-agent --session-key without requiring --agent, avoid dropping events appended while follow mode starts, and honor existing relocated trajectory pointer files.

  • Real environment tested: local macOS source checkout of this PR branch using Node.js v24.13.1, node --import tsx src/entry.ts, and temporary OPENCLAW_STATE_DIR directories containing real OpenClaw session-store and *.trajectory.jsonl files for a non-default ops agent.

  • Exact steps or command run after this patch:

    OPENCLAW_STATE_DIR=/tmp/openclaw-sessions-tail-follow-proof-*/state \
      node --import tsx src/entry.ts sessions tail \
        --session-key agent:ops:telegram:direct:redacted-user \
        --tail 1 --follow

    I also ran the non-follow tail path:

    OPENCLAW_STATE_DIR=/tmp/openclaw-sessions-tail-proof.zBZU2c/state \
      node --import tsx src/entry.ts sessions tail \
        --session-key agent:ops:telegram:direct:redacted-user \
        --tail 4
  • Evidence after fix: copied terminal output from the after-fix source-checkout CLI run. The temporary trajectory fixture included SECRET_SHOULD_NOT_PRINT in a tool result body; the rendered output below did not expose it.

    $ openclaw sessions tail --session-key agent:ops:telegram:direct:redacted-user --tail 1 --follow
    03:31:01 session.started  agent:ops:telegram:direct:red… session started
    03:31:02 tool.result      agent:ops:telegram:direct:red… bash ok
    

    Non-follow copied terminal output:

    $ openclaw sessions tail --session-key agent:ops:telegram:direct:redacted-user --tail 4
    03:30:01 session.started  agent:ops:telegram:direct:red… session started
    03:30:02 tool.call        agent:ops:telegram:direct:red… bash {...redacted...}
    03:30:03 tool.result      agent:ops:telegram:direct:red… bash ok
    03:30:04 model.completed  agent:ops:telegram:direct:red… openai/gpt-5.2 done
    
  • Observed result after fix: the command found the ops agent session from the explicit fully qualified session key, printed compact session progress lines, followed an appended trajectory event, rendered tool call/result/model status previews, and kept the secret tool result body out of the output. Focused regression coverage also verifies the follow handoff case and an OPENCLAW_TRAJECTORY_DIR-style relocated runtime trajectory pointer.

  • What was not tested: full GitHub CI for the latest pushed head is left to the repository workflow. The local run covered focused command tests, trajectory export regression tests, formatting, diff check, full lint, and core/core-test typecheck.

  • Before evidence: before the follow-up fixes, source inspection showed sessions tail resolved stores before deriving any agent from --session-key, follow mode initialized offsets from current file size after initial rendering, and tailing computed only the direct trajectory path without checking the session-adjacent trajectory pointer.

Verification

  • OPENCLAW_TEST_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.commands.config.ts src/commands/sessions-tail.test.ts (5 tests passed)
  • OPENCLAW_TEST_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.cli.config.ts src/cli/program/register.status-health-sessions.test.ts (25 tests passed)
  • OPENCLAW_TEST_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/trajectory/export.test.ts (17 tests passed)
  • ./node_modules/.bin/oxfmt --check --threads=1 src/cli/program/register.status-health-sessions.ts src/cli/program/register.status-health-sessions.test.ts src/commands/sessions-tail.ts src/commands/sessions-tail.test.ts src/trajectory/export.ts src/trajectory/runtime-file.ts
  • OPENCLAW_OXLINT_SKIP_LOCK=1 node scripts/run-oxlint-shards.mjs --threads=8
  • OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
  • OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
  • git diff --check

Risk

Low-to-medium. The change is additive CLI surface over existing trajectory/session files. The main open question is naming and redaction policy, not runtime behavior.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: L triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 19, 2026
@clawsweeper

clawsweeper Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 30, 2026, 4:24 PM ET / 20:24 UTC.

Summary
The PR adds openclaw sessions tail for redacted human-readable trajectory progress, wires it into the sessions CLI, documents it, adds focused tests, and shares pointer-aware trajectory file resolution with export.

PR surface: Source +572, Tests +347, Docs +14. Total +933 across 7 files.

Reproducibility: not applicable. this is an additive feature PR rather than a broken existing behavior report. Current main lacks the command, and the PR body includes source-entry CLI output showing the new behavior.

Review metrics: 1 noteworthy metric.

  • Public CLI surface: 1 command added, 6 options added. The new command and options become documented operator-facing CLI API, so maintainers should explicitly accept the shape before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Maintainer should choose the final public command shape and redaction policy before merge.

Risk before merge

  • [P1] Merging establishes a new public operator CLI surface and conservative redaction policy; maintainers should decide whether openclaw sessions tail is the desired command shape before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Land this after maintainers accept the public command name and redaction policy, keeping the linked feature issue open until the PR merges.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] The remaining action is maintainer product/API judgment on the public command shape, not an automated repair.

Security
Cleared: No concrete security or supply-chain issue found; the diff adds no dependencies or workflows, and the new CLI path avoids printing prompt text, tool arguments, and tool result bodies by default.

Review details

Best possible solution:

Land this after maintainers accept the public command name and redaction policy, keeping the linked feature issue open until the PR merges.

Do we have a high-confidence way to reproduce the issue?

Not applicable; this is an additive feature PR rather than a broken existing behavior report. Current main lacks the command, and the PR body includes source-entry CLI output showing the new behavior.

Is this the best way to solve the issue?

Yes, if maintainers accept the command shape: the implementation reuses session-store targeting and extracted pointer-aware trajectory resolution instead of duplicating export behavior. The unresolved part is product/API naming, not a concrete code defect.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 3fc0df953cf1.

Label changes

Label justifications:

  • P2: This is a normal-priority CLI ergonomics feature with focused blast radius and a linked operator workflow request.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes copied after-fix terminal output from real source-entry CLI runs against temporary session and trajectory files, including a secret-bearing fixture that did not appear in output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied after-fix terminal output from real source-entry CLI runs against temporary session and trajectory files, including a secret-bearing fixture that did not appear in output.
Evidence reviewed

PR surface:

Source +572, Tests +347, Docs +14. Total +933 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 653 81 +572
Tests 2 347 0 +347
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 1014 81 +933

What I checked:

Likely related people:

  • Peter Steinberger: Authored the latest PR-head commit handling rewritten sessions-tail trajectories and also appears in recent docs history for the sessions docs path. (role: recent branch updater and adjacent contributor; confidence: medium; commits: 2dd6bdf9da0d, 005da57957c9; files: src/commands/sessions-tail.ts, src/commands/sessions-tail.test.ts, docs/cli/sessions.md)
  • Shakker: The available shallow/grafted current-main blame and log attribute the adjacent sessions CLI registration, trajectory export, and sessions docs files to the same current-main commit; useful as a routing hint but not a deep ownership conclusion. (role: current-main adjacent code owner signal; confidence: low; commits: f7729028aea4; files: src/cli/program/register.status-health-sessions.ts, src/trajectory/export.ts, docs/cli/sessions.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated this draft with:

  • a fix for explicit non-default-agent --session-key lookup
  • focused regression coverage for that lookup path
  • redacted real behavior proof in the PR body, including a --follow run against a temporary trajectory fixture
  • refreshed focused test, format, and diff checks

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels May 19, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 19, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated the draft again for the follow-mode handoff finding:

  • carries the initial trajectory read byte offset into --follow instead of snapshotting the later file size
  • adds regression coverage for an event appended while follow mode starts
  • reran the requested focused tests, format check, and diff check
  • refreshed the PR body proof/verification section for the new head

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 19, 2026
@spacegeologist
spacegeologist marked this pull request as ready for review May 20, 2026 04:52
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 20, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 23, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head is 52211b0595e18c256c9df03447e4a7c2a72731b8. The prior lint and trajectory pointer findings were addressed in this branch, so requesting a fresh review against the latest head.

@clawsweeper

clawsweeper Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels May 23, 2026
@steipete steipete self-assigned this May 30, 2026
@steipete
steipete force-pushed the sessions-tail-progress-view branch from 52211b0 to 2dd6bdf Compare May 30, 2026 20:17
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed size: L labels May 30, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer verification for head 2dd6bdf.

Behavior addressed: openclaw sessions tail --follow now keeps following when the bounded trajectory writer rewrites/replaces the JSONL window, and the public sessions tail CLI surface is documented.

Real environment tested: local macOS source checkout on this PR branch, using the real CLI entrypoint with a temporary session store and trajectory file.

Exact steps or command run after this patch:

node scripts/run-vitest.mjs run --config test/vitest/vitest.commands.config.ts src/commands/sessions-tail.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.cli.config.ts src/cli/program/register.status-health-sessions.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/trajectory/export.test.ts
./node_modules/.bin/oxfmt --check --threads=1 src/commands/sessions-tail.ts src/commands/sessions-tail.test.ts src/cli/program/register.status-health-sessions.ts src/cli/program/register.status-health-sessions.test.ts src/trajectory/export.ts src/trajectory/runtime-file.ts
pnpm docs:list
git diff --check
OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
.agents/skills/autoreview/scripts/autoreview --mode local --prompt 'Review the sessions tail follow fix. Focus on cursor correctness for rewritten bounded trajectory files, duplicate/missed events, redaction, and docs accuracy.'

Evidence after fix: focused tests passed (sessions-tail: 6 tests, CLI registration: 26 tests, trajectory export: 17 tests). The live CLI proof started node --import tsx src/entry.ts sessions tail --store <tmp>/sessions.json --session-key agent:main:telegram:direct:live-proof --tail 1 --follow, waited for the initial rendered line, atomically replaced <tmp>/live-session.trajectory.jsonl with a new event, and observed:

12:04:17 session.started  agent:main:telegram:direct:li… session started
12:04:21 tool.result      agent:main:telegram:direct:li… bash ok

Observed result after fix: follow mode printed the event from the replaced trajectory window and did not print the secret-bearing tool result body (SECRET_SHOULD_NOT_PRINT was absent from output). Autoreview reported clean: no accepted/actionable findings. GitHub checks for this head are green: 103 passing, 0 pending, 0 failing.

What was not tested: a real long-running chat transport session on Telegram/Discord/Slack; the live proof used the same CLI entrypoint and persisted session/trajectory file shape with a temporary local store.

@steipete steipete left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after maintainer fixup, focused tests, live CLI follow proof, clean autoreview, and green GitHub checks on head 2dd6bdf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants