main
md 49 lines 2.55 KB
Rendered Raw
1 # rename_work_dir_file.py DOX
2
3 ## Purpose
4
5 - Own the `rename_work_dir_file.py` API endpoint.
6 - This module handles workdir file operations for rename work dir file.
7 - Keep this file-level DOX profile synchronized with `rename_work_dir_file.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `rename_work_dir_file.py` owns the runtime implementation.
12 - `rename_work_dir_file.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `RenameWorkDirFile` (`ApiHandler`)
15 - `async process(self, input: Input, request: Request) -> Output`
16 - Top-level functions:
17 - `async rename_item(file_path: str, new_name: str) -> bool`
18 - `async create_folder(parent_path: str, folder_name: str) -> bool`
19 - `async move_items(file_paths: list[str], destination_path: str) -> list[str]`
20
21 ## Runtime Contracts
22
23 - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`.
24 - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change.
25 - `RenameWorkDirFile` is an `ApiHandler`.
26 - `RenameWorkDirFile` defines `process(...)`.
27 - Observed side-effect areas: filesystem writes.
28 - Imported dependency areas include: `api`, `helpers`, `helpers.api`, `helpers.file_browser`, `posixpath`.
29
30 ## Key Concepts
31
32 - Important called helpers/classes observed in the source: `FileBrowser`, `browser.rename_item`, `browser.create_folder`, `browser.move_items`, `strip`, `runtime.call_development_function`, `posixpath.join`, `file_path.startswith`, `extension.call_extensions_async`, `str.rstrip`, `posixpath.dirname`.
33 - The `move` action accepts `paths` plus `destinationPath`, emits the standard mutation hook, and returns the refreshed `currentPath` listing used by drag-and-drop clients.
34 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
35
36 ## Work Guidance
37
38 - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes.
39 - Update frontend callers, plugin callers, and tests together when payload shape changes.
40 - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies.
41
42 ## Verification
43
44 - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists.
45 - Run `pytest tests/test_file_browser_navigation.py` and smoke-test folder and Up-button drops in the WebUI.
46
47 ## Child DOX Index
48
49 No child DOX files.