Repository navigation
feat(kiro): agent status, session history and usage fixes (builds on #14001) - #26639
w-felipe360 wants to merge 24 commits into
Conversation
formatRateLimitResetLabel returned null for human-readable resetDescription values such as "Thu" or "2:30 PM" because only ISO dates were recognized. Return non-date descriptions unchanged so the status bar keeps a valid reset label.
execFile cannot launch configured .cmd/.bat paths directly on Windows. Route the Kiro usage command through getSpawnArgsForWindows like the other usage fetchers; native binaries keep the direct execFile path.
The Antigravity coverage landed upstream after this branch last rebased. Its test file predates the Kiro provider, so the shared resetRateLimitProviderMocks harness now fails on the unmocked fetchKiroRateLimits import. Declare the same vi.mock the other service test files use.
Upstream now feeds a ticking `now` into ProviderRateLimitWindowSection; `formatRateLimitResetLabel` gains an optional `now` (default Date.now()) so the label keeps re-rendering on the clock without inventing reset times.
Signed-off-by: guanbear <123guan@gmail.com>
# Conflicts: # src/main/rate-limits/rate-limit-service-test-harness.ts # src/main/rate-limits/service-account-target-selection.test.ts # src/main/rate-limits/service-inactive-account-previews.test.ts # src/main/rate-limits/service-live-claude-usage.test.ts # src/main/rate-limits/service-minimax-usage.test.ts # src/main/rate-limits/service-refresh-orchestration.test.ts # src/main/rate-limits/service-window-activation.test.ts # src/main/rate-limits/service/service-full-cycle-application.ts # src/main/rate-limits/service/service-full-cycle-preparation.ts # src/main/rate-limits/service/service-polling.ts # src/main/rate-limits/service/service-state.ts # src/main/rate-limits/service/service-types.ts # src/renderer/src/components/settings/appearance-status-bar-search.ts # src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx # src/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsx # src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts # src/renderer/src/components/status-bar/status-bar-agent-gating.ts # src/renderer/src/components/status-bar/status-bar-provider-visibility.ts # src/renderer/src/components/status-bar/usage-provider-settings-target.ts # src/renderer/src/components/status-bar/use-status-bar-controller.ts # src/renderer/src/i18n/locales/en.json # src/renderer/src/store/slices/ui-hydration-workspace-preferences.test.ts # src/renderer/src/store/slices/ui/ui-slice-hydration-status-bar-items.ts # src/shared/persisted-ui-state-types.ts # src/shared/rate-limit-state-factory.ts # src/shared/rate-limit-types.test.ts # src/shared/rate-limit-types.ts # src/shared/rpc-contract/client-ui-params.ts # src/shared/status-bar-defaults.ts # src/shared/ui-chrome-types.ts
# Conflicts: # src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx # src/renderer/src/i18n/locales/en.json
Kiro panes never reached the hook server, so pets, sidebar status and "agent finished" notifications ignored them, and Kiro conversations were missing from Agent session history. - Install Orca status hooks into every global Kiro agent config (~/.kiro/agents/*.json), locally and over SSH, and normalize Kiro's agentSpawn/userPromptSubmit/preToolUse/postToolUse/stop events. - Scan ~/.kiro/sessions/cli (<id>.json metadata + <id>.jsonl transcript) into the AI Vault, skipping subagent child sessions, with `kiro-cli chat --tui --resume-id <id>` as the resume command. - Gate Kiro resume on a new agent-session.kiro-resume.v1 capability so older remote hosts never see the widened agent enum.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe changes add Kiro support across managed hooks, hook-event processing, AI Vault session scanning and resume commands, and rate-limit reporting. The Kiro usage fetcher runs the CLI usage command and adds its results to rate-limit refresh cycles. The status bar adds Kiro usage visibility, settings controls, and reset-date labels. Tests and fixtures cover these changes. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The displayed agents path is correct for local and remote installations. No actionable merge-blocking risk remains for the supported Kiro workflow. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
060a9241-17c4-4f49-a297-1f8f7d6e4789
📒 Files selected for processing (81)
config/tsconfig.cli.jsonsrc/main/agent-hooks/installer-utils-remote.tssrc/main/agent-hooks/managed-agent-hook-registry.tssrc/main/agent-hooks/managed-hook-command-contract.test.tssrc/main/agent-hooks/remote-hook-service-registry-coverage.test.tssrc/main/agent-hooks/remote-managed-hook-installers.tssrc/main/agent-hooks/server-retired-pane-new-turn.test.tssrc/main/ai-vault/remote-session-scanner-kiro-source.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-agent-sources.tssrc/main/ai-vault/session-scanner-every-agent-fixture.tssrc/main/ai-vault/session-scanner-kiro-fixtures.tssrc/main/ai-vault/session-scanner-kiro-parser.test.tssrc/main/ai-vault/session-scanner-kiro-parser.tssrc/main/ai-vault/session-scanner-opencode-sqlite-coexistence.test.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-test-fixtures.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner.test.tssrc/main/ipc/preflight-agent-detection.test.tssrc/main/kiro/hook-service.test.tssrc/main/kiro/hook-service.tssrc/main/kiro/hook-settings.tssrc/main/preflight/agent-detection.tssrc/main/rate-limits/kiro-usage-fetcher.test.tssrc/main/rate-limits/kiro-usage-fetcher.tssrc/main/rate-limits/rate-limit-service-test-harness.tssrc/main/rate-limits/service-account-target-selection.test.tssrc/main/rate-limits/service-antigravity-usage.test.tssrc/main/rate-limits/service-cursor-usage.test.tssrc/main/rate-limits/service-inactive-account-previews.test.tssrc/main/rate-limits/service-live-claude-usage.test.tssrc/main/rate-limits/service-minimax-usage.test.tssrc/main/rate-limits/service-opencode-go-credentials.test.tssrc/main/rate-limits/service-refresh-orchestration.test.tssrc/main/rate-limits/service-window-activation.test.tssrc/main/rate-limits/service-zcode-usage.test.tssrc/main/rate-limits/service/service-full-cycle-application.tssrc/main/rate-limits/service/service-full-cycle-preparation.tssrc/main/rate-limits/service/service-polling.tssrc/main/rate-limits/service/service-state.tssrc/main/rate-limits/service/service-types.tssrc/renderer/src/components/settings/appearance-status-bar-kiro-toggle-search.tssrc/renderer/src/components/settings/appearance-status-bar-search.tssrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/StatusBarProviderSegment.tsxsrc/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsxsrc/renderer/src/components/status-bar/status-bar-agent-gating.test.tssrc/renderer/src/components/status-bar/status-bar-agent-gating.tssrc/renderer/src/components/status-bar/status-bar-provider-letter.test.tssrc/renderer/src/components/status-bar/status-bar-provider-visibility.tssrc/renderer/src/components/status-bar/tooltip-reset-label.test.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/components/status-bar/usage-error-copy.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.test.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.tssrc/renderer/src/components/status-bar/use-status-bar-controller.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/runtime/agent-resume-host-authority-capability.tssrc/renderer/src/store/slices/ui-hydration-workspace-preferences.test.tssrc/renderer/src/store/slices/ui/ui-slice-hydration-status-bar-items.tssrc/shared/agent-hook-listener/provider-dispatch.tssrc/shared/agent-hook-listener/provider-event-routing.tssrc/shared/agent-hook-listener/providers/kiro-events.test.tssrc/shared/agent-hook-listener/providers/kiro-events.tssrc/shared/agent-hook-listener/providers/kiro-tool-fields.tssrc/shared/agent-hook-listener/source-routing.tssrc/shared/agent-hook-relay.tssrc/shared/agent-hook-types.tssrc/shared/agent-resume-argv.tssrc/shared/agent-session-resume-runtime-capabilities.tssrc/shared/agent-session-resume.tssrc/shared/ai-vault-resume-command.tssrc/shared/ai-vault-types.tssrc/shared/persisted-ui-state-types.tssrc/shared/rate-limit-state-factory.tssrc/shared/rate-limit-types.tssrc/shared/rpc-contract/client-ui-params.tssrc/shared/status-bar-defaults.tssrc/shared/ui-chrome-types.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
5c05ceb to
6422766
Compare
Kiro CLI uses $KIRO_HOME in place of ~/.kiro for both its agent configs and its sessions (verified on kiro-cli 2.28), so a relocated home left Kiro panes without status hooks and its conversations out of history. Resolve both paths through one shared helper; SSH hosts keep the CLI's default since their environment is not visible over SFTP.
52115b7 to
08f0a6f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
77a2aac7-034f-4ad5-ba05-7f0ba168d4e0
📒 Files selected for processing (6)
src/main/ai-vault/session-scanner-agent-sources.tssrc/main/ai-vault/session-scanner-kiro-parser.tssrc/main/kiro/hook-service.test.tssrc/main/kiro/hook-settings.tssrc/shared/kiro-home.test.tssrc/shared/kiro-home.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
…tus-and-history # Conflicts: # src/renderer/src/i18n/locales/en.json
…ice suites The shared rate-limit test harness resets fetchKiroRateLimits on every run, so a suite that does not mock kiro-usage-fetcher fails before its first assertion with 'mockResolvedValue is not a function'. These two suites lost the mock in an earlier rebase of the Kiro usage branch.
On an SSH host the Kiro installer always patched <home>/.kiro/agents, so a host that sets KIRO_HOME got hooks on inactive configs and none on the agents Kiro actually loads. The host-side runtime now reads KIRO_HOME from the login shell, the same probe it already runs for GROK_HOME (both run in parallel), and the installer and its status use that one directory. Adding the test exposed that the host-side SFTP stand-in returned an empty readdir, so the remote install could never see any Kiro agent. It now returns entry names, matching the WSL adapter.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d5c0110d-0fa4-4c45-9ae5-b3f91c80a067
📒 Files selected for processing (17)
config/tsconfig.cli.jsonsrc/main/agent-hooks/managed-hook-local-filesystem.tssrc/main/agent-hooks/managed-hook-runtime.test.tssrc/main/agent-hooks/managed-hook-runtime.tssrc/main/agent-hooks/remote-managed-hook-installers.tssrc/main/kiro/hook-service.test.tssrc/main/kiro/hook-service.tssrc/main/kiro/hook-settings.tssrc/main/rate-limits/service-cursor-usage.test.tssrc/main/rate-limits/service-live-claude-usage.test.tssrc/main/rate-limits/service-opencode-go-credentials.test.tssrc/renderer/src/components/status-bar/StatusBarProviderSegment.tsxsrc/renderer/src/components/status-bar/usage-provider-settings-target.tssrc/renderer/src/components/status-bar/use-status-bar-controller.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/agent-resume-argv.tssrc/shared/rate-limit-types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
The detail always said ~/.kiro/agents, which points users to the wrong place when KIRO_HOME is set locally or probed on an SSH host.
Carries forward the fixes from stablyai#26390 that the stablyai#14001 head does not have: - Local agent detection validates a configured KIRO_CLI_PATH with the same resolution the usage fetcher uses, so a Kiro CLI outside PATH keeps its meter and menu toggle; an invalid configured command is not detected, and WSL detection is unaffected. - The usage command is killed at the 1 MiB output cap and truncated output is rejected instead of being parsed as a valid total. - Reset descriptions that are not ISO dates (for example "01/01") are kept as display text instead of failing to parse.
|
Tip For best results, initiate chat on the files or code changes.
🧠 Learnings usedIf you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
|
Closing this in favor of smaller PRs that don't depend on each other. Kiro agent status and session history are now in the new Kiro PR (fixes #26694). It's built on Thanks to CodeRabbit for the reviews here. The fixes from this thread carried over to the new Kiro PR. |
ELI5
Orca learns what a coding agent is doing by having the agent "ping" Orca at key moments (prompt sent, tool running, turn finished). It builds the session history by reading the files each agent saves. Kiro was set up for neither, so Orca could launch Kiro but could not tell when it was working or done, and could not see its past conversations. This PR teaches Orca both, and fixes three gaps in the Kiro usage meter.
What Changed
Before:
Other agents behaved normally.
After:
Mechanism:
src/main/kiro/). Kiro has no global hook file; hooks live inside each agent config.agentSpawn,userPromptSubmit,preToolUse,postToolUse,stop) to every global agent in$KIRO_HOME/agents/*.json(default~/.kiro). User hooks are left untouched, and uninstall removes only Orca's entries./hook/kiro.shelsewhere, so the existing wrappers are reused. SSH hosts get the same install over SFTP.providers/kiro-events.ts). Kiro's payload has the same fields as Claude's (session_id,prompt,tool_name,tool_input,assistant_response), only with camelCase event names, so it reuses the existing Claude tool-field extraction.session-scanner-kiro-parser.ts).$KIRO_HOME/sessions/cli/<id>.json(metadata) plus<id>.jsonl(transcript). The transcript is streamed, because tool outputs make these files megabytes.parent_session_id) are left out, the same way Claude's subagents are.kiro-cli chat --tui --resume-id <id>.KIRO_CLI_PATHdetection. Before: a Kiro CLI outsidePATHwas not detected, so its usage meter and menu toggle disappeared. After: local detection validates the configured command with the same resolution the usage fetcher uses. An invalid configured command is not detected, and WSL detection is unaffected./usagecommand was capped at 1 MiB, but a cut-off read could still be parsed as a real total. After: the process is killed at the cap and truncated output is rejected.YYYY-MM-DDreset dates parsed, so other descriptions such as01/01showed a parse error. After: any description is kept as display text, still without inventing a reset time.Why
Hooks are the source of truth every other agent uses (the hook server's status store). Pets, sidebar, notifications and mobile therefore pick Kiro up with no reader-side changes.
Alternatives considered:
kiroand never reflects working or idle, so there is nothing reliable to match.--agent. This would override the user's chosen default agent and lose their tools and permissions.kiro_defaultagent file. We can't reproduce its built-in config faithfully.The usage fixes keep the meter honest. Detection and fetching resolve the same command, so the menu never offers a meter that cannot run, and a capped read is never shown as a real number.
Known limit: a user who only uses the built-in
kiro_defaultagent has no file to patch. The hook status says so and points them tokiro-cli agent create.Linked Issue
No separate issue: this is the agent-status and history follow-up to #14001, and it supersedes #26390 (related to #9559).
Visual Proof
A recording will follow in a comment. It shows a Kiro pane going idle → working → done with the pet and the notification, and Kiro rows in Agent session history.
Testing
Tested on Windows 11 with
kiro-cli2.28:--no-interactiveand the--tuimode Orca launches. All five events fire in the TUI. Subagents do not fire the parent's hooks.userPromptSubmit → preToolUse → postToolUse → stoparrived on/hook/kirowith the right token and pane key.kiro-cli chat --resume-id <id>restores the conversation.KIRO POWER, 49.1% used, reset2026-11-01.Automated:
New tests:
src/main/kiro/hook-service.test.ts,providers/kiro-events.test.tsandsession-scanner-kiro-parser.test.ts. Kiro is also added to the every-agent vault fixture and the hook registry coverage tests.New usage tests: the non-ISO reset description, the output-limit kill and truncated-output rejection, and
KIRO_CLI_PATHdetection (configured command found, broken configured command, WSL unaffected).Checks on this branch:
tscpasses for node, cli and web, and the Kiro, hook-registry and usage tests pass.Pre-existing Windows failures: 8 AI Vault scanner tests fail on Windows (
EBUSYtemp-dir cleanup andCODEX_HOMEpath quoting). They fail the same way on the base commit without this change.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude Code (Claude Opus 5.5), directed and reviewed by me.
Review
Agent skill upstream boundary
Notes
kiroto the resumable agents widensterminal.ensureAgentSession's enum. Kiro resume is therefore gated on a newagent-session.kiro-resume.v1runtime capability, and older hosts fall back instead of failing./hook/kiro..bak. Unparseable files are reported and left untouched.agentSpawn/userPromptSubmithook output into the model context..jsonand.jsonlstats.working: the agent is mid-tool.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)