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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run check
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- run: cargo fmt --check
- run: cargo clippy --locked -- -D warnings
- run: cargo build --release --locked
- run: timeout 90s python3 scripts/test_protocol.py --binary target/release/lithe-http-client
- run: npx playwright install --with-deps chromium
- run: timeout 90s node scripts/test_ui.js
env:
HTTP_CLIENT_BINARY: target/release/lithe-http-client
HTTP_CLIENT_BROWSER: chromium
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
__pycache__/
*.pyc
.DS_Store
/node_modules/
4 changes: 4 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Revision: e689971c000c15a044df0502052fe7b2c1c6f84f
Original copyright and license notices are retained in licenses/ in each
release package. DEPENDENCIES.json records Cargo dependencies and notices.
Upstream authors do not endorse this plugin.

The bundled UI uses CodeMirror 6 and Lezer (MIT). Exact bundled versions
and their original license texts are in ui/DEPENDENCIES.json and
ui/THIRD_PARTY_LICENSES.txt.
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

**0.1.1 preview:** protocol/Core integration is verified; native install/window and Intel hardware acceptance are still pending.

A small HTTP workbench inside Lithe's native macOS tool window. Paste `.http` requests, select one, send it, and inspect the response without leaving the IDE.
A compact HTTP workbench inside Lithe's native macOS tool window. Paste `.http` requests, select one, send it, and inspect the response without leaving the IDE.

## Install and use

Install **HTTP Client** from the Lithe plugin marketplace when its listing is available, or download the ZIP from [Releases](https://github.com/Lithe-IDEA/lithe-plugin-http-client/releases) and use Lithe's install-from-disk action. The universal macOS package contains Apple Silicon and Intel code. The host must advertise `backend: 1`, `serverProcess: 1`, and `ui: 2` (plugin API 3). Windows is not supported in this release.
Install **HTTP Client** from the Lithe plugin marketplace when its listing is available, or download the ZIP from [Releases](https://github.com/Lithe-IDEA/lithe-plugin-http-client/releases) and use Lithe's install-from-disk action. The universal macOS package contains Apple Silicon and Intel code. This development branch requires `backend: 2`, `serverProcess: 1`, and `ui: 2` (plugin API 3), adding workspace metadata, document-summary and preview permissions for HTML preview. Windows is not supported in this release.

Open the **HTTP Client** bottom tool window. Paste a request, then click **Send** (⌘/Ctrl+Enter). For multiple requests, use **Read requests**, choose an entry, then send. Editing the text invalidates the selection; sending reparses and selects the first request. No network request runs automatically.
Open the **HTTP Client** bottom tool window. Use **Open .http** to choose a UTF-8 `.http` or `.rest` file (up to 128 KiB), or paste a request. Files are read and their requests listed immediately. Choose an entry and click **Send** (⌘/Ctrl+Enter). **Read requests** reparses pasted text. Editing invalidates the selection; sending reparses and selects the first request. Choosing a file, request or history entry never sends it automatically.

```http
@base = http://localhost:8080
Expand All @@ -23,24 +23,41 @@ Content-Type: application/json
{"name":"example"}
```

Replace the address with a service you intend to call. The UI follows the host's theme and language (English / Chinese), displays status, elapsed time and received size, and switches between body and headers. JSON formatting is optional. Header names and values are separated; values start on one line and expand on click. The toolbar preview limit applies to the next send and is kept only for the current page session. JSON-escaped responses may be truncated earlier to fit the 900 KiB transport budget. Select response text and use the normal copy shortcut. Responses are displayed as text; returned HTML is never executed.
Replace the address with a service you intend to call. The request editor provides HTTP / inline-variable / JSON highlighting, line numbers and undo. The divider is draggable (arrow keys also resize it; double-click resets it). Narrow windows stack the panes. The UI follows the host's theme and language (English / Chinese), displays status, elapsed time and received size, and switches between body and headers. JSON formatting is optional. Header names and values are separated; values start on one line and expand on click. The toolbar preview limit applies to the next send and is kept only for the current page session. JSON-escaped responses may be truncated earlier to fit the 900 KiB transport budget. Select response text and use the normal copy shortcut. The wrap icon switches between wrapped lines and horizontal scrolling. Request/response editors use CodeMirror's viewport rendering. Responses stay text in the plugin page.

The history selector keeps up to 20 sent requests / 1 MiB of source text in the current page session. It restores the source and selected request without sending; use the clear icon to discard it. No history or draft is persisted.

The workbench uses theme-aware inset editor panels, compact segmented response tabs, colored method/status badges, header/history counts, and response content-type metadata. Empty, loading and failed states explain the current operation without replacing real response content. Cancel appears while an operation is active; keyboard hints follow the host platform. Narrow and short docked panels retain the same controls, and reduced-motion preferences disable animation.

The tool-window icon, panel identity and empty state reuse the minimal globe in `assets/http.svg`. The host tints the template icon for inactive and selected sidebar states; the panel uses an accent color in light mode and a light neutral color in dark mode. The empty request editor uses a single-line example and CodeMirror's cursor/selection rendering, keeping the caret at one line in WebKit as well as Chromium.

Response headers use the host's proportional UI font and text size, with compact rows and readable name/value contrast. Code bodies keep the editor's monospace font. Long header names show their full name on hover; values expand on click.

The bottom-right save action opens the host's native save dialog and exports **Body only** or **Headers + body**, preserving the raw response rather than the formatted JSON display. A truncated response exports only its available preview, with a visible notice. Binary bodies are not exported. File dialogs require Web bridge 2; older hosts keep sending/inspection available and disable file actions.

HTML responses collapse complete leading blank lines in the text viewer, keeping the first content line at the top. The footer shows the collapsed line count and lets you restore the original view. Internal whitespace, saved files and the editor preview retain the original response.

HTML responses expose **Preview**. The current public host API accepts workspace files rather than arbitrary HTML strings: this action asks where to save the response **inside the current local workspace**, then opens that file in the editor's **preview-only** presentation. It checks host capability availability and refuses an already-open target to avoid displaying an older live buffer. The file remains in the location you chose; there is no hidden response cache. HTML runs only in the host's separate HTML preview, without the plugin bridge. Native dialog and editor-preview acceptance are still pending on this branch.

## Scope and data handling

- The declared executable `bin/lithe-http-client` runs locally via the official Lithe plugin SDK. It performs HTTP(S) requests explicitly requested by the user. The Web UI only talks to the host bridge.
- No request history, draft persistence or automatic workspace/file reads. Request text, headers and response content stay in memory; closing/recreating the page can discard them. The plugin does not write to its package or application bundle.
- Requests, session history and responses stay in memory until you explicitly save or preview. No automatic workspace scanning, file reads or draft persistence. The plugin reads only the chosen request file, and writes only the chosen export/HTML file with an atomic replacement. Application bundles, installed plugin resources, symbolic-link export targets and special files are refused. Closing/recreating the page discards history. HTML preview uses workspace metadata and document summaries to find the current root and avoid stale open buffers; it does not read other documents' contents.
- Inline `@variables`, headers, request bodies and `###` separators use the unchanged OpenIDEA parser/executor. Environment files, local body includes, response scripts and file redirects are unsupported. Includes and scripts/redirects fail explicitly before sending.
- 128 KiB input, 30-second overall request timeout, cancellable operations, configurable 48 / 256 / 512 KiB text preview (512 KiB default). Upstream retains at most 16 MiB of network body. Received size can exceed the preview size; truncation is visible. Binary responses show status/headers without a body preview.
- 128 KiB input, 30-second overall request timeout, cancellable operations, configurable 1–512 KiB text preview (1 KiB steps, 128 KiB default). Upstream retains at most 16 MiB of network body. Received size can exceed the preview size; truncation is visible. Binary responses show status/headers without a body preview.
- Network/prepare errors are localized stable codes; raw request URLs and transport errors are not exposed in diagnostics. User-supplied text and server responses can contain secrets; this is a local HTTP client, not a redaction tool.
- Uses upstream default proxy behavior; Lithe's proxy settings are not synchronized. No custom TLS/credential/environment UI.
- macOS host chrome remains native; the plugin content is a themed Web page. This is not a replacement for the editor or a new host architecture.
- Community package with ad-hoc executable signature, not publisher-signed or notarized. Lithe handles program review/consent on install.

## Build and verify

Requires macOS, Python 3, Rust (edition 2024), Xcode command line tools, and the `x86_64-apple-darwin` Rust target. Pinning uses Cargo.lock and Git revisions; no runtime downloads.
Requires macOS, Node.js 22+, Python 3, Rust (edition 2024), Xcode command line tools, and the `x86_64-apple-darwin` Rust target. Pinning uses Cargo.lock and Git revisions; no runtime downloads.

```sh
npm ci
npm run build
npm run check
cargo build --release --locked
cargo build --release --locked --target x86_64-apple-darwin
cargo fmt --check
Expand All @@ -59,7 +76,7 @@ Optional real Core integration (requires a compatible host Core library):
python3 scripts/test_core.py --core /path/to/liblithe_core.dylib --binary dist/io.github.lithe-idea.http-client/bin/lithe-http-client
```

Run that C ABI integration under an external 30-second process watchdog. `scripts/test_ui.js` is a browser test function for the loaded `ui/index.html`; its mocked bridge checks interaction state, cancellation and text-only rendering. Mocked UI tests do not replace native host acceptance.
Run that C ABI integration under an external 30-second process watchdog. `scripts/test_ui.js` launches a real SDK backend, a loopback HTTP server and headless Chrome. It checks caret/input/focus behavior, parsing/sending, highlighting, history, headers, resize/wrap, truncation, cancellation, real file reads/exports, install-directory refusal, localization and responsive layout. Run `node scripts/test_ui.js` after a debug build, or set `HTTP_CLIENT_BINARY=target/release/lithe-http-client`. For Playwright Chromium use `npx playwright install chromium` and `HTTP_CLIENT_BROWSER=chromium`; for WebKit use `npx playwright install webkit` and `HTTP_CLIENT_BROWSER=webkit`. Reports are `.artifacts/test-stability/ui.html` / `ui.junit.xml`; screenshots are under `.artifacts/`. The test bridge forwards real function calls and does not simulate native file dialogs or editor previews. Those flows still require native host acceptance.

## Architecture and attribution

Expand All @@ -69,4 +86,6 @@ This project's adapter and UI are Apache-2.0. Release packages retain original d

## 中文说明

保留 Lithe 原生 Mac 工作台,在底部工具窗口提供独立 HTTP 面板。粘贴 `.http` 文本后可发送请求、取消、查看状态码/耗时/大小,切换正文与响应头,格式化 JSON。界面跟随宿主中英文和主题。首版仅支持 macOS;没有环境文件、文件引用、响应脚本、历史记录或编辑器行内按钮,不会自动保存含有令牌的请求。
保留 Lithe 原生 Mac 工作台,在底部工具窗口提供独立 HTTP 面板。粘贴 `.http` 文本后可发送请求、取消、查看状态码/耗时/大小,切换正文与响应头,格式化 JSON。界面跟随宿主中英文和主题。首版仅支持 macOS;支持原生选择 `.http` / `.rest` 文件、请求高亮、会话历史、可拖动分栏、响应换行和原始内容保存。HTML 响应可先保存到当前工作区,再在编辑区预览。没有环境文件、正文文件引用、响应脚本或编辑器行内按钮;历史不会写入磁盘,只有显式保存或预览才写入选择的文件。原生文件对话框和编辑区 HTML 预览的完整验收仍待进行。

UI source is `ui/src/main.js`; translations live in `shared/i18n/`. `npm run build` bundles all editor code locally into `ui/main.js` and records bundled UI dependency licenses. Commit generated outputs; `npm run check` verifies the bundle, licenses and matching English/Chinese keys. Packaging copies those files verbatim and requires no runtime downloads.
12 changes: 4 additions & 8 deletions assets/http.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading