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

@@ -139,8 +139,15 @@ test.describe("Feature Lifecycle Tests", () => {
// Perform the drag and drop using dnd-kit compatible method
await dragAndDropWithDndKit(page, dragHandle, inProgressColumn);
// Wait for the feature to move to in_progress
await page.waitForTimeout(500);
// First verify that the drag succeeded by checking for in_progress status
// This helps diagnose if the drag-drop is working or not
await expect(async () => {
const featureData = JSON.parse(
fs.readFileSync(path.join(featuresDir, featureId, "feature.json"), "utf-8")
);
// Feature should be either in_progress (agent running) or waiting_approval (agent done)
expect(["in_progress", "waiting_approval"]).toContain(featureData.status);
}).toPass({ timeout: 15000 });
// The mock agent should complete quickly (about 1.3 seconds based on the sleep times)
// Wait for the feature to move to waiting_approval (manual review)
@@ -349,15 +356,16 @@ test.describe("Feature Lifecycle Tests", () => {
await dragAndDropWithDndKit(page, dragHandle, inProgressColumn);
// Wait for the feature to be in in_progress
await page.waitForTimeout(500);
// Verify feature file still exists and is readable
const featureFilePath = path.join(featuresDir, testFeatureId, "feature.json");
expect(fs.existsSync(featureFilePath)).toBe(true);
// Wait a bit for the agent to start
await page.waitForTimeout(1000);
// First verify that the drag succeeded by checking for in_progress status
await expect(async () => {
const featureData = JSON.parse(fs.readFileSync(featureFilePath, "utf-8"));
// Feature should be either in_progress (agent running) or waiting_approval (agent done)
expect(["in_progress", "waiting_approval"]).toContain(featureData.status);
}).toPass({ timeout: 15000 });
// ==========================================================================
// Step 3: Wait for the mock agent to complete (it's fast in mock mode)
@@ -421,8 +429,15 @@ test.describe("Feature Lifecycle Tests", () => {
// Drag to in_progress to restart
await dragAndDropWithDndKit(page, restartDragHandle, inProgressColumnRestart);
// Wait for the feature to be processed
await page.waitForTimeout(2000);
// Verify the feature file still exists
expect(fs.existsSync(featureFilePath)).toBe(true);
// First verify that the restart drag succeeded by checking for in_progress status
await expect(async () => {
const data = JSON.parse(fs.readFileSync(featureFilePath, "utf-8"));
// Feature should be either in_progress (agent running) or waiting_approval (agent done)
expect(["in_progress", "waiting_approval"]).toContain(data.status);
}).toPass({ timeout: 15000 });
// Verify no "Feature not found" errors in console
const featureNotFoundErrors = consoleErrors.filter(
@@ -430,9 +445,6 @@ test.describe("Feature Lifecycle Tests", () => {
);
expect(featureNotFoundErrors).toEqual([]);
// Verify the feature file still exists
expect(fs.existsSync(featureFilePath)).toBe(true);
// Wait for the mock agent to complete and move to waiting_approval
await expect(async () => {
const data = JSON.parse(fs.readFileSync(featureFilePath, "utf-8"));

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);
}