Skip to content

Add Pre-Check File Size and Type Before File Preview - #3427

Merged
xuang7 merged 3 commits into
masterfrom
xuan-precheck-file-preview
May 8, 2025
Merged

xuang7 merged 3 commits into
masterfrom
xuan-precheck-file-preview

Conversation

@xuang7

@xuang7 xuang7 commented May 6, 2025

Copy link
Copy Markdown
Contributor

Purpose:

Fixes issue #3422. When a user opens a file that’s too large or an unsupported type, the UI shows the loading spinner until it finally errors out. This pr adds a size/type pre-check before displaying the spinner so that the user immediately sees the “cannot preview” message instead of waiting.

Changes:

In user-dataset-file-renderer.component.ts:

  • Validate file 'MIME' type against 'MIME_TYPES' and size against 'MIME_TYPE_SIZE_LIMITS_MB' before initiating the loading spinner.

In dataset-detail.component.html:

  • Bind the parent’s 'currentFileSize' into the previewer component so the renderer can perform the size check.

Demonstration:

Too large file:
precheck

Unsupported file type:
type

Successful preview:
Loading:
load

Displayed:
preview

@xuang7 xuang7 self-assigned this May 6, 2025
@xuang7
xuang7 marked this pull request as ready for review May 6, 2025 02:34
@xuang7
xuang7 requested a review from bobbai00 May 6, 2025 02:48

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@bobbai00 bobbai00 changed the title Enhance File Preview with Pre-check Add FileSize pre-check before previewing a file May 6, 2025
@xuang7 xuang7 changed the title Add FileSize pre-check before previewing a file Add Pre-Check File Size And Type Before File Preview May 8, 2025
@xuang7 xuang7 changed the title Add Pre-Check File Size And Type Before File Preview Add Pre-Check File Size and Type Before File Preview May 8, 2025
@xuang7
xuang7 merged commit 5e5c515 into master May 8, 2025
@xuang7
xuang7 deleted the xuan-precheck-file-preview branch May 8, 2025 03:00
SarahAsad23 pushed a commit to madisonmlin/texera that referenced this pull request May 20, 2026
### **Purpose:**
Fixes issue apache#3422. When a user
opens a file that’s too large or an unsupported type, the UI shows the
loading spinner until it finally errors out. This pr adds a size/type
pre-check before displaying the spinner so that the user immediately
sees the “cannot preview” message instead of waiting.

### **Changes:**
In user-dataset-file-renderer.component.ts:
- Validate file 'MIME' type against 'MIME_TYPES' and size against
'MIME_TYPE_SIZE_LIMITS_MB' before initiating the loading spinner.

In dataset-detail.component.html:
- Bind the parent’s 'currentFileSize' into the previewer component so
the renderer can perform the size check.

### **Demonstration:**
**Too large file:**
<img width="1268" alt="precheck"
src="https://github.com/user-attachments/assets/a0b588ff-9480-4214-991a-306e0532c277"
/>



**Unsupported file type:**
<img width="859" alt="type"
src="https://github.com/user-attachments/assets/00d89c22-61ae-4913-9e0b-bde57335a837"
/>



**Successful preview:**
Loading:
<img width="801" alt="load"
src="https://github.com/user-attachments/assets/e5e58834-6d13-4255-9bd2-4e6fd1a4e324"
/>

Displayed:
<img width="1254" alt="preview"
src="https://github.com/user-attachments/assets/b19b6b65-a42e-4fae-9a18-cd632bb6c8e3"
/>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
### **Purpose:**
Fixes issue apache#3422. When a user
opens a file that’s too large or an unsupported type, the UI shows the
loading spinner until it finally errors out. This pr adds a size/type
pre-check before displaying the spinner so that the user immediately
sees the “cannot preview” message instead of waiting.

### **Changes:**
In user-dataset-file-renderer.component.ts:
- Validate file 'MIME' type against 'MIME_TYPES' and size against
'MIME_TYPE_SIZE_LIMITS_MB' before initiating the loading spinner.

In dataset-detail.component.html:
- Bind the parent’s 'currentFileSize' into the previewer component so
the renderer can perform the size check.

### **Demonstration:**
**Too large file:**
<img width="1268" alt="precheck"
src="https://github.com/user-attachments/assets/a0b588ff-9480-4214-991a-306e0532c277"
/>



**Unsupported file type:**
<img width="859" alt="type"
src="https://github.com/user-attachments/assets/00d89c22-61ae-4913-9e0b-bde57335a837"
/>



**Successful preview:**
Loading:
<img width="801" alt="load"
src="https://github.com/user-attachments/assets/e5e58834-6d13-4255-9bd2-4e6fd1a4e324"
/>

Displayed:
<img width="1254" alt="preview"
src="https://github.com/user-attachments/assets/b19b6b65-a42e-4fae-9a18-cd632bb6c8e3"
/>
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 17, 2026
### What changes were proposed in this PR?

Remove unreachable code from dataset creation, dashboard search, and
file previews, and rename the dataset creator to match the model
creator. **+245/−388 lines across fourteen files.**

- The dashboard and result export both open the modal to create a
dataset. Versions are created on the dataset detail page, so the shared
creator form always shows its visibility and downloadability switches.
- With only dataset creation left, `UserDatasetVersionCreatorComponent`
becomes `UserDatasetCreatorComponent` and moves from
`user-dataset-explorer/` to `user-dataset/user-dataset-creator/`,
matching `UserModelCreatorComponent` in
`user-model/user-model-creator/`. GitHub shows its `.ts` as a new file
because the move and the version-mode removal together change most of
it.
- Dashboard search has no callers for the public or all scopes.
- HTML, PDF, MS Word, and MS PowerPoint suffixes already fall through to
the unsupported-preview notice. The preview guard rejects binary files
before the size lookup, and every type it accepts has its own size
limit, so the default limit is never used.

| Code | Introduced by | Usage removed by |
| --- | --- | --- |
| Modal version mode | apache#3296 | apache#3659 |
| Creator form switch toggle | apache#2413 | apache#3659 |
| Dashboard search scopes | apache#2987 | apache#3129 |
| Binary preview size limit | apache#2413 | apache#3149 |
| Default preview size limit | apache#2413, apache#3427 | Never reached |
| Unsupported MIME aliases | apache#2413 | Never selected a viewer |

The modal mode and its switch toggle have been unreachable since August
2025, the search scopes since January 2025, and the binary size limit
since December 2024.

### Any related issues, documentation, discussions?

Closes apache#9462.

### How was this PR tested?

From `frontend/` on Node 24

```sh
NODE_OPTIONS=--max-old-space-size=8192 yarn test --progress=false \
  --include='**/{user-dataset-file-renderer,user-dataset-creator,user-model-creator,user-dataset,result-exportation,result-table-frame,context-menu,dataset-detail,version-uploader}.component.spec.ts'
yarn exec tsc --noEmit -p src/tsconfig.app.json
yarn exec tsc --noEmit -p src/tsconfig.spec.json
yarn format:ci
yarn build
```

509 tests passed across nine suites. The preview test now checks that
the four affected suffixes still show the unsupported-preview state
without a request to the backend. Both creation entry points, the model
creator that shares the creator form, and the dataset version uploader
are covered by the targeted run.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Codex (GPT-6) and Claude Code (Claude Opus 5.5)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants