Skip to content

feat(web): add request headres draft controller#107

Merged
andrewmelchor merged 4 commits intomainfrom
feat(web)/headers-edit-operations
Mar 3, 2026
Merged

feat(web): add request headres draft controller#107
andrewmelchor merged 4 commits intomainfrom
feat(web)/headers-edit-operations

Conversation

@andrewmelchor
Copy link
Copy Markdown
Member

Summary

This PR introduces a Request Workspace feature that adds a new tabbed interface for viewing and editing HTTP request details directly within the editor. Users can now inspect request parameters, modify headers with a live draft mode, and view request body information.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bc304af05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR introduces a Request Workspace feature — a tabbed panel embedded in the HTTP editor that lets users view query params, edit request headers inline (with save/discard draft semantics), and inspect the request body. The implementation spans a new useRequestHeaderDraftController SolidJS hook, file-rewrite utilities in request-editing.ts, and the corresponding UI components and tests.

The overall architecture is clean and the draft lifecycle (dirty tracking, concurrent-save guard, partial-failure handling) is well-tested. A couple of issues worth addressing before merge:

  • Header value whitespace not trimmed (request-editing.ts line 98–102): normalizeRows trims header keys but not values. A leading or trailing space typed by the user gets written literally into the file, producing a double-space artifact next to the : separator (e.g. Accept: application/json). This is inconsistent and can produce subtly malformed header lines.
  • onAddHeader marks draft dirty for an empty row (use-request-header-draft-controller.ts line 105–108): clicking "Add Header" without filling anything in shows the "Unsaved" badge; saving silently discards the empty row, making the badge disappear with no visible file change. Consider deferring markDirty() until the user actually edits the new row.
  • Comment lines within the header block are reordered on save (request-editing.ts line 153–169): comments interspersed between headers are always moved to after all header lines in the rewritten output. This is covered by a test and appears intentional, but it can silently reformat carefully authored .http files.

Confidence Score: 3/5

  • Safe to merge after addressing the header-value trimming issue; remaining concerns are UX/style.
  • The core draft-controller logic is solid and well-tested. The header value trimming omission is a logic bug that can silently write malformed header lines to disk. The comment-reordering behaviour and the empty-row dirty flag are functional but may surprise users. No data-loss or security risks identified.
  • Pay close attention to packages/web/src/utils/request-editing.ts — the normalizeRows function and the rewriteRequestSegment comment-ordering logic.

Important Files Changed

Filename Overview
packages/web/src/utils/request-editing.ts Core file-rewrite logic for applying header/URL edits to .http file content. Well-structured with splitLines, findRequestSegment, and rewriteRequestSegment helpers, but normalizeRows trims header keys without trimming values, which can produce double-space artifacts in the written file. Comment lines within the header block are also silently reordered to appear after all headers on save.
packages/web/src/components/request-workspace/use-request-header-draft-controller.ts New SolidJS hook managing the header draft lifecycle (edit, discard, save). Concurrent-save guard and dirty-flag-after-save logic look correct. Minor UX concern: onAddHeader immediately marks the draft dirty even for an empty row that will be filtered out on save, surfacing a spurious "Unsaved" badge.
packages/web/src/components/request-workspace/use-request-header-draft-controller.test.ts Good test coverage for the draft controller: mutation tracking, full save flow, partial-failure (reload throws), and concurrent-save guard are all tested.
packages/web/src/utils/request-editing.test.ts Comprehensive tests for applyRequestEditsToContent covering multi-request files, URL continuation lines, comment preservation, and error cases. No test for header value whitespace trimming.
packages/web/src/components/request-workspace/request-workspace-tab-panels.tsx New header editing panel UI with save/discard controls, disabled states, and error display. Looks correct; disabled states are appropriately wired to hasRequest and headerDraftSaving.
packages/web/src/components/request-workspace/request-workspace-tabs.tsx Wires the three draft-controller props (onHeaderChange, onSaveHeaders, onDiscardHeaders, etc.) through to RequestWorkspaceHeadersPanel correctly.
packages/web/src/components/editor/EditorWithExecution.tsx Integrates useRequestHeaderDraftController into the editor, passing workspace callbacks (saveFile, reloadRequests, setFileContent) and wiring draft headers to the workspace tabs. Clean integration with no obvious issues.

Sequence Diagram

sequenceDiagram
    participant User
    participant HeadersPanel as RequestWorkspaceHeadersPanel
    participant Controller as useRequestHeaderDraftController
    participant Editing as applyRequestEditsToContent
    participant Workspace as WorkspaceStore

    User->>HeadersPanel: Edit / Add / Remove header
    HeadersPanel->>Controller: onHeaderChange / onAddHeader / onRemoveHeader
    Controller->>Controller: setDraftHeaders(), markDirty()

    User->>HeadersPanel: Click Save
    HeadersPanel->>Controller: onSave()
    Controller->>Controller: isSaving() guard check
    Controller->>Editing: applyRequestEditsToContent(content, index, url, draftHeaders)
    Editing-->>Controller: { ok: true, content: rewritten }
    Controller->>Workspace: setFileContent(rewritten)
    Controller->>Workspace: saveFile(path)
    Workspace-->>Controller: resolved
    Controller->>Controller: setIsDirty(false)
    Controller->>Workspace: reloadRequests(path)
    Controller->>Controller: refetchRequestDetails()

    User->>HeadersPanel: Click Discard
    HeadersPanel->>Controller: onDiscard()
    Controller->>Controller: setDraftHeaders(clone(sourceHeaders)), setIsDirty(false)
Loading

Last reviewed commit: e15d675

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

@andrewmelchor andrewmelchor merged commit 0bb0b57 into main Mar 3, 2026
1 check passed
@andrewmelchor andrewmelchor deleted the feat(web)/headers-edit-operations branch March 3, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant