Skip to content

feat(mobile): add one-off agent briefings - #8303

Merged
iscekic merged 12 commits into
mainfrom
feat/manual-agent-briefing
Oct 22, 2026
Merged

iscekic merged 12 commits into
mainfrom
feat/manual-agent-briefing

Conversation

@iscekic

@iscekic iscekic commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add one-off agent briefings from the mobile Briefings screen. Users select Personal or one organization, choose a preset or custom historical period, and review coverage, the payer, the model, and the cost bound before creating a report.

Confirmed reports remain available in History while AI generation runs. They preserve the selected period and historical state without changing the morning schedule or automatic AI settings. Empty periods save without an AI request or charge.

Confirmation is idempotent. Account changes discard pending results. Source-access changes invalidate frozen evidence, including charges omitted from displayed details. Busy periods use bounded samples across the whole period and show partial-coverage warnings.

Paid confirmation remains native-only and is excluded from the MCP catalog.

Verification

  • Exercised Android creation, cost review, generation, History restoration, custom dates, and empty reports against an isolated backend and deterministic local inference provider.
  • Exercised real HTTP preparation, duplicate confirmation, generation, and history against isolated PostgreSQL.
  • Verified morning settings remain unchanged and empty reports create no generation job.
  • Passed focused backend, mobile, and MCP regressions for account changes, high-volume provenance, bounded snapshots, historical state, and pagination.
  • Passed web, database, and mobile type checks, scoped lint, translation catalog checks, and plural checks.
  • Retained main’s latest-model pricing fix.
  • Verified the generated migration against populated scheduled reports. The existing scheduled index and report data remain unchanged.
  • Independent backend and mobile reviews completed; their findings are fixed and covered by regressions.
  • iOS device smoke is not exercised.
  • All CI checks pass on the latest head.

Deployment

The generated report migration must precede backend promotion. The existing production workflow already gates promotion on its migration job. No new secrets, environment variables, feature flags, or external services are required.

The existing database enum snapshot check has a baseline mismatch for the todo session-origin enum; schema-to-migration consistency passes. No production migration or deployment was performed during verification.

Comment thread services/kilo-mcp/catalog.json Resolved
@kilo-code-bot

kilo-code-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The two PR commits after the previously reviewed increment are a CI-generated kilo-mcp catalog refresh (required-seconds datetime pattern plus procedure counts) and a one-line fix making listBriefings honour the requested page size; both are benign, the replaced clamp now matches the router's z.number().int().min(1).max(100) bound and the mobile screen's limit: 30, and all earlier findings remain fixed.

Assumptions: [INFERENCE] The incremental range c6c26bc1bc..HEAD also contains the 337-commit origin/main merge, so I scoped review to the PR's own new commits (3f981da5a, f1d19f5a9, bbdc18498) and verified upstream-merged files only where they intersect the PR; services/kilo-mcp/catalog.json is CI-generated from the router schemas and was checked only for denylist coverage (agentBriefing.createOneOff/generateSummary/retrySummary/updateContextPreferences remain excluded) rather than line-by-line. No .md image usage or new mount/subscription (memory-leak) surface is introduced by this increment.

Files Reviewed (3 files)
  • apps/web/src/lib/agent-briefing/store.ts - 0 issues (limit clamp removal verified against agent-briefing-router.ts:203 max 100 and briefing-list-screen.tsx page size 30; cursor and 3 MB byte-cap logic unchanged and still consistent)
  • apps/mobile/src/components/agent-briefing/briefing-period-label.tsx - 0 issues (routes all three instants through formatBriefingTimestamp, which falls back to the device zone on unknown zones)
  • services/kilo-mcp/catalog.json - 0 issues (generated refresh; no new credential, secret, membership, deploy, purchase, or delete mutation exposed)
Previous Review Summaries (4 snapshots, latest commit c6c26bc)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c6c26bc)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The only PR change since the prior review is 3f981da5a, which routes BriefingPeriodLabel through the existing formatBriefingTimestamp helper, and the helper matches the call sites, types, and time-zone fallback; the previously fixed provenance-cap and bucket-boundary findings remain fixed at HEAD.

Assumptions: [INFERENCE] The 0294 migration rename on main and the main-merge resolution were not re-derived beyond checking that the prior fixed files still contain their fixes; no .md documentation or memory-leak-relevant code is introduced by this increment.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Files Reviewed (5 files)
  • apps/mobile/src/components/agent-briefing/briefing-period-label.tsx - 0 issues
  • apps/mobile/src/components/agent-briefing/briefing-window.ts - 0 issues (helper signature and fallback verified against all three call sites)
  • apps/web/src/lib/agent-briefing/one-off-evidence.ts - 0 issues (byte cap still applies to displayed facts only)
  • apps/web/src/lib/agent-briefing/evidence.ts - 0 issues (all event buckets still end with lt)
  • apps/web/src/lib/agent-briefing/store.ts - 0 issues (targeted check only)

Previous review (commit bf23863)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The new snapshot size guard can still reject a valid heavy one-off because the fixed provenance arrays are never shrunk, and the last event bucket samples the cutoff instant that aggregation discards.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/agent-briefing/one-off-evidence.ts 124 The byte-cap loop only shrinks sessions and sources, so the fixed evidenceEventIds/evidenceSessionIds/evidenceUsage provenance (up to ~448 production event ids of 120-170 bytes, 256 session ids, and 128 usage references) can exceed the 64,000-byte snapshot cap and throw BAD_REQUEST for a legitimate 31-day report.

SUGGESTION

File Line Issue
apps/web/src/lib/agent-briefing/evidence.ts 368 The last event bucket uses lte(cutoffAt) while aggregation skips non-status events at or after cutoff and usage uses lt; a cutoff-instant activity event consumes a bucket/sample slot, can force truncated, and can add a session with no in-window evidence.
Files Reviewed (15 files)
  • apps/web/src/lib/agent-briefing/one-off-evidence.ts - 1 warning
  • apps/web/src/lib/agent-briefing/evidence.ts - 1 suggestion
  • apps/web/src/lib/agent-briefing/store.ts - 0 issues
  • apps/web/src/lib/agent-briefing/summary.ts - 0 issues
  • apps/web/src/lib/agent-briefing/sweep.ts - 0 issues
  • apps/web/src/routers/agent-briefing-router.one-off.test.ts - 0 issues
  • apps/web/src/scripts/mcp-catalog/catalog.ts - 0 issues
  • apps/web/src/scripts/mcp-catalog/catalog.test.ts - 0 issues
  • packages/db/src/schema.ts - 0 issues
  • packages/db/src/migrations/0292_heavy_guardian.sql - 0 issues
  • packages/db/src/migrations/meta/0292_snapshot.json - generated, not reviewed
  • packages/db/src/migrations/meta/_journal.json - generated, not reviewed
  • services/kilo-mcp/catalog.json - 0 issues (createOneOff removed from the catalog)
  • .kilo/skills/kilo-mcp/SKILL.md - 0 issues
  • apps/mobile/README.md - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit e6f505d)

Status: 3 Issues Found | Recommendation: Address before merge

Executive Summary

The latest revision (e6f505d, account-change fencing, ANY($1::text[]) provenance lookups, and evidence subsampling) introduces no new defects; the three previously raised warnings remain unresolved in current HEAD.

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/db/src/migrations/0292_heavy_guardian.sql 7 DROP INDEX plus a non-concurrent CREATE UNIQUE INDEX and two validating ADD CONSTRAINT ... CHECK statements take ACCESS EXCLUSIVE locks on the populated agent_briefing_reports table; the file is unchanged in this revision.
services/kilo-mcp/catalog.json 101 agentBriefing.createOneOff is a newly cataloged mutation that finalizes a one-off report and starts a billed AI summary; an MCP agent can obtain an estimateToken via estimateSummary and spend up to the configured cap without human confirmation, and the catalog entry is unchanged.
apps/web/src/lib/agent-briefing/store.ts 602 The one-off path still runs the unbounded collectBriefingEvidence over up to 31 days and persists every session/source in facts for get/list; the new subsampling in summary.ts only bounds the model prompt, not the stored snapshot or the API response.
Files Reviewed (8 files changed in this revision)
  • apps/web/src/lib/agent-briefing/summary.ts - 0 new issues (historical evidence is now resampled evenly from the original sample; omission counts stay consistent with allSources)
  • apps/web/src/lib/agent-briefing/evidence.ts - 0 new issues (= ANY($1::text[]) matches the existing repo pattern and avoids the parameter-count limit)
  • apps/web/src/lib/agent-briefing/store.ts - 0 new issues in changed lines (prior unbounded-evidence finding re-verified at line 602)
  • apps/mobile/src/lib/hooks/use-create-briefing.ts - 0 new issues (epoch fencing mirrors use-session-mutations; WeakMap keys do not retain operations)
  • apps/mobile/src/lib/hooks/use-create-briefing.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/hooks/use-create-briefing-test-utils.tsx - 0 issues
  • apps/web/src/routers/agent-briefing-router.one-off.test.ts - 0 issues
  • apps/mobile/README.md - 0 issues

Previous review (commit 7eff193)

Status: 3 Issues Found | Recommendation: Address before merge

Executive Summary

Highest-risk items are the new MCP-exposed paid-generation mutation and a migration that rebuilds a unique index and validates CHECK constraints on a populated table without concurrent DDL.

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/db/src/migrations/0292_heavy_guardian.sql 7 DROP INDEX + non-concurrent CREATE UNIQUE INDEX + ADD CONSTRAINT ... CHECK take table-blocking locks and validate every row on the populated agent_briefing_reports table; repo convention is concurrent index DDL and NOT VALID/VALIDATE CONSTRAINT.
services/kilo-mcp/catalog.json 101 agentBriefing.createOneOff is a newly cataloged mutation that starts billed AI generation; an MCP agent can mint an estimate token via estimateSummary and spend up to the configured cap without human confirmation. Needs justification or exclusion.
apps/web/src/lib/agent-briefing/store.ts 602 One-off snapshots reuse the unbounded evidence collector over up to 31 days; all sessions/sources are persisted in facts and returned verbatim by get/list, so active accounts can create very large rows and multi-MB responses. Only the model prompt is bounded.
Files Reviewed (121 files)
  • packages/db/src/migrations/0292_heavy_guardian.sql - 1 issue
  • packages/db/src/schema.ts - 0 issues (schema/migration consistent)
  • apps/web/src/lib/agent-briefing/store.ts - 1 issue
  • apps/web/src/lib/agent-briefing/summary.ts - 0 issues
  • apps/web/src/lib/agent-briefing/evidence.ts - 0 issues
  • apps/web/src/lib/agent-briefing/sweep.ts - 0 issues
  • apps/web/src/routers/agent-briefing-router.ts - 0 issues
  • packages/app-shared/src/agent-briefing.ts - 0 issues
  • apps/mobile/src/lib/hooks/use-create-briefing.ts - 0 issues (no leaked subscriptions/timers)
  • apps/mobile/src/lib/agent-briefing-period.ts - 0 issues
  • apps/mobile/src/lib/agent-briefing-state.ts - 0 issues
  • apps/mobile/src/lib/agent-briefing.ts - 0 issues
  • apps/mobile/src/components/agent-briefing/* - 0 issues (create, review, detail, list, period picker/label, summary, card)
  • apps/mobile/src/app/(app)/_layout.tsx, apps/mobile/src/app/(app)/agent-briefing/create.tsx - 0 issues
  • apps/mobile/src/i18n/locales/*.json - 0 issues (new keys present in all 100 locale bundles)
  • services/kilo-mcp/catalog.json - 1 issue
  • .kilo/skills/kilo-mcp/SKILL.md, apps/mobile/README.md - 0 issues
  • New/changed tests (agent-briefing-router.one-off.test.ts, summary.test.ts, period/picker/hook/cache tests) - 0 issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 71.4K · Output: 12.8K · Cached: 1.3M

Review guidance: REVIEW.md from base branch main

iscekic and others added 4 commits October 22, 2026 17:06
…efing

# Conflicts:
#	.kilo/skills/kilo-mcp/SKILL.md
#	apps/mobile/src/components/agent-briefing/briefing-detail-screen.tsx
#	apps/mobile/src/i18n/locales/km.json
#	apps/web/src/lib/agent-briefing/store.ts
#	packages/db/src/migrations/meta/0292_snapshot.json
#	packages/db/src/migrations/meta/_journal.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants