Skip to content

Add session performance trend visualization to dashboard#75

Open
jwaldrip wants to merge 2 commits intomainfrom
claude/session-performance-visualization-JOKNc
Open

Add session performance trend visualization to dashboard#75
jwaldrip wants to merge 2 commits intomainfrom
claude/session-performance-visualization-JOKNc

Conversation

@jwaldrip
Copy link
Collaborator

Summary

Adds a new "Session Performance Trend" chart to the dashboard that visualizes weekly session efficiency metrics over the past 30 days. The chart displays three key performance indicators: average turns per session, average compactions per session, and effectiveness score, with trend indicators showing week-over-week improvement or regression.

Changes

  • New Component: PerformanceTrendChart.tsx - Interactive chart component with:

    • Weekly bar chart visualization with metric-specific coloring
    • Metric selector tabs to switch between turns, compactions, and effectiveness
    • Summary stats row showing current values with trend arrows
    • Color-coded bars (green for improvement, red for regression)
    • Responsive legend and educational callout
  • Backend: Added SessionPerformancePoint GraphQL type and performanceTrend field to DashboardAnalytics

    • Aggregates session data by week (Monday-based weeks)
    • Calculates averages for turns, compactions, and effectiveness scores
    • Sorts results chronologically
  • GraphQL Schema: Updated schema and generated types to include performanceTrend field with weekly performance data points

  • Dashboard Integration: Integrated PerformanceTrendChart into DashboardContent with proper data mapping and loading states

  • Fragment: Added performanceTrend query fragment to fetch required fields from backend

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation
  • New plugin

Testing

  • Existing tests pass
  • Component handles empty data gracefully with appropriate messaging
  • Chart properly scales bars based on metric values
  • Trend calculations correctly identify improvements vs regressions

Checklist

  • Code follows existing patterns (component structure, styling, data flow)
  • Self-review completed
  • No new warnings

https://claude.ai/code/session_01Gkip9YRmLjZbHKQyer3zZK

@railway-app
Copy link

railway-app bot commented Mar 23, 2026

🚅 Deployed to the han-pr-75 environment in han-team-platform

Service Status Web Updated (UTC)
api ✅ Success (View Logs) Mar 23, 2026 at 7:08 am
website ✅ Success (View Logs) Mar 23, 2026 at 7:04 am
2 services not affected by this PR
  • postgres
  • redis

Adds a weekly performance trend chart showing avg turns, compactions,
and effectiveness score per session over time. Helps track whether
AI sessions are becoming more focused and efficient.

- New SessionPerformancePoint type in Rust GraphQL API
- Weekly aggregation computed from scored sessions using chrono
- PerformanceTrendChart component with metric toggle tabs
- Regression highlighting (red bars when metrics worsen week-over-week)
- Integrated into Browse dashboard between Compaction Health and Session Effectiveness

https://claude.ai/code/session_01Gkip9YRmLjZbHKQyer3zZK
@jwaldrip jwaldrip force-pushed the claude/session-performance-visualization-JOKNc branch from 0cee8eb to 1f44e94 Compare March 23, 2026 07:03
@railway-app railway-app bot temporarily deployed to han-team-platform / han-pr-75 March 23, 2026 07:03 Destroyed
@claude
Copy link

claude bot commented Mar 23, 2026

test comment from claude agent - ignore

@claude
Copy link

claude bot commented Mar 23, 2026

Code Review

Good overall addition - the weekly trend chart fills a real gap in session observability, and the Rust aggregation logic is clean. A few issues worth addressing before merge.


MODERATE

1. React Native Web violations in PerformanceTrendChart.tsx and DashboardContent.tsx

Per .claude/rules/browse/react-native-first.md, HTML/web-only CSS properties must not be used in browse-client. This PR has three violations:

PerformanceTrendChart.tsx x-axis label (line 256): uses style whiteSpace nowrap which is web-only. Fix: remove whiteSpace - React Native does not support it and short month labels do not need it.

PerformanceTrendChart.tsx empty state (line 150): uses minHeight as a string pixel value (120px). String pixel values are CSS, not React Native. Fix: use minHeight: 120 as a number.

DashboardContent.tsx loading state box: uses display flex, alignItems center, justifyContent center, and minHeight 120px in an inline style prop. Fix: replace with the Center atom and minHeight: 120.

2. Schema documentation regression in schema.graphql

The PR strips all per-field documentation from SessionFilter and the type-level description, replacing them with generic boilerplate. Field-level docs are also removed. This is a consumer-facing regression - IDE tooling and GraphQL clients surface these descriptions. If the derive macro now controls SDL generation, it should be extended to accept doc strings rather than stripping them.


MINOR

3. SessionPerformancePoint fields should be non-null

All six fields are declared nullable in the schema but the Rust code always produces Some(...) - there is no code path that returns None. They should be declared non-null to reflect the actual API contract.

4. X-axis label logic shows too few labels for typical data windows

With 30 days of data there are ~4-5 weeks. The current logic (idx === 0 or idx % 4 === 0) shows only two labels when data spans 4-5 points. Consider anchoring first and last labels, or showing all when there are 6 or fewer data points.

5. Performance trend silently excludes unscored sessions

The trend is computed from scored_sessions, which only includes sessions that completed the effectiveness scoring pipeline. Users with new installations will see an empty chart even though sessions exist. A note in the Rust code would help future maintainers.


Good feature overall. The BTreeMap aggregation for naturally-sorted weekly keys is a nice touch. The main blockers are the RN violations (item 1) and the schema doc regression (item 2).

@claude
Copy link

claude bot commented Mar 23, 2026

PR Review: Add session performance trend visualization to dashboard

Overall this is a well-structured addition. The backend computes metrics correctly, the frontend component handles empty states, and the Relay-generated types are up to date. A few issues worth addressing before merge.


MODERATE ISSUES

theme.borderRadius.md: inconsistent key path vs rest of file. In PerformanceTrendChart.tsx (callout box near the bottom): borderRadius: theme.borderRadius.md. Other uses in the same file correctly use theme.radii.full. While theme.borderRadius is an alias for theme.radii so this works, it is inconsistent. Change to theme.radii.md to match the rest of the file.

Performance trend iterates over scored_sessions: verify no LIMIT truncates it. The performance_trend block reuses scored_sessions, which is built from the same SQL effectiveness query. If that query ever gains a LIMIT (for performance), lower-scoring sessions could be silently excluded from weekly aggregation, skewing trend data. Add a comment or assertion clarifying the query is unlimited here, or compute the trend from a separate query.

Division by zero risk in trend computation: avg_turns: Some((turns / count as f64 * 10.0).round() / 10.0). count is incremented before this map so it is always >= 1 in current code, but this is fragile. If the entry insertion logic ever changes, this produces silent NaN. Guard with if count > 0.


MINOR ISSUES

All SessionPerformancePoint fields are Option-T but never null. In the Rust code all fields are always Some(...). Consider making them non-nullable in the GraphQL schema (Float!, String!, Int!) to match how other computed analytics types are modeled. The frontend already handles nullability with ?? 0 fallbacks but a cleaner schema is preferable.

Hardcoded hex colors bypass design system. COLORS turns:#f59e0b compactions:#f97316 effectiveness:#10b981 plus inline #ef4444, #3b82f6, rgba(59,130,246,0.1). Consistent with other chart components in the codebase, but noting for future theming work.

Key includes redundant index: weekStart is already unique per week; the -idx suffix is unnecessary. The label row below uses only weekStart correctly.

SessionFilter doc comment regression. The schema diff replaces detailed per-field docs with generic Auto-generated filter input type. / Association filter (auto-generated). comments. If the macro generates these, it should preserve meaningful descriptions.


POSITIVE

  • Weekly bucketing with ISO Monday alignment and BTreeMap for natural chronological sort is clean and correct.
  • Empty state and loading skeleton are handled properly at both component and container level.
  • Metric selector tabs and trend arrows are a good UX addition.
  • Relay-generated types are properly regenerated and in sync with the schema.
  • ConfigDir, HookExecution, and NativeTask gaining the Node interface is consistent with the existing node() resolver cases already in query.rs.

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