Skip to content

Conversation

@lefarcen
Copy link
Contributor

@lefarcen lefarcen commented Dec 18, 2025

Summary

Fix file preview truncation on share pages and correct resultId mapping when duplicating canvas drive files.

File Preview (Frontend):

  • Added disableTruncation prop to FilePreview, CodeRenderer, MarkdownRenderer, and JsonRenderer
  • Share file pages now display full file content without 20-line truncation limit
  • Card mode still uses truncation (20 lines), preview mode uses extended limit (2000 lines)

Canvas Duplication (Backend):

  • Fixed duplicated DriveFiles retaining old resultId instead of mapped new resultId
  • Added post-duplication update step to replace resultId using replaceEntityMap

Impact Areas

  • Free-form Canvas Interface
  • Other (Share Pages, Canvas Duplication)

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Summary by CodeRabbit

  • New Features

    • Added optional control to disable content truncation in file previews for code, JSON, and markdown files.
  • Chores

    • Improved file duplication process with enhanced record mapping updates.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

This PR introduces two independent features: post-duplication housekeeping in the share service to update driveFile resultId mappings using fileId mappings, and a new global disableTruncation flag threaded through the file preview rendering system to conditionally disable content truncation.

Changes

Cohort / File(s) Change Summary
Share duplication housekeeping
apps/api/src/modules/share/share-duplication.service.ts
Adds post-duplication update logic to fetch driveFile records for new fileIds and update their resultId using replaceEntityMap when mappings exist; logs count of updated files.
File preview truncation control
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts, index.tsx, code.tsx, markdown.tsx
Introduces optional disableTruncation prop to SourceRendererProps and FilePreview; threads flag through CardRenderer, JsonRenderer, CodeRenderer, MarkdownRenderer, and HtmlRenderer; conditionally applies truncation and displays TruncationNotice in preview mode. Removes share page detection logic (useMatch).
Drive file share usage
packages/web-core/src/pages/drive-file-share/index.tsx
Passes disableTruncation prop to FilePreview component invocation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • apps/api/src/modules/share/share-duplication.service.ts: Verify the resultId update logic correctly applies mappings and that the driveFile fetch/update operations use appropriate error handling.
  • File preview components: Ensure disableTruncation is consistently threaded through all renderer paths and that default truncation behavior is preserved when the flag is omitted.
  • Integration: Confirm that the TruncationNotice display logic correctly triggers only in preview mode when truncation occurs.

Possibly related PRs

Suggested reviewers

  • mrcfps
  • CH1111

Poem

🐰 Files now remember where they came from,
IDs mapped with care, no more humdrum!
And truncation? Just disable it, friend—
Let content flow freely, end to end! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes both main changes: disabling truncation for shared files and updating resultId mapping during duplication.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mashu/bugs

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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/web-core/src/pages/drive-file-share/index.tsx (1)

17-17: Remove debug console.log statement.

This console.log appears to be a debug artifact that should be removed before merging to production.

🔎 Apply this diff to remove the debug statement:
-  console.log('driveFileData', driveFileData);
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx (1)

147-156: Potential stale closure in useEffect cleanup.

The cleanup function captures a stale reference to fileContent?.url because fileContent is not in the dependency array. When the effect re-runs due to fetchFileContent changing, the cleanup from the previous render will reference the old fileContent.url value, which may have already been revoked or be null.

🔎 Consider using a ref to track the URL for cleanup:
+  const objectUrlRef = useRef<string | null>(null);
+
   useEffect(() => {
     fetchFileContent();

     // Cleanup object URL on unmount
     return () => {
-      if (fileContent?.url) {
-        URL.revokeObjectURL(fileContent.url);
+      if (objectUrlRef.current) {
+        URL.revokeObjectURL(objectUrlRef.current);
+        objectUrlRef.current = null;
       }
     };
   }, [fetchFileContent]);

Then update the setFileContent call to also set the ref:

+        objectUrlRef.current = url;
         setFileContent({
           data: arrayBuffer,
           contentType,
           url,
         });
🧹 Nitpick comments (2)
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx (1)

13-27: Consider extracting truncateContent to a shared utility.

This function is duplicated in both markdown.tsx and code.tsx with identical logic. Extracting it to a shared utility would improve maintainability and adhere to DRY principles.

🔎 Suggested approach:

Create a shared utility file (e.g., utils.ts in the same directory):

// utils.ts
export const truncateContent = (
  content: string,
  maxLines: number,
  maxChars: number,
  disableTruncation = false,
): { content: string; isTruncated: boolean } => {
  if (disableTruncation) {
    return { content, isTruncated: false };
  }
  const lines = content.split('\n');
  if (lines.length <= maxLines && content.length <= maxChars) {
    return { content, isTruncated: false };
  }
  return { content: lines.slice(0, maxLines).join('\n').slice(0, maxChars), isTruncated: true };
};

Then import and use in both markdown.tsx and code.tsx.

packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx (1)

14-38: truncateContent and TruncationNotice are duplicated.

Both truncateContent function and TruncationNotice component are identical to those in markdown.tsx. Consider extracting these to a shared module to reduce duplication.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45ad187 and 66bd491.

📒 Files selected for processing (6)
  • apps/api/src/modules/share/share-duplication.service.ts (1 hunks)
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx (4 hunks)
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx (6 hunks)
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx (4 hunks)
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts (1 hunks)
  • packages/web-core/src/pages/drive-file-share/index.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (21)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{js,ts,jsx,tsx}: Always use optional chaining (?.) when accessing object properties
Always use nullish coalescing (??) or default values for potentially undefined values
Always check array existence before using array methods
Always validate object properties before destructuring
Always use single quotes for string literals in JavaScript/TypeScript code

**/*.{js,ts,jsx,tsx}: Use semicolons at the end of statements
Include spaces around operators (e.g., a + b instead of a+b)
Always use curly braces for control statements
Place opening braces on the same line as their statement

**/*.{js,ts,jsx,tsx}: Group import statements in order: React/framework libraries, third-party libraries, internal modules, relative path imports, type imports, style imports
Sort imports alphabetically within each import group
Leave a blank line between import groups
Extract complex logic into custom hooks
Use functional updates for state (e.g., setCount(prev => prev + 1))
Split complex state into multiple state variables rather than single large objects
Use useReducer for complex state logic instead of multiple useState calls

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}

📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)

**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}: All code comments MUST be written in English
All variable names, function names, class names, and other identifiers MUST use English words
Comments should be concise and explain 'why' rather than 'what'
Use proper grammar and punctuation in comments
Keep comments up-to-date when code changes
Document complex logic, edge cases, and important implementation details
Use clear, descriptive names that indicate purpose
Avoid abbreviations unless they are universally understood

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)

Use JSDoc style comments for functions and classes in JavaScript/TypeScript

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)

**/*.{js,jsx,ts,tsx}: Use single quotes for string literals in TypeScript/JavaScript
Always use optional chaining (?.) when accessing object properties in TypeScript/JavaScript
Always use nullish coalescing (??) or default values for potentially undefined values in TypeScript/JavaScript
Always check array existence before using array methods in TypeScript/JavaScript
Validate object properties before destructuring in TypeScript/JavaScript
Use ES6+ features like arrow functions, destructuring, and spread operators in TypeScript/JavaScript
Avoid magic numbers and strings - use named constants in TypeScript/JavaScript
Use async/await instead of raw promises for asynchronous code in TypeScript/JavaScript

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/03-typescript-guidelines.mdc)

**/*.{ts,tsx}: Avoid using any type whenever possible - use unknown type instead with proper type guards
Always define explicit return types for functions, especially for public APIs
Prefer extending existing types over creating entirely new types
Use TypeScript utility types (Partial<T>, Pick<T, K>, Omit<T, K>, Readonly<T>, Record<K, T>) to derive new types
Use union types and intersection types to combine existing types
Always import types explicitly using the import type syntax
Group type imports separately from value imports
Minimize creating local type aliases for imported types

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{js,ts,jsx,tsx,css,json}

📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)

Maximum line length of 100 characters

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{js,ts,jsx,tsx,css,json,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)

Use 2 spaces for indentation, no tabs

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{js,ts,jsx,tsx,css,json,yml,yaml,md}

📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)

No trailing whitespace at the end of lines

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{css,scss,sass,less,js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/09-design-system.mdc)

**/*.{css,scss,sass,less,js,jsx,ts,tsx}: Primary color (#155EEF) should be used for main brand color in buttons, links, and accents
Error color (#F04438) should be used for error states and destructive actions
Success color (#12B76A) should be used for success states and confirmations
Warning color (#F79009) should be used for warnings and important notifications
Info color (#0BA5EC) should be used for informational elements

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)

**/*.{tsx,ts}: Use the translation wrapper component and useTranslation hook in components
Ensure all user-facing text is translatable

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{tsx,ts,json}

📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)

Support dynamic content with placeholders in translations

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{tsx,ts,jsx,js,vue,css,scss,less}

📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)

**/*.{tsx,ts,jsx,js,vue,css,scss,less}: Use the primary blue (#155EEF) for main UI elements, CTAs, and active states
Use red (#F04438) only for errors, warnings, and destructive actions
Use green (#12B76A) for success states and confirmations
Use orange (#F79009) for warning states and important notifications
Use blue (#0BA5EC) for informational elements
Primary buttons should be solid with the primary color
Secondary buttons should have a border with transparent or light background
Danger buttons should use the error color
Use consistent padding, border radius, and hover states for all buttons
Follow fixed button sizes based on their importance and context
Use consistent border radius (rounded-lg) for all cards
Apply light shadows (shadow-sm) for card elevation
Maintain consistent padding inside cards (p-4 or p-6)
Use subtle borders for card separation
Ensure proper spacing between card elements
Apply consistent styling to all form inputs
Use clear visual indicators for focus, hover, and error states in form elements
Apply proper spacing between elements using 8px, 16px, 24px increments
Ensure proper alignment of elements (left, center, or right)
Use responsive layouts that work across different device sizes
Maintain a minimum contrast ratio of 4.5:1 for text

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{tsx,ts,jsx,js,vue}

📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)

**/*.{tsx,ts,jsx,js,vue}: Include appropriate loading states for async actions in buttons
Group related form elements with appropriate spacing
Provide clear validation feedback for forms
Ensure proper labeling and accessibility for form elements
Ensure all interactive elements are keyboard accessible
Include appropriate ARIA attributes for complex components
Provide alternative text for images and icons
Support screen readers with semantic HTML elements

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)

**/*.{ts,tsx,js,jsx}: Follow the TypeScript/JavaScript style guidelines
Ensure code is well-tested and documented

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • apps/api/src/modules/share/share-duplication.service.ts
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{jsx,tsx}: Always use tailwind css to style the component
Always wrap pure components with React.memo to prevent unnecessary re-renders
Always use useMemo for expensive computations or complex object creation
Always use useCallback for function props to maintain referential equality
Always specify proper dependency arrays in useEffect to prevent infinite loops
Always avoid inline object/array creation in render to prevent unnecessary re-renders
Always use proper key props when rendering lists
Always split nested components with closures into separate components to avoid performance issues and improve code maintainability

**/*.{jsx,tsx}: Always wrap pure components with React.memo to prevent unnecessary re-renders
Always use useMemo for expensive computations or complex object creation in React
Always use useCallback for function props to maintain referential equality in React
Always specify proper dependency arrays in useEffect to prevent infinite loops in React
Always avoid inline object/array creation in render to prevent unnecessary re-renders in React
Always use proper key props when rendering lists in React (avoid using index when possible)
Always split nested components with closures into separate components in React
Use lazy loading for components that are not immediately needed in React
Debounce handlers for events that might fire rapidly (resize, scroll, input) in React
Implement fallback UI for components that might fail in React
Use error boundaries to catch and handle runtime errors in React

**/*.{jsx,tsx}: Place each attribute on a new line when a component has multiple attributes in JSX
Use self-closing tags for elements without children in JSX
Keep JSX expressions simple, extract complex logic to variables
Put closing brackets for multi-line JSX on a new line

**/*.{jsx,tsx}: Component file names should match the component name
Organize function components in order: imports, type definitions, constants, component function, hook calls, e...

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{jsx,tsx,css}

📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)

**/*.{jsx,tsx,css}: Use Tailwind CSS for styling components
Follow the utility-first approach with Tailwind CSS
Group related utility classes together in Tailwind CSS
Prefer Tailwind utilities over custom CSS when possible

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{jsx,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/05-code-organization.mdc)

Each component file should contain only one main component

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/index.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/05-code-organization.mdc)

Use index files to export multiple components from a directory

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/web-core/src/pages/drive-file-share/index.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/05-code-organization.mdc)

Explicitly type props with interfaces or types in React components

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)

Use React best practices for frontend code

Files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • packages/web-core/src/pages/drive-file-share/index.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
apps/api/src/**/*.{controller,service}.ts

📄 CodeRabbit inference engine (.cursor/rules/06-api-structure.mdc)

Implement proper error handling in API modules

Files:

  • apps/api/src/modules/share/share-duplication.service.ts
🧠 Learnings (9)
📚 Learning: 2025-11-25T03:04:05.715Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/05-code-organization.mdc:0-0
Timestamp: 2025-11-25T03:04:05.715Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Extract complex logic into custom hooks

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
📚 Learning: 2025-11-25T03:03:31.945Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/01-code-style.mdc:0-0
Timestamp: 2025-11-25T03:03:31.945Z
Learning: Applies to **/*.{jsx,tsx} : Implement fallback UI for components that might fail in React

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
📚 Learning: 2025-11-25T03:04:05.715Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/05-code-organization.mdc:0-0
Timestamp: 2025-11-25T03:04:05.715Z
Learning: Applies to **/*.{jsx,tsx} : Use ternary operators or && for conditional rendering in React

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx
📚 Learning: 2025-11-25T03:05:07.580Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/11-ui-design-patterns.mdc:0-0
Timestamp: 2025-11-25T03:05:07.580Z
Learning: Applies to **/*.{tsx,ts,jsx,js,vue,css,scss,less} : Ensure proper spacing between card elements

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
📚 Learning: 2025-11-25T03:05:07.580Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/11-ui-design-patterns.mdc:0-0
Timestamp: 2025-11-25T03:05:07.580Z
Learning: Applies to **/*.{tsx,ts,jsx,js,vue,css,scss,less} : Use subtle borders for card separation

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
📚 Learning: 2025-11-25T03:05:07.580Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/11-ui-design-patterns.mdc:0-0
Timestamp: 2025-11-25T03:05:07.580Z
Learning: Applies to **/*.{tsx,ts,jsx,js,vue,css,scss,less} : Maintain consistent padding inside cards (`p-4` or `p-6`)

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
📚 Learning: 2025-11-25T03:05:07.580Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/11-ui-design-patterns.mdc:0-0
Timestamp: 2025-11-25T03:05:07.580Z
Learning: Applies to **/*.{tsx,ts,jsx,js,vue,css,scss,less} : Use consistent border radius (`rounded-lg`) for all cards

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
📚 Learning: 2025-11-25T03:02:45.779Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T03:02:45.779Z
Learning: Applies to **/*.{jsx,tsx} : Always wrap pure components with React.memo to prevent unnecessary re-renders

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx
📚 Learning: 2025-11-25T03:04:41.334Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/09-i18n-guidelines.mdc:0-0
Timestamp: 2025-11-25T03:04:41.334Z
Learning: Applies to **/*.{tsx,ts,json} : Support dynamic content with placeholders in translations

Applied to files:

  • packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx
🧬 Code graph analysis (2)
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx (1)
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts (1)
  • SourceRendererProps (16-22)
packages/web-core/src/pages/drive-file-share/index.tsx (1)
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx (1)
  • FilePreview (85-264)
⏰ 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: build / Build
🔇 Additional comments (12)
packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/types.ts (1)

16-22: LGTM!

The disableTruncation optional boolean property is cleanly added to SourceRendererProps. The type extension is appropriate and follows TypeScript conventions.

packages/web-core/src/pages/drive-file-share/index.tsx (1)

74-76: LGTM!

The disableTruncation prop is correctly passed to FilePreview, enabling full content display for shared file pages as intended by the PR objectives.

packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/index.tsx (2)

78-91: LGTM!

The FilePreviewProps interface and component signature correctly add disableTruncation with an appropriate default value of false, maintaining backward compatibility.


182-237: LGTM!

The disableTruncation prop is consistently threaded to all relevant renderers (HtmlRenderer, MarkdownRenderer, CodeRenderer, JsonRenderer) ensuring uniform truncation behavior control across all file types.

packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/markdown.tsx (3)

39-51: LGTM!

The Card component correctly receives and uses disableTruncation, with proper useMemo dependency array including the new prop.


53-85: LGTM!

The Preview component properly handles disableTruncation and conditionally shows TruncationNotice only when content is actually truncated. The useMemo dependency array correctly includes disableTruncation.


87-119: LGTM!

The MarkdownRenderer correctly destructures and forwards disableTruncation to both Card and Preview child components, maintaining consistent prop threading throughout the component hierarchy.

packages/ai-workspace-common/src/components/canvas/canvas-resources/file-preview/code.tsx (4)

45-92: LGTM!

The CardRenderer correctly handles both card and preview modes with the disableTruncation prop. The dynamic truncation limits based on source and proper useMemo dependencies ensure correct behavior.


95-141: LGTM!

The PreviewRenderer properly integrates disableTruncation with correct useMemo dependencies and conditional TruncationNotice display.


146-185: LGTM!

The CodeRenderer correctly threads disableTruncation to both CardRenderer and PreviewRenderer, maintaining consistent truncation control across all code rendering paths.


187-216: LGTM!

The JsonRenderer correctly implements disableTruncation support with proper conditional logic for card vs preview modes and appropriate useMemo dependencies.

apps/api/src/modules/share/share-duplication.service.ts (1)

973-995: LGTM! Correctly implements resultId mapping for duplicated drive files.

This post-duplication housekeeping step properly addresses the bug where duplicated DriveFiles retained the old resultId. The implementation follows a safe pattern:

  1. Checks if file mappings exist before proceeding (line 975)
  2. Fetches the newly created drive files by their new fileIds
  3. Filters to only files with valid resultId mappings (line 983)
  4. Updates resultId in parallel using the replaceEntityMap
  5. Logs the count of updated files for observability

The non-null assertion on line 987 is safe because the filter on line 983 guarantees both file.resultId and the mapping exist. The sequential placement after entity duplication (line 971) prevents race conditions.

@lefarcen lefarcen merged commit 4b08ea3 into main Dec 19, 2025
2 checks passed
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.

3 participants