Commit 7913cd5
Improve: Enforce 15MB max file size limit before downloading/viewing sandbox inspect files (#200)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds a 15MB max preview limit with pre-read size checks, introduces
explicit unreadable states (file_type, too_large), and updates viewer
messaging accordingly.
>
> - **Sandbox Inspect**:
> - **Preview size limit**: Introduces `MAX_VIEWABLE_FILE_SIZE_BYTES`
(15MB) and pre-checks file size via `files.getInfo` before reading.
Oversized files set `unreadable` with `reason: 'too_large'` and include
`size`.
> - **File content states**: Refactors to explicit types:
`TextFileContentState`, `ImageFileContentState`,
`UnreadableFileTypeContentState`, `UnreadableTooLargeContentState`.
> - **Error mapping**: On read errors and non-text/image blobs, sets
`unreadable` with `reason: 'file_type'`.
> - **Viewer UI**:
> - Renders size-specific message for oversized files and generic
message for unreadable type; wires new state variants.
> - **Utils**:
> - `determineFileContentState` now returns `unreadable` with `reason:
'file_type'` on decode failures.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
254300b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Jakub Novák <[email protected]>1 parent 1d5fbb7 commit 7913cd5
File tree
4 files changed
+71
-17
lines changed- src
- features/dashboard/sandbox/inspect
- filesystem
- lib/utils
4 files changed
+71
-17
lines changedLines changed: 18 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | 31 | | |
25 | | - | |
| 32 | + | |
26 | 33 | | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
32 | 41 | | |
33 | 42 | | |
34 | 43 | | |
35 | | - | |
36 | | - | |
| 44 | + | |
37 | 45 | | |
| 46 | + | |
| 47 | + | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| |||
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
325 | 342 | | |
326 | 343 | | |
327 | 344 | | |
| |||
337 | 354 | | |
338 | 355 | | |
339 | 356 | | |
340 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
341 | 361 | | |
342 | 362 | | |
343 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
117 | 123 | | |
118 | 124 | | |
119 | 125 | | |
120 | | - | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
151 | | - | |
| 157 | + | |
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
| |||
195 | 201 | | |
196 | 202 | | |
197 | 203 | | |
198 | | - | |
| 204 | + | |
| 205 | + | |
199 | 206 | | |
200 | 207 | | |
201 | 208 | | |
202 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
203 | 227 | | |
204 | 228 | | |
205 | | - | |
| 229 | + | |
206 | 230 | | |
207 | 231 | | |
208 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
0 commit comments