Commit bf0312f
Add drag-and-drop from preview directory to WaveAI panel (#2502)
Enables dragging files from preview directory listings directly into the
WaveAI panel for analysis.
## Changes
**Modified `frontend/app/aipanel/aipanel.tsx`:**
- Added `useDrop` hook to accept `FILE_ITEM` drag type from preview
directory
- Implemented `handleFileItemDrop` to:
- Read file content via `RpcApi.FileReadCommand` using the remote URI
- Convert base64 data to browser `File` object with proper MIME type
- Validate and add to panel using existing `model.addFile()` flow
- Integrated with existing drag overlay for visual feedback
- Rejects directories with appropriate error messaging
## Implementation
```typescript
const handleFileItemDrop = useCallback(
async (draggedFile: DraggedFile) => {
if (draggedFile.isDir) {
model.setError("Cannot add directories to Wave AI. Please select a file.");
return;
}
const fileData = await RpcApi.FileReadCommand(TabRpcClient, {
info: { path: draggedFile.uri }
}, null);
const bytes = new Uint8Array(atob(fileData.data64).split('').map(c => c.charCodeAt(0)));
const file = new File([bytes], draggedFile.relName, {
type: fileData.info?.mimetype || "application/octet-stream"
});
// Existing validation and addFile flow
await model.addFile(file);
},
[model]
);
const [{ isOver, canDrop }, drop] = useDrop(() => ({
accept: "FILE_ITEM",
drop: handleFileItemDrop,
collect: (monitor) => ({ isOver: monitor.isOver(), canDrop: monitor.canDrop() })
}), [handleFileItemDrop]);
```
No changes required to preview directory—it already exports `FILE_ITEM`
drag items. Works independently from native file system drag-and-drop.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>1 parent a19cb6f commit bf0312f
4 files changed
Lines changed: 301 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
| |||
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
| 47 | + | |
| 48 | + | |
39 | 49 | | |
40 | 50 | | |
| 51 | + | |
| 52 | + | |
41 | 53 | | |
42 | 54 | | |
43 | 55 | | |
| |||
47 | 59 | | |
48 | 60 | | |
49 | 61 | | |
| 62 | + | |
50 | 63 | | |
51 | 64 | | |
52 | 65 | | |
53 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
54 | 71 | | |
55 | 72 | | |
56 | 73 | | |
| |||
69 | 86 | | |
70 | 87 | | |
71 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
72 | 108 | | |
73 | 109 | | |
74 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
75 | 199 | | |
76 | 200 | | |
77 | 201 | | |
| |||
182 | 306 | | |
183 | 307 | | |
184 | 308 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 309 | | |
190 | | - | |
| 310 | + | |
191 | 311 | | |
192 | 312 | | |
193 | 313 | | |
194 | | - | |
| 314 | + | |
195 | 315 | | |
196 | 316 | | |
197 | 317 | | |
198 | 318 | | |
199 | | - | |
| 319 | + | |
200 | 320 | | |
201 | 321 | | |
202 | 322 | | |
203 | | - | |
| 323 | + | |
204 | 324 | | |
205 | 325 | | |
206 | 326 | | |
207 | 327 | | |
208 | | - | |
| 328 | + | |
209 | 329 | | |
210 | 330 | | |
211 | 331 | | |
212 | | - | |
| 332 | + | |
213 | 333 | | |
214 | 334 | | |
215 | 335 | | |
| |||
218 | 338 | | |
219 | 339 | | |
220 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
221 | 372 | | |
222 | 373 | | |
223 | 374 | | |
| |||
233 | 384 | | |
234 | 385 | | |
235 | 386 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 387 | | |
240 | 388 | | |
241 | 389 | | |
| |||
246 | 394 | | |
247 | 395 | | |
248 | 396 | | |
249 | | - | |
| 397 | + | |
250 | 398 | | |
251 | 399 | | |
252 | 400 | | |
| |||
272 | 420 | | |
273 | 421 | | |
274 | 422 | | |
275 | | - | |
| 423 | + | |
276 | 424 | | |
277 | 425 | | |
278 | 426 | | |
279 | 427 | | |
280 | 428 | | |
281 | 429 | | |
282 | | - | |
283 | | - | |
| 430 | + | |
| 431 | + | |
284 | 432 | | |
285 | | - | |
286 | | - | |
| 433 | + | |
| 434 | + | |
287 | 435 | | |
288 | 436 | | |
289 | 437 | | |
| |||
312 | 460 | | |
313 | 461 | | |
314 | 462 | | |
315 | | - | |
| 463 | + | |
316 | 464 | | |
317 | 465 | | |
318 | 466 | | |
| |||
333 | 481 | | |
334 | 482 | | |
335 | 483 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | 484 | | |
340 | 485 | | |
341 | 486 | | |
| |||
346 | 491 | | |
347 | 492 | | |
348 | 493 | | |
349 | | - | |
350 | | - | |
| 494 | + | |
| 495 | + | |
351 | 496 | | |
352 | | - | |
353 | | - | |
| 497 | + | |
| 498 | + | |
354 | 499 | | |
355 | 500 | | |
356 | 501 | | |
| |||
372 | 517 | | |
373 | 518 | | |
374 | 519 | | |
375 | | - | |
| 520 | + | |
376 | 521 | | |
377 | 522 | | |
378 | 523 | | |
| |||
0 commit comments