Skip to content

fix(llc): show Company OS router notices as toasts via live events (#21045) - #21090

Merged
mrveiss merged 23 commits into
mainfrom
issue-21045
Nov 11, 2026
Merged

mrveiss merged 23 commits into
mainfrom
issue-21045

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Refs #21045

Thinking Path

Company OS router events are republished to the company:{id} live channel, which every member receives, but nothing in the UI turned them into a notice. The unused useLLCNotifications.ts was a parallel transport with zero importers. The canonical path is useLiveEvents().subscribe('company:{id}') and display through useNotificationBus (toasts).

Single-issue rationale

One defect: router notices never reach a user. The new composable, its mount point, its strings, the removal of the dead parallel transport and the tests all belong to that one fix.

What Changed

  • New useLlcCompanyNotices composable: maps event_type to an i18n key and level, calls the notification bus. heartbeat_missed warns (dedicated string for recovery_unfiled); budget_warning_80/95 warn; budget_exhausted is a sticky error; agent_*, approval_*, sprint_* are info; unknown types use the generic string; heartbeat_ok and llc:activity_created are ignored. It re-subscribes on company change and unsubscribes on unmount.
  • Mounted in LlcCompanyLayout.vue (stays mounted across company routes). LlcSidebar.vue is untouched.
  • llc.notices.* keys in en.json (English only).
  • Removed useLLCNotifications.ts (zero importers, no test imports).
  • Tests: vitest LlcCompanyLayout.notices.test.ts and repo_tests/llc_notices_wired_21045_test.py.

Owner decisions applied: replace and remove the old composable; show notices as toasts through the notification bus (budget exhaustion sticky); a persistent notification list is a separate feature.

Not delivered: AC3 (the in-app store), because autobot_shared/store_authority.py is held by #21027. The dropped llc:notifications:* budget and handoff notices are tracked in #21080. Recipient filtering is #20885 (the composable notes this).

Verification

  • vitest views/llc + components/llc: 70 files, 586 tests passed (5 new). Run locally with a temporary vitest config aliasing reka-ui to a stub, because reka-ui is not installed locally; that config was deleted and is not in the PR.
  • eslint on touched frontend files: clean; vue-tsc: no errors in touched files.
  • pytest: new guard plus the fast-guard list (includes fragmentation and size ratchets): 2033 passed.

Model Used

Claude Sonnet 5.5

🤖 Generated with Claude Code

@mrveiss mrveiss added this to the M2 - Company OS workflow-ready milestone Nov 7, 2026
@mrveiss mrveiss added frontend area: company-os Wave 4 · cluster A — Company OS & LLC canvas phase:M2.3 Goals and work hierarchy labels Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6cd72da and ccd68fc.

Files selected for processing: 8

  • autobot-backend/services/notification_service.py
  • autobot-frontend/src/composables/useLLCNotifications.ts
  • autobot-frontend/src/composables/useLlcCompanyNotices.ts
  • autobot-frontend/src/i18n/locales/en.json
  • autobot-frontend/src/views/llc/LlcCompanyLayout.vue
  • autobot-frontend/src/views/llc/__tests__/LlcCompanyLayout.notices.test.ts
  • autobot_shared/store_authority.py
  • repo_tests/llc_notices_wired_21045_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at 47f2d1b

Verdict: CHANGES (two should-fix items; nothing blocks the design)

Checked: 0 behind main; 6 files; no failing checks; no inline review threads, one bot comment that only reports a rate limit.

# Severity File Finding Fix
1 Medium composables/useLlcCompanyNotices.ts No flood control. A burst of events gives one toast per event. budget_exhausted goes through notifyError, which is sticky (duration 0), so repeats stack sticky toasts the user must dismiss one by one. A heartbeat_missed storm across many agents does the same at warning level. Dedupe by type+agent inside a short window (env-backed constant, not hard-coded) and/or coalesce to one toast with a count. Add a test for a burst of N identical events giving 1 toast.
2 Medium composables/useLlcCompanyNotices.ts:11 Imports useLiveEvents, which is marked @deprecated in favour of useEventBus (identical API). A new caller adds to the migration backlog. Import useEventBus from @/composables/useEventBus.
3 Low en.json llc.notices.generic/approval/sprint Unknown, approval_* and sprint_* events render the raw event_type ("Company update: mystery_thing"), which is not a safe fallback for an unlisted type. Make the generic text type-free ("A company update arrived") and keep the raw type in the logger only. Update the test expectation.
4 Low LlcCompanyLayout.notices.test.ts The file name says Layout but it mounts a stub host with the composable. The wiring is only checked by a Python source-text grep (llc_notices_wired_21045_test.py), which passes even if the call were dead code. No test for a payload with no agent_id, a company: channel mismatch, or the burst case. No fixed sleeps (uses nextTick): good. Mount the real layout with mocked store/route, or rename the test. Drop or keep the grep test as a supplement only.
5 Info useLlcCompanyNotices.ts watch + useLiveEvents Lifecycle is correct: the watch stops the old subscription before the new one, onUnmounted(stop) cleans up, and a null id unsubscribes. useLiveEvents also keeps each unsub in its own list and calls it again on unmount; double-calling is harmless only if LiveEventService unsub is idempotent, and that list grows by one per company switch. Moving to useEventBus (same behaviour) does not change this; just confirm idempotence in the test.
6 Info Tenant isolation Verified OK. api/live_events.py::_authorize_llc_channel requires MembershipService.is_member for company:{id} (admins bypass, fails closed on error). A non-member cannot receive another company's events. The route param is used first, falling back to the selected company, so the channel follows the URL. None.
7 Info Removal of useLLCNotifications.ts Verified: on current main the only matches for useLLCNotifications are inside the file itself (no importers, no dynamic imports). Removal is safe. None.
8 Info Size and canon Composable 91 lines, resolveNotice and onEvent well under 30 lines, layout change small. Toasts go through useNotificationBus (canon). en.json keys all exist for every mapped key. No design-system violations seen. AC3/#21080 deferral is stated and consistent. None.

Items 1 and 2 should be fixed in this PR; 3 and 4 are cheap to include.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at f289270

Verdict: APPROVE. Delta reviewed: 032db6d and 0d5a91e (since 47f2d1b). 15 commits behind main.

# Item Result Evidence
1 Dedupe/coalesce in env-backed window, burst test, sticky toasts do not stack Fixed createNoticeDeduper keyed type+agent; LLC_NOTICE_DEDUPE_MS from VITE_LLC_NOTICE_DEDUPE_MS (30 s). Burst test: 10 identical hard stops plus a second agent give 2 error toasts, a third after the window (fake timers, no sleeps). Company-level hard stop x5 gives 1 toast
2 useEventBus replaces useLiveEvents Fixed Import and test mock both switched; subscribe(channel, cb) returns an unsubscribe, matching the composable
3 Type-free i18n; raw type logged at debug only Fixed {type} removed from generic/approval/sprint text; logger.debug('company notice', type) only
4 Real layout mounted; burst and missing agent_id tests Fixed Test mounts LlcCompanyLayout (router and store mocked, sidebar stubbed); missing-agent test asserts the NoAgent text and no throw
5 Notice map matches real producers; 5 dead names removed Fixed budget.soft_alert, budget.company_soft_alert, budget.hard_stop, budget.company_hard_stop, work_item.handoff, work_item.handoff_ready all exist in the producers. budget_warning_80/95, budget_exhausted, agent_paused, agent_resumed and their strings are gone. Table-driven test covers all 6 levels
6 Size/style rules OK Composable 133 lines, test 154 lines; every function under 30 lines; no fixed sleeps; no line-number comments
7 Minor, non-blocking: the dedupe map has no eviction Note One entry per type+agent per mounted layout, so it is bounded by the agent count and discarded on unmount
8 Minor, non-blocking: VITE_LLC_NOTICE_DEDUPE_MS is not listed in docs/developer/ENV_VARS.md Note Worth adding when the file is next touched
9 Unresolved threads None No unresolved review threads on this PR

@mrveiss

mrveiss commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Defect confirmed and fixed (ccd68fc).

Wire shape: the router passes the producer fields as payload (router.py, _event_payload); publisher.py builds an envelope {event_type, company_id, entity_type, entity_id, payload, actor_id, ts} with the producer fields under payload; live_event_manager.publish sends that whole envelope as the message's payload; LiveEventService and useEventBus pass it through untouched (LiveEvent.payload: Record<string, unknown>). So the producer fields are at ev.payload.payload. The composable read ev.payload.agent_id and ev.payload.reason, so recovery_unfiled was never selected, the agent name was lost, and every agent shared one dedupe key.

Fix (useLlcCompanyNotices.ts): added LlcEventEnvelope and LlcNoticeFields types plus a noticeFields(ev) helper. Both reads now go through it. No casts at call sites.

Tests (LlcCompanyLayout.notices.test.ts): every fixture now comes from a wire() factory that builds the real envelope, so a flat payload cannot pass. Added a test that different agents are not deduped together while the same agent and reason is. The existing recovery_unfiled test asserts the warning string with the agent name.

Other consumers: LlcSidebar and CompanyDashboard read only event_type, or the flat llc:activity_created payload, which is published separately by activity_log. Not affected.

Backend: test_notification_router.py pins the envelope's company_id and entity_id but not the nested payload holding the producer fields. Not added here.

Not run locally; needs CI.

@mrveiss mrveiss left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: APPROVE @ ccd68fc

Delta reviewed: ccd68fc (composable + notices test only; the rest since e35c623 is main merges). Previous approval: e35c623.

Wire shape verified hop by hop: liveness_monitor.py:343-353 and budget_watchdog.py:236 publish to Redis; router.py _event_payload + :209 hand the producer fields to publisher.py:56-64, which builds the envelope; live_event_manager.py:150-155 sends it whole as payload. The router is the only producer onto company:{id} live channels, so every handled type (heartbeat_missed, budget., work_item.handoff, approval_, sprint_, generic) arrives nested; none arrives flat. noticeFields returns {} for a missing or non-object inner payload, so agent is '' and the NoAgent text is used.

Severity File:line Finding Fix
Low useLlcCompanyNotices.ts:103-109 Dedupe key is `type agent, without reason. A second heartbeat_missed` with another reason for the same agent inside 30 s is merged. The test title says "agent and reason" but only covers agent.
Low useLlcCompanyNotices.ts:53 LlcEventEnvelope has no other definition in the frontend. Local placement is acceptable. Move to a shared types file if a second consumer appears.
Info backend tests test_notification_router.py checks only company_id/entity_id; the nested payload the frontend depends on is not pinned. Add an envelope contract test to #21338.

Tests: wire() matches publisher.py field for field; asserts are on rendered text; the recovery and dedupe tests would fail pre-fix (agent '' gives the NoAgent text and one merged toast). No new i18n keys, no console.*, no any. Unresolved threads: 0.

@mrveiss
mrveiss merged commit 70c327f into main Nov 11, 2026
87 checks passed
mrveiss added a commit that referenced this pull request Nov 11, 2026
@mrveiss
mrveiss deleted the issue-21045 branch November 11, 2026 22:40
@mrveiss

mrveiss commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Landed in #21323 (merge commit a0cfcc1). Content on main: useLlcCompanyNotices.ts (noticeFields line 64), wired at LlcCompanyLayout.vue:26; useLLCNotifications.ts removed.

timothybrush pushed a commit to timothybrush/AutoBot-AI that referenced this pull request Nov 11, 2026
This was referenced Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: company-os Wave 4 · cluster A — Company OS & LLC canvas frontend phase:M2.3 Goals and work hierarchy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant