Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .claude/docs/V1.2.1_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,17 @@ Then pushed `v1.2.1` to `origin` at the maintainer's request. **No merge and no

**#180 (IDE), eighteenth PR of epic #163: debugger (DAP) for Python and Node.js** [confirmed: unit tests (`debug.test.ts`: `launch.json` parsing with aliases and errors, the template, variables on POSIX and Windows, DAP framing split anywhere including inside a UTF-8 character, the client's responses, error formats, reverse requests, timeouts and close, the Node adapter's helpers, and two end-to-end sessions: a Node.js program through the IDE's adapter on every run, a Python one through debugpy when it is installed (run locally with it)), `smoke.test.ts`, the gate, the smoke run (debugging refused in Restricted Mode), Playwright on Linux in both themes: a breakpoint set from the glyph margin, F5 on a `.py` file offered "Install debugpy", installing it into the IDE's environment and starting stopped on the breakpoint with the locals shown, F10 stepped, a watch and a console expression evaluated, Shift+F5 stopped; the same on a `.js` file with Shift+F11 and continuing to the end with the output in the Debug Console]. Main: `main/debug/dapClient.ts` (DAP over a byte stream), `debugSession.ts` (start-up sequence, events, path mapping), `debugHost.ts` (IPC `codexr:debug:*`, one session per window, trust-gated), `nodeAdapter.ts` (DAP to the V8 inspector, `node --inspect-brk` + WebSocket); `PythonEnvironmentService.debugAdapterCommand`/`installDebugpy` (pinned `debugpy==1.8.22`, installed only after consent); Output channel `debug`. Renderer: `renderer/debug/` (controller, view, console, CSS), `renderer/editor/debugDecorations.ts` (glyph margin, `glyphMargin` on), activity item `debug`, panel view `debug`, commands `workbench.action.debug.*`, `editor.debug.action.toggleBreakpoint`, `workbench.view.debug`. Windows and macOS: the Node adapter's breakpoint regex is caseless and slash-agnostic on Windows (unit-tested), the rest is the same spawn/stdio code as the tested path, run by CI on Linux only. Plugin: nothing to do, VS Code has its own debugger. Not done: attach requests, conditional breakpoints and logpoints, exception breakpoints, multi-thread and child-process debugging.

**#256 (IDE), epic #253 (classic gaps after #163): PDF and image viewer tabs on a generic custom-editor seam** [confirmed: unit tests (`viewers.test.ts`: zoom steps and fit, find across pages and its item mapping, sizes, the resolver registry, `readDocument` limited to PDFs inside the folder including through a symlink), the gate, the smoke run, Playwright on Linux in both themes. That run covered a 12-page PDF drawn lazily with its text layer, Ctrl+F finding and highlighting "lazy" on page 3, zoom, an image with its size, a broken PDF reported, the split showing the PDF in both groups, a session restored with both, an external overwrite re-rendered (12 then 3 pages), a deletion shown in the tab, and Close Editor from the palette on an image tab.]
- Main: `Workspace.readDocument` (PDF only, 64 MB cap, real path inside the folder) over IPC `codexr:workspace:read-document`; `readImage` also serves ICO and AVIF.
- Renderer:
- `editor/customEditor.ts` (types), `editor/customEditorRegistry.ts` (DOM-free registry), and `editorGroup.openCustom` / `registerCustomEditor`. A custom tab is a document with an empty placeholder model under the `codexr-custom:` scheme plus one view per tab; text commands see no active document.
- `viewers/` (pdf.js viewer loaded lazily, image viewer, resolver).
- New command target `hasActiveTab` for close, split, keep, copy path and reveal.
- Dependency: `pdfjs-dist` 6.5.438 (Apache-2.0, notice added).
- Plugin: nothing to do, VS Code has its own viewers.
- The agent-first layout thread builds its chat tabs on the same seam.
- Not done: password-protected PDFs, the outline/thumbnails sidebar, printing, CJK PDFs without embedded fonts (no CMaps bundled).

**#176 (IDE), sixteenth PR of epic #163: tasks and Run Current File** [confirmed: unit tests (`tasks.test.ts`: package.json scripts and hooks, package manager by lock file, Makefile targets, `.codexr/tasks.json` with comments, matchers by command, interpreters by extension, PATH and PATHEXT lookup, quoting for bash/PowerShell/cmd, tsc and ESLint matchers, a command terminal's output and exit code), the smoke run (an untrusted folder lists its tasks as not trusted and refuses a run), Playwright on Linux: Run Task in Restricted Mode shows the explanation with Manage Workspace Trust; once trusted the picker lists the user task, `npm: hello` and `make: build`; each ran in its own tab with its exit code; the user task's tsc-shaped line reached the Problems panel; Run Current File ran `run me.py` (a space in the name) with python3]. `shared/tasks.ts` (pure), `main/tasks/taskHost.ts` + `problemMatchers.ts`, `TerminalService.createCommand` (the default profile's shell with `-c` or its equivalent, `shellInvocation` from the agents' command tool), `Workspace.runnableFile`, settings `run.pythonInterpreter` / `run.nodeInterpreter`, commands `workbench.action.tasks.runTask`, `workbench.action.tasks.configureTaskRunner`, `workbench.action.runCurrentFile` (`Ctrl/Cmd+F5`). Core: `ProblemOrigin` gains `task` (type only; the plugin never produces it). The user tasks file is `.codexr/tasks.json`, next to `.codexr/settings.json`, not the `.code-xr/` the issue wrote. Windows and macOS not run by hand: the quoting and PATHEXT paths are unit-tested and CI runs the gate on all three. Plugin: nothing to do, VS Code has tasks natively.

**#177 (IDE), fifteenth PR of epic #163: workspace trust** [confirmed: unit tests (`trust.test.ts`: parent trusts children, a sibling with the same prefix is not, Restricted Mode inside a trusted parent, case rules per platform, bounded storage; the choices offered), the smoke run (new folder unknown, shield shown, Git `restricted`, then trusted and Git on), Playwright on Linux: the question on a new folder, the XR deep analysis ran to a scene while restricted, Trust Folder turned Git on and hid the shield, the answer survived a restart, Manage Workspace Trust from the palette restricted it again, "Trust every folder in ol" trusted it through the parent]. Main: `main/trust/trustModel.ts` (pure), `main/trust/workspaceTrust.ts` (decisions in `userData/workspace-trust.json`, in memory for the smoke run; `isWorkspaceTrusted(contents)` for #176), IPC `codexr:workspace:trust` / `set-trust` and event `trust-changed`. Gated: Git (`GitRepoState` `restricted`, status and every operation), the Python language server (pyright runs a project-configured interpreter); a trust change stops the window's language servers and the renderer re-sends its documents (`reopenLanguageDocuments`). Not gated: the IDE's own TypeScript server (no local tsserver plugins), the terminal, the analysis. Renderer: `trustView.ts` + `trustChoices.ts`, status-bar shield, command `workbench.trust.manage`. Acceptance "Run Task is disabled with an explanation" lands with #176, which does not exist yet; this PR provides the gate. Plugin: nothing to do, VS Code has Workspace Trust natively.
Expand Down
30 changes: 30 additions & 0 deletions apps/ide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,36 @@ Each run gets a terminal tab of its own, in the folder, started with the shell o

The renderer names a task only by the id the main process listed, or a file by its workspace path; the main process re-reads the folder, builds the command line (quoted for bash/zsh/fish, PowerShell or cmd), checks the trust and starts the terminal (`shared/tasks.ts`, pure and unit-tested; `main/tasks/`; `renderer/taskRunner.ts`). The smoke run checks that a task is refused in an untrusted folder.

## PDF and image viewers (#256)

PDFs and images open in an editor tab instead of being refused as binary files. This covers the explorer, Quick Open, search results and links in the Markdown preview. The tabs behave like file tabs:
- a single click opens a preview tab;
- they can be dragged to the other group or split with `Ctrl/Cmd+\`;
- they are restored with the folder's session;
- they follow the file on disk.

- **PDF**
- Drawn by [PDF.js](https://github.com/mozilla/pdf.js), fitted to the width by default.
- Pages are drawn as they come near the viewport, and give their memory back when they are far away.
- Text can be selected and copied.
- The toolbar has the page number (type one and press Enter), previous and next page, zoom in and out (also `Ctrl/Cmd+=` / `Ctrl/Cmd+-` and `Ctrl/Cmd`+wheel), fit width (`Ctrl/Cmd+0`) and actual size.
- It also has a find box (`Ctrl/Cmd+F`, Enter and Shift+Enter step through the matches, Escape clears them) that highlights the match on the page.
- Up to 64 MB. Password-protected PDFs are not supported yet.
- **Images** (PNG, JPEG, GIF, WebP, BMP, ICO, AVIF, up to 8 MB)
- Fitted to the tab over a checkerboard.
- Zoom in steps, to actual size or back to fit, with the same keys.
- The size in pixels and bytes is shown in the toolbar.
- SVG stays a text file: it is a document that can carry script.
- **Security**
- The bytes come from the main process through a read that stays inside the folder and is size-capped (`workspace.readDocument` / `readImage`).
- PDF.js parses them in its own worker, bundled with the app.
- The CSP is unchanged: no frames, no objects, no remote fetches.
- Viewing is read-only, so it works in Restricted Mode.
- **Custom editor tabs**
- The viewers are the first users of a generic seam in `renderer/editor/customEditor.ts`. `editorGroup.openCustom(input)` opens a tab whose content is a DOM element of its own, and `registerCustomEditor(resolver)` turns an id (a file being opened, or a tab of a saved session) into such a tab.
- A tab's id is a workspace path for a file viewer, and carries a prefix of its own otherwise (`chat:<id>`).
- Text commands (save, format, go to line) leave custom tabs alone; close, split, keep and copy path work on them.

## Debugger (#180)

**Run and Debug** (activity bar, `Ctrl/Cmd+Shift+D`) debugs Python and Node.js programs over the Debug Adapter Protocol. Click left of a line number (or press `F9`) to set a breakpoint; breakpoints follow the text as you edit, are listed in the view and are kept per folder. **F5** starts the configuration picked in the view, by default the active file with its language's debugger, and continues once paused. While paused, the line is highlighted, and the view shows **Variables** (expanded on demand, open nodes stay open from one stop to the next), **Watch** expressions, the **Call Stack** (click a frame to inspect it) and **Breakpoints**. A floating toolbar over the editors and the usual keys drive it: Continue `F5`, Pause `F6`, Step Over `F10`, Step Into `F11`, Step Out `Shift+F11`, Restart `Ctrl/Cmd+Shift+F5`, Stop `Shift+F5`. The **Debug Console** (panel, `Ctrl/Cmd+Shift+Y`) shows the program's output and evaluates expressions in the selected frame. The status bar turns orange while a session runs.
Expand Down
13 changes: 13 additions & 0 deletions apps/ide/THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,16 @@ Usage in this package:
Usage in this package:

- Bundled into the renderer by Vite: sanitises the Markdown preview's HTML before it reaches the page (#179, `src/renderer/editor/markdownPreview.ts`). The same version Monaco already depends on.

## PDF.js (PDF viewer)

- Project: `pdfjs-dist` on npm, 6.5.438, by Mozilla and the PDF.js contributors
- Source: https://github.com/mozilla/pdf.js
- License: Apache-2.0

Usage in this package:

- Bundled into the renderer by Vite: draws PDFs in the PDF viewer tab (#256, `src/renderer/viewers/pdfViewer.ts`). The library is a chunk loaded on the first PDF only.
- Its worker (`pdfjs-dist/build/pdf.worker.mjs`) is bundled the same way and served from the app's origin, so the CSP's `worker-src 'self'` covers it.
- The text-layer rules in `src/renderer/viewers/viewers.css` are a trimmed copy of the `.textLayer` block of its `web/pdf_viewer.css`.
- The optional `@napi-rs/canvas` dependency is only used by PDF.js under Node and is not bundled.
1 change: 1 addition & 0 deletions apps/ide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"marked": "14.0.0",
"material-icon-theme": "^5.40.0",
"monaco-editor": "0.57.0",
"pdfjs-dist": "6.5.438",
"vite": "^8.3.8",
"vscode-jsonrpc": "9.0.3",
"vscode-languageserver-types": "3.18.4"
Expand Down
1 change: 1 addition & 0 deletions apps/ide/src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export function registerIpcHandlers(origins: ReadonlySet<string>, isDevelopment:
handle(IPC_CHANNELS.workspaceTrust, (event) => trustInfoOf(event.sender));
handle(IPC_CHANNELS.workspaceSetTrust, (event, choice) => setWorkspaceTrust(event.sender, choice));
handle(IPC_CHANNELS.workspaceReadImage, (event, path) => workspaceOf(event.sender).readImage(path));
handle(IPC_CHANNELS.workspaceReadDocument, (event, path) => workspaceOf(event.sender).readDocument(path));
handle(IPC_CHANNELS.workspaceOpenExternalLink, async (_event, url) => {
if (!isOpenableExternalLink(url)) {
throw new Error('Only http, https and mailto links open outside the IDE.');
Expand Down
27 changes: 26 additions & 1 deletion apps/ide/src/main/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export const MAX_PREVIEW_IMAGE_BYTES = 8 * 1024 * 1024;
* Raster images only: an SVG is a document that can carry script and
* external references, and the preview has no reason to take that on.
*/
const IMAGE_TYPES: Record<string, string> = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', bmp: 'image/bmp' };
const IMAGE_TYPES: Record<string, string> = {
png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', bmp: 'image/bmp',
ico: 'image/x-icon', avif: 'image/avif',
};
/** #256: the largest document the PDF viewer reads (pdf.js keeps it in memory). */
export const MAX_DOCUMENT_BYTES = 64 * 1024 * 1024;
/** #256: the documents a viewer tab may read whole, by extension. */
const DOCUMENT_TYPES = new Set(['pdf']);

export function imageMimeType(path: string): string | null {
const dot = path.lastIndexOf('.');
Expand Down Expand Up @@ -173,6 +180,24 @@ export class Workspace {
return `data:${mime};base64,${(await fs.readFile(absolute)).toString('base64')}`;
}

/**
* #256: a document of the folder (a PDF) as bytes, for a viewer tab. Null
* for another kind of file or one over `MAX_DOCUMENT_BYTES`.
*/
async readDocument(relativePath: unknown): Promise<Uint8Array | null> {
const name = parseWorkspacePath(relativePath).join('/');
const dot = name.lastIndexOf('.');
if (dot <= name.lastIndexOf('/') || !DOCUMENT_TYPES.has(name.slice(dot + 1).toLowerCase())) {
return null;
}
const absolute = await this.realPathInside(relativePath);
const stat = await fs.stat(absolute);
if (!stat.isFile() || stat.size > MAX_DOCUMENT_BYTES) {
return null;
}
return new Uint8Array(await fs.readFile(absolute));
}

/**
* Overwrites an existing file with `text` (UTF-8). Refuses a folder, a text
* over the editor limit, and, when `expectedMtimeMs` is given, a file whose
Expand Down
1 change: 1 addition & 0 deletions apps/ide/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const api: CodeXRApi = Object.freeze({
rename: (path: string, newName: string) => ipcRenderer.invoke(IPC_CHANNELS.workspaceRename, path, newName),
copyPath: (path: string, kind: 'absolute' | 'relative') => ipcRenderer.invoke(IPC_CHANNELS.workspaceCopyPath, path, kind),
readImage: (path: string) => ipcRenderer.invoke(IPC_CHANNELS.workspaceReadImage, path),
readDocument: (path: string) => ipcRenderer.invoke(IPC_CHANNELS.workspaceReadDocument, path),
trust: () => ipcRenderer.invoke(IPC_CHANNELS.workspaceTrust),
setTrust: (choice: 'folder' | 'parent' | 'restrict') => ipcRenderer.invoke(IPC_CHANNELS.workspaceSetTrust, choice),
onDidChangeTrust: (listener: (trust: WorkspaceTrustInfo) => void) => subscribe(IPC_EVENTS.workspaceTrustChanged, listener),
Expand Down
Loading
Loading