Add inline file creation to the config tab#27
Merged
Conversation
Right-click on empty file-tree space opens an "Add file" menu; right-click on a folder opens "Add file to folder". Selecting either reveals an inline input in the tree (auto-focused, Enter to create, Escape/blur to cancel) rather than a modal dialog. Uses the existing PUT config-file endpoint with empty content, so no backend changes are needed. Path/collision validation is extracted to a pure helper module (web/src/lib/config-files.ts) and covered by vitest unit tests. Adds vitest as a dev dep and wires up `npm test` / `npm run test:watch`. Delete is intentionally left out — squadron-wire doesn't expose a delete-config-file message yet.
…-b51cff # Conflicts: # web/src/pages/ConfigPage.tsx
Replaces the hand-rolled popover with radix-backed ContextMenu components so we get proper keyboard nav, focus management, and portalled positioning. Root (empty space) and per-folder triggers are nested so each gets its own appropriate items. The project's --radius token is 1.15rem, which makes stock shadcn menus render with ~16px-radius items that look pill-ish. Overridden to 6px/4px on the menu content and items so the menu looks like a menu.
- Accept a leading './' on new filenames (normalized away before path concat and collision checks) so './foo.md' behaves identically to 'foo.md'. - Extract splitDirAndBase helper and use it at the four inline substring/lastIndexOf sites in ConfigPage. - Replace the nested-ternary error-code-to-message mapping with a lookup object. - Extract the shared ContextMenuContent className and onCloseAutoFocus handler into module-level constants. - Drop the redundant setTimeout around the inline input's focus call — onCloseAutoFocus already prevents Radix's focus restore. - Reuse cancelAddingFile in handleCreateFile's success path. - Tests: 5 new cases for './' handling and splitDirAndBase (19 total).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PUT /api/instances/{id}/config/files/{name}endpoint with empty content, so no backend changes.web/src/lib/config-files.tswith 14 vitest unit tests covering root vs. nested placement, whitespace, absolute paths,..traversal, and collisions.npm test/npm run test:watch.Not included
Delete (file/folder) was discussed but skipped —
squadron-wiredoesn't currently expose a delete-config-file message type. Worth a follow-up that extends the protocol and the instance-side handler.Test plan
npm testinweb/passesnpm run buildinweb/succeeds../fooor/fooshows red border