Skip to content

Conversation

@MohitAgrawal16
Copy link
Collaborator

@MohitAgrawal16 MohitAgrawal16 commented Aug 11, 2025

Fixes: #1414

Summary by CodeRabbit

  • New Features

    • Added per-stream statistics in Connection Sync History with an expandable section showing stream-level metrics in a compact table.
    • Expand/collapse toggle reveals per-stream metrics; toggle is disabled when no stats are available.
  • UI

    • Added a dedicated expand/collapse control alongside existing Logs/AI Summary toggles.
    • Increased Actions area width to improve layout and accommodate the new control.

@coderabbitai
Copy link

coderabbitai bot commented Aug 11, 2025

Walkthrough

Adds per-stream metrics to connection sync history: introduces a StreamStat type and stream_stats on ConnectionSyncJobObject, plus a collapsible StreamStatsTable UI rendered per sync row showing per-stream recordsCommitted and other metrics.

Changes

Cohort / File(s) Summary
Model & UI: Sync history + per-stream stats
src/components/Connections/ConnectionSyncHistory.tsx
- Added type StreamStat and stream_stats: StreamStat[] to ConnectionSyncJobObject.
- Introduced StreamStatsTable rendering per-stream rows (streamName, recordsEmitted, recordsCommitted, bytesEmitted, bytesCommitted, wasResumed, wasBackfilled).
- Added showStreamStats state and expand/collapse IconButton (ExpandMore/ExpandLess), disabled when no stats.
- Conditional rendering of StreamStatsTable beneath Logs column when expanded.
- Reorganized Actions area (Logs/AI-summary ToggleButtonGroup + stream stats toggle) and increased actions cell width to 350px.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SyncHistoryRow
  participant StreamStatsTable

  User->>SyncHistoryRow: Click stream stats toggle
  SyncHistoryRow->>SyncHistoryRow: set showStreamStats = true/false
  alt stream_stats present and showStreamStats true
    SyncHistoryRow->>StreamStatsTable: render(stream_stats)
  else no stream_stats
    SyncHistoryRow-->>User: toggle disabled
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Stream list with name and number of records pulled [#1414]
Display last synced time per stream [#1414] No per-stream timestamp or last_synced field added or displayed.
Display per-stream status (Synced/Failed/In Progress) [#1414] No per-stream status property or derived status column implemented.
Provide Airbyte-like stream pull summary view [#1414] Per-stream stats are shown inline per sync row; a centralized dedicated summary view was not added.

Out-of-scope changes

Code Change Explanation
Reorganized Actions area and widened actions cell to 350px (src/components/Connections/ConnectionSyncHistory.tsx) Layout/spacing adjustment not required by the linked issue objectives.
Added Logs/AI-summary ToggleButtonGroup reorganization (src/components/Connections/ConnectionSyncHistory.tsx) UI control reorganization is ancillary to adding per-stream data and not specified in the issue.

Suggested reviewers

  • fatchat

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce78244 and 8f1836e.

📒 Files selected for processing (1)
  • src/components/Connections/ConnectionSyncHistory.tsx (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/Connections/ConnectionSyncHistory.tsx (1)
src/config/constant.ts (1)
  • AIRBYTE_JOB_STATUS_FAILED (43-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks
🔇 Additional comments (4)
src/components/Connections/ConnectionSyncHistory.tsx (4)

95-103: LGTM! StreamStat type is well-defined and addresses previous feedback.

The introduction of the dedicated StreamStat type improves type safety and code maintainability by providing a structured definition for stream statistics data.


224-224: LGTM! Stream stats toggle state is properly initialized.

The showStreamStats state initialization follows React best practices and integrates well with the existing component state management.


376-376: Actions column width increase is appropriate.

The width increase from 300px to 350px accommodates the new stream stats toggle button while maintaining proper layout proportions.


432-467: LGTM! Stream stats layout implementation is well-structured.

The conditional rendering and responsive layout logic properly handles different states:

  • Flexbox direction changes based on content presence
  • Proper flex ratios for optimal space distribution
  • Guards against undefined stream_stats data

The implementation successfully provides the requested stream visibility feature from issue #1414.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/stream_info

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/components/Connections/ConnectionSyncHistory.tsx (2)

366-366: Actions column width increase

The 350px width resolves space for the new icon. Consider using theme spacing to keep consistency, but this is fine as-is.

-            width: '350px',
+            width: 350,

430-434: Render per-stream stats: good conditional; consider column span in detail row

The conditional render is correct. Minor: the detail row above uses colSpan={5} while the table has 6 columns. Using columns.length keeps it resilient and avoids layout quirks if headers change.

Apply this diff (on the detail row’s TableCell):

-        <TableCell colSpan={5} style={{ paddingBottom: 0, paddingTop: 0 }}>
+        <TableCell colSpan={columns.length} style={{ paddingBottom: 0, paddingTop: 0 }}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2942ca5 and 50f6cfe.

📒 Files selected for processing (1)
  • src/components/Connections/ConnectionSyncHistory.tsx (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/Connections/ConnectionSyncHistory.tsx (1)
src/config/constant.ts (1)
  • AIRBYTE_JOB_STATUS_FAILED (43-43)
🔇 Additional comments (4)
src/components/Connections/ConnectionSyncHistory.tsx (4)

25-25: LGTM: icon imports for expand/collapse

Imports are correct and match usage below.


214-215: State for stream stats toggle looks good

Local UI state to control expand/collapse is appropriate. No issues.


106-114: Does stream_stats include per-stream status/last-synced? Objective gap

Issue #1414 asks for per-stream: Name, Number of Records Pulled, Last Synced Time, and Status. The current UI shows Name + Records Committed only. If the backend provides per-stream status and timestamps, we can extend the table easily; if not, we may need API changes.

Would you confirm the backend payload shape for stream_stats? If fields like status or lastSyncedAt exist (or can be derived), I can follow up with a patch to display them.

Also applies to: 170-195, 403-417


106-114: Ensure JSON key mapping for stream_stats
The ConnectionSyncJobObject.stream_stats type uses camelCase properties (streamName, recordsEmitted, etc.), but the raw Airbyte API returns snake_case JSON (stream_name, records_emitted, etc.). Without a casing conversion step, those fields will be undefined at runtime.

• Verify the httpGet helper in helpers/http.ts (or wherever it’s defined) to see if it converts snake_case keys to camelCase.
• If it doesn’t, add a transformation either inside httpGet or immediately after calling fetchAirbyteSyncs to map stream_stats keys from snake_case → camelCase.
• Audit any other code paths or DTOs that consume stream_stats to ensure they all expect the same shape.

@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 72.72727% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.94%. Comparing base (2942ca5) to head (8f1836e).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...c/components/Connections/ConnectionSyncHistory.tsx 72.72% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1643      +/-   ##
==========================================
- Coverage   75.96%   75.94%   -0.03%     
==========================================
  Files         102      102              
  Lines        7769     7789      +20     
  Branches     1867     1886      +19     
==========================================
+ Hits         5902     5915      +13     
- Misses       1753     1842      +89     
+ Partials      114       32      -82     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MohitAgrawal16
Copy link
Collaborator Author

image

@himanshudube97

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (4)
src/components/Connections/ConnectionSyncHistory.tsx (4)

171-205: Improve StreamStatsTable: stable keys and right-align numeric column

  • Use a stable key (streamName) instead of array index.
  • Right-align numeric values for readability.
  • Optional: remove the global center text-align to let per-column alignment apply cleanly.
-const StreamStatsTable = ({ streamStats }: { streamStats: StreamStat[] }) => {
+const StreamStatsTable = ({ streamStats }: { streamStats: StreamStat[] }) => {
   return (
     <Box sx={{ p: 2, display: 'flex', width: '100%' }}>
       <Table
         size="small"
         sx={{
           width: '100%',
           border: '1px solid #ccc',
           borderCollapse: 'collapse',
-          '& td, & th': {
-            border: '1px solid #ccc',
-            textAlign: 'center',
-          },
+          '& td, & th': {
+            border: '1px solid #ccc',
+          },
         }}
       >
         <TableHead>
           <TableRow>
             <TableCell sx={{ fontWeight: 700, color: '#00897B' }}>Stream Name</TableCell>
-            <TableCell sx={{ fontWeight: 700, color: '#00897B' }}>Records Committed</TableCell>
+            <TableCell sx={{ fontWeight: 700, color: '#00897B' }} align="right">
+              Records Committed
+            </TableCell>
           </TableRow>
         </TableHead>
         <TableBody>
-          {streamStats.map((stream, index) => (
-            <TableRow key={index}>
+          {streamStats.map((stream) => (
+            <TableRow key={stream.streamName}>
               <TableCell sx={{ fontWeight: 500 }}>{stream.streamName}</TableCell>
-              <TableCell sx={{ fontWeight: 500 }}>
+              <TableCell sx={{ fontWeight: 500 }} align="right">
                 {stream.recordsCommitted.toLocaleString()}
               </TableCell>
             </TableRow>
           ))}
         </TableBody>
       </Table>
     </Box>
   );
 };

413-427: Add accessibility: aria-label/aria-expanded and optional tooltip for the stream stats toggle

The toggle IconButton lacks an accessible label and state. Add aria-label and aria-expanded. Consider a Tooltip; wrap in a span so tooltips work when disabled.

Apply this diff:

-            <IconButton
+            <IconButton
               size="small"
               onClick={() => setShowStreamStats(!showStreamStats)}
               disabled={
                 !connectionSyncJob.stream_stats || connectionSyncJob.stream_stats.length === 0
               }
               sx={{
                 color: '#00897B',
                 '&.Mui-disabled': {
                   color: '#ccc',
                 },
               }}
+              aria-label={showStreamStats ? 'Hide stream stats' : 'Show stream stats'}
+              aria-expanded={showStreamStats}
             >
               {showStreamStats ? <ExpandLess /> : <ExpandMore />}
             </IconButton>

Optional Tooltip usage:

// add with other imports
import { Tooltip } from '@mui/material';
<Tooltip title={showStreamStats ? 'Hide stream stats' : 'Show stream stats'}>
  <span>
    <IconButton
      // ...same props as above
      aria-label={showStreamStats ? 'Hide stream stats' : 'Show stream stats'}
      aria-expanded={showStreamStats}
    >
      {showStreamStats ? <ExpandLess /> : <ExpandMore />}
    </IconButton>
  </span>
</Tooltip>

Optional: connect the button to content for a11y:

  • Add aria-controls on the IconButton: aria-controls={stream-stats-${connectionSyncJob.job_id}}
  • Add id on the container rendering StreamStatsTable: id={stream-stats-${connectionSyncJob.job_id}}

115-115: Make stream_stats optional to match UI guards and avoid type/usage mismatch

The UI checks for undefined stream_stats, but the interface marks it as required. Align typing with usage.

Apply this diff:

-interface ConnectionSyncJobObject {
+interface ConnectionSyncJobObject {
   job_type: ConnectionJobType;
   last_attempt_no: number;
   bytes_committed: string;
   created_at: string;
   job_id: number;
   logs: string[];
   records_committed: number;
   status: string;
   duration_seconds: number;
   reset_config: any | null;
-  stream_stats: StreamStat[];
+  stream_stats?: StreamStat[];
 }

392-397: Guard ToggleButtonGroup onChange null and narrow handleLogActions type

ToggleButtonGroup onChange can pass null. Currently you call handleLogActions unguarded and its signature expects string. Guard and narrow the type to avoid calling with null and to benefit from strict typing.

Apply these diffs:

-  const [action, setAction] = useState<'detail' | 'summary' | null>(null);
+  const [action, setAction] = useState<'detail' | 'summary' | null>(null);
 
-  const handleLogActions = (action: string) => {
+  const handleLogActions = (action: 'detail' | 'summary') => {
     if (action === 'summary' && summarizedLogs.length < 1) {
       summarizeLogs();
       trackAmplitudeEvent('[ai-summary] Button clicked');
     } else if (action === 'detail' && detailedLogs.length < 1) {
       getDetailedLogs();
       if (connectionSyncJob.status === AIRBYTE_JOB_STATUS_RUNNING) {
         pollForDetailedSyncLogs();
       }
     }
   };
-              onChange={(event, newAction) => {
-                setAction(newAction);
-                handleLogActions(newAction);
-                trackAmplitudeEvent('[connection-logs] Button clicked');
-              }}
+              onChange={(event, newAction: 'detail' | 'summary' | null) => {
+                setAction(newAction);
+                if (newAction) {
+                  handleLogActions(newAction);
+                  trackAmplitudeEvent('[connection-logs] Button clicked');
+                }
+              }}

Also applies to: 304-316

🧹 Nitpick comments (2)
src/components/Connections/ConnectionSyncHistory.tsx (2)

95-103: StreamStat type addition is good; verify API field casing alignment

Type is clear and usable. Ensure backend returns camelCase for these fields (streamName, recordsCommitted, etc.). If API uses snake_case, add a transformation layer or adapt the type accordingly.


440-444: Conditional stream stats rendering is good; ties back to optional typing

Rendering is correctly guarded against undefined/empty. This further supports marking stream_stats optional on the type to match usage.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4f2e4e and ce78244.

📒 Files selected for processing (1)
  • src/components/Connections/ConnectionSyncHistory.tsx (7 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/Connections/ConnectionSyncHistory.tsx (1)
src/config/constant.ts (1)
  • AIRBYTE_JOB_STATUS_FAILED (43-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks
🔇 Additional comments (1)
src/components/Connections/ConnectionSyncHistory.tsx (1)

25-25: Imports for expand/collapse icons look good

No issues; consistent with MUI icon usage.

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.

Provide stream syncs info like airbyte

2 participants