feat: add file renaming functionality in ContextView

- Implemented a rename dialog for files, allowing users to rename selected context files.
- Added state management for the rename dialog and file name input.
- Enhanced file handling to check for existing names and update file paths accordingly.
- Updated UI to include a pencil icon for triggering the rename action on files.
- Improved user experience by ensuring the renamed file is selected after the operation.
This commit is contained in:
Cody Seibert
2025-12-16 22:36:22 -05:00
parent 4996a63bcc
commit 83fab5321e
5 changed files with 197 additions and 44 deletions

View File

@@ -3,12 +3,22 @@ import { Page, Locator } from "@playwright/test";
/**
* Perform a drag and drop operation that works with @dnd-kit
* This uses explicit mouse movements with pointer events
*
* NOTE: dnd-kit requires careful timing for drag activation. In CI environments,
* we need longer delays and more movement steps for reliable detection.
*/
export async function dragAndDropWithDndKit(
page: Page,
sourceLocator: Locator,
targetLocator: Locator
): Promise<void> {
// Ensure elements are visible and stable before getting bounding boxes
await sourceLocator.waitFor({ state: "visible", timeout: 5000 });
await targetLocator.waitFor({ state: "visible", timeout: 5000 });
// Small delay to ensure layout is stable
await page.waitForTimeout(100);
const sourceBox = await sourceLocator.boundingBox();
const targetBox = await targetLocator.boundingBox();
@@ -24,11 +34,29 @@ export async function dragAndDropWithDndKit(
const endX = targetBox.x + targetBox.width / 2;
const endY = targetBox.y + targetBox.height / 2;
// Perform the drag and drop with pointer events
// Move to source element first
await page.mouse.move(startX, startY);
await page.waitForTimeout(50);
// Press and hold - dnd-kit needs time to activate the drag sensor
await page.mouse.down();
await page.waitForTimeout(150); // Give dnd-kit time to recognize the drag
await page.mouse.move(endX, endY, { steps: 15 });
await page.waitForTimeout(100); // Allow time for drop detection
await page.waitForTimeout(300); // Longer delay for CI - dnd-kit activation threshold
// Move slightly first to trigger drag detection (dnd-kit has a distance threshold)
const smallMoveX = startX + 10;
const smallMoveY = startY + 10;
await page.mouse.move(smallMoveX, smallMoveY, { steps: 3 });
await page.waitForTimeout(100);
// Now move to target with slower, more deliberate movement
await page.mouse.move(endX, endY, { steps: 25 });
// Pause over target for drop detection
await page.waitForTimeout(200);
// Release
await page.mouse.up();
// Allow time for the drop handler to process
await page.waitForTimeout(100);
}