Skip to content

fix(ui): adjust docx and code rendering#4334

Merged
TheodoreSpeaks merged 3 commits intostagingfrom
fix/document-preview
Apr 29, 2026
Merged

fix(ui): adjust docx and code rendering#4334
TheodoreSpeaks merged 3 commits intostagingfrom
fix/document-preview

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Code generation was creating tooltips which are kinda overkill and word documents didn't respect container width sizing.
Fixed both.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Tested locally

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 29, 2026 2:25am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Low Risk
UI-only adjustments to preview rendering and editor options; primary risk is layout/regression in DOCX scaling or degraded editor assistance features.

Overview
DOCX previews are now post-processed to fit within the available panel width by scaling the .docx-wrapper and reapplying page styling via a shared applyPostRenderStyling() hook, including resize-aware reflow using ResizeObserver.

The Monaco text editor configuration is tightened to suppress suggestion UI (quick suggestions, trigger-based suggestions, word-based suggestions, hovers, parameter hints, codelens, lightbulb, and inlay hints) to avoid noisy tooltips during code generation/editing.

Reviewed by Cursor Bugbot for commit 33851c3. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 29, 2026

Greptile Summary

This PR fixes two UI rendering issues: DOCX files now scale to fit their container using CSS transforms with a ResizeObserver for reactive updates, and the Monaco code editor has IntelliSense features (hover tooltips, autocomplete, lightbulb, inlay hints) disabled to reduce noise for a display/generation context. The post-render styling logic is also neatly refactored into a shared useCallback.

Confidence Score: 4/5

Safe to merge — both changes are well-scoped UI fixes with no data or security risk.

Only P2 style/robustness findings: a hardcoded library-internal padding constant and an inline type cast for a Monaco enum. No logic errors or regressions identified.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/docx-preview.tsx Adds CSS scale-based fitting of docx pages to container width via fitDocxToContainer, a ResizeObserver for reactive rescaling, and refactors post-render styling into a reusable useCallback.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx Disables Monaco IntelliSense features (autocomplete, hover tooltips, code lens, lightbulb, inlay hints) to simplify the editor UX for code display/generation use.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[DocxPreview mounts] --> B[useEffect: ResizeObserver setup]
    B --> C[Observe containerRef]
    A --> D[useEffect: fileData rendered]
    A --> E[useEffect: streamingContent rendered]
    D --> F[renderAsync docx-preview lib]
    E --> G[fetch /api/docx/preview]
    G --> H[renderAsync docx-preview lib]
    F --> I[applyPostRenderStyling]
    H --> I
    I --> J[set background transparent]
    I --> K[set box-shadow on pages]
    I --> L[fitDocxToContainer]
    C --> |container resizes| L
    L --> M{naturalPageWidth?}
    M -- no --> N[return early]
    M -- yes --> O{scale >= 1?}
    O -- yes --> P[reset styles only, return]
    O -- no --> Q[apply CSS scale + negative margins to wrapper]
Loading

Reviews (1): Last reviewed commit: "fix(ui): adjust docx and code rendering" | Re-trigger Greptile

Use computed padding from `.docx-wrapper` instead of a hardcoded 60px
so the fit calculation survives docx-preview library changes. Replace
the inline `import()` cast for ShowLightbulbIconMode with a top-level
type import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant