Skip to content

feat(intelligence): add Namespace Overview#2964

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
aashir-athar:feat/namespace-overview
May 30, 2026
Merged

feat(intelligence): add Namespace Overview#2964
senamakel merged 3 commits into
tinyhumansai:mainfrom
aashir-athar:feat/namespace-overview

Conversation

@aashir-athar
Copy link
Copy Markdown
Contributor

@aashir-athar aashir-athar commented May 29, 2026

Summary

Adds a new read-only "Namespaces" tab — the first lens whose primary axis is the namespace dimension. Every memory fact carries a namespace ("work", "personal", or null for un-namespaced); this view shows how the user's knowledge is distributed across those contexts — the distinct facts and entities recorded in each — so lopsided or empty contexts are visible at a glance.

Design

  • Pure & deterministic (lib/memory/namespaceOverview.ts): groups relations by their namespace field (null = un-namespaced), counting distinct triples and distinct entities per namespace, plus a global distinct-entity total. No clock, no RNG; collision-free JSON.stringify triple keys; sorted by factCount desc, namespace asc, with the un-namespaced bucket last (relation-order-invariant).
  • Zero new core surface: reuses only memoryGraphQuery — one all-namespaces call, grouped client-side. Read-only. Notably it needs no namespace selector (this view is the namespace breakdown), so it makes a single query.
  • Container/presentational split; the container guards the load with a monotonic request token; summary tiles (namespaces / facts / entities) + a ranked per-namespace bar list (facts bar + entity count), capped at 50 with a truncation note. i18n across all 13 locales.

Edge cases (tested)

Empty graph, multi-namespace aggregation, per-namespace triple de-dup, an entity shared across namespaces (counted per-namespace but once globally), the null/un-namespaced bucket sorting last, malformed rows dropped, and order-invariance.

Test plan

  • vitest — 17 tests (engine aggregation/dedup/global-dedup/null-bucket/order-invariance; api facade; panel states; container load + error)
  • tsc --noEmit — clean
  • eslint — 0 errors
  • prettier --check — clean
  • i18n coverage gate — EXIT 0, no unused namespaceOverview.* keys

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a Namespace Overview tab in Intelligence showing per-namespace and total metrics (namespaces, facts, entities), proportional bars, un‑namespaced labeling, and truncation notice when results are capped.
    • Includes loading skeletons, error handling with Retry, and comprehensive localization for the new UI across multiple languages.

Review Change Stack

@aashir-athar aashir-athar requested a review from a team May 29, 2026 17:33
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This PR implements a Namespace Overview feature: deterministic aggregation of graph relations by namespace, an API wrapper, container loader component, presentational panel with loading/error/empty states and truncation, Intelligence page tab integration, tests, and translations across 14 locales.

Changes

Namespace Overview Feature

Layer / File(s) Summary
Core namespace aggregation logic and types
app/src/lib/memory/namespaceOverview.ts, app/src/lib/memory/namespaceOverview.test.ts
Defines NamespaceStat and NamespaceOverviewReport; implements computeNamespaceOverview that filters valid string triples, groups by namespace (null for unnamespaced), de-duplicates facts per-namespace and entities globally, and sorts by descending fact count with deterministic tie-breaking; tests validate aggregation, dedupe, sorting, malformed filtering, and order invariance.
API service layer
app/src/services/api/namespaceOverviewApi.ts, app/src/services/api/namespaceOverviewApi.test.ts
Adds loadNamespaceOverview() which calls memoryGraphQuery(), logs relation count, and returns computeNamespaceOverview results; tests verify full-graph fetching, empty result handling, error propagation, and public API surface.
Container component with state management
app/src/components/intelligence/NamespaceOverviewTab.tsx, app/src/components/intelligence/NamespaceOverviewTab.test.tsx
Implements NamespaceOverviewTab that loads data on mount, tracks report/loading/error state, uses a monotonic request id to ignore stale results, and delegates rendering to NamespaceOverviewPanel; tests assert loader invocation and error rendering.
Presentational UI component
app/src/components/intelligence/NamespaceOverviewPanel.tsx, app/src/components/intelligence/NamespaceOverviewPanel.test.tsx
Adds NamespaceOverviewPanel rendering loading skeleton (role="status"), error alert with optional retry callback, empty state, and main UI with summary tiles and ranked namespace rows (including (un-namespaced) label), proportional fact bars, and truncation notice; tests cover the loading/empty/error/populated states.
Intelligence page integration
app/src/pages/Intelligence.tsx
Adds the namespaces tab: imports NamespaceOverviewTab, extends IntelligenceTab union, adds tab entry with t('memory.tab.namespaces'), and conditionally renders the tab content.
Multilingual i18n support
app/src/lib/i18n/en.ts, app/src/lib/i18n/ar.ts, app/src/lib/i18n/bn.ts, app/src/lib/i18n/de.ts, app/src/lib/i18n/es.ts, app/src/lib/i18n/fr.ts, app/src/lib/i18n/hi.ts, app/src/lib/i18n/id.ts, app/src/lib/i18n/it.ts, app/src/lib/i18n/ko.ts, app/src/lib/i18n/pl.ts, app/src/lib/i18n/pt.ts, app/src/lib/i18n/ru.ts, app/src/lib/i18n/zh-CN.ts
Adds memory.tab.namespaces and a namespaceOverview.* translation group across locales (title/intro, loading/error/empty states, retry label, metric labels, unnamespaced/truncated messaging).

Sequence Diagram

sequenceDiagram
  participant UI as NamespaceOverviewTab
  participant API as loadNamespaceOverview
  participant Panel as NamespaceOverviewPanel
  UI->>API: loadNamespaceOverview()
  API-->>UI: NamespaceOverviewReport / Error
  UI->>Panel: pass report, loading, error, onRetry
  Panel->>UI: onRetry() (user)
  UI->>API: loadNamespaceOverview() (retry)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • graycyrus
  • sanil-23

Poem

🐰 I hopped through graphs both wide and deep,

Counting facts the memory keeps,
Bars that grow and labels true,
Tabs and texts in languages new,
Retry a click, the view returns—hooray for code that leaps!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(intelligence): add Namespace Overview' directly and clearly describes the main change: adding a new Namespace Overview feature to the Intelligence component. It is concise, specific, and accurately summarizes the primary functionality introduced in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added feature Net-new user-facing capability or product behavior. memory Memory store, memory tree, recall, summarization, and embeddings in src/openhuman/memory/. working A PR that is being worked on by the team. labels May 29, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 29, 2026
@sanil-23 sanil-23 self-assigned this May 29, 2026
A new read-only "Namespaces" tab — the first lens whose primary axis is the
namespace dimension. Shows how the user's knowledge is distributed across
contexts: the distinct facts and entities recorded in each namespace, so
lopsided or empty contexts are visible at a glance.

- Pure deterministic engine (lib/memory/namespaceOverview.ts): groups relations
  by their namespace field (null = un-namespaced), counting distinct triples and
  distinct entities per namespace plus a global distinct-entity total. No clock,
  no RNG; sorted by factCount desc, namespace asc, with the un-namespaced bucket
  last. Collision-free triple keys.
- Zero new core surface: reuses ONLY memoryGraphQuery (one all-namespaces call,
  grouped client-side). Read-only. No namespace selector — this view shows them
  all — so it needs no per-namespace re-query.
- Container guards the load with a request token; summary tiles (namespaces /
  facts / entities) + a ranked per-namespace bar list, capped with a truncation
  note. i18n across all 13 locales.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts:
#	app/src/lib/i18n/chunks/ar-1.ts
#	app/src/lib/i18n/chunks/bn-1.ts
#	app/src/lib/i18n/chunks/de-1.ts
#	app/src/lib/i18n/chunks/en-1.ts
#	app/src/lib/i18n/chunks/es-1.ts
#	app/src/lib/i18n/chunks/fr-1.ts
#	app/src/lib/i18n/chunks/hi-1.ts
#	app/src/lib/i18n/chunks/id-1.ts
#	app/src/lib/i18n/chunks/it-1.ts
#	app/src/lib/i18n/chunks/ko-1.ts
#	app/src/lib/i18n/chunks/pt-1.ts
#	app/src/lib/i18n/chunks/ru-1.ts
#	app/src/lib/i18n/chunks/zh-CN-1.ts
#	app/src/lib/i18n/en.ts
#	app/src/pages/Intelligence.tsx
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 30, 2026
# Conflicts:
#	app/src/pages/Intelligence.tsx
@senamakel senamakel merged commit 6c3ad63 into tinyhumansai:main May 30, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Net-new user-facing capability or product behavior. memory Memory store, memory tree, recall, summarization, and embeddings in src/openhuman/memory/. working A PR that is being worked on by the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants