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
59 changes: 53 additions & 6 deletions packages/web/src/components/editor/EditorWithExecution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createSignal,
Match,
on,
onCleanup,
Show,
Switch
} from 'solid-js';
Expand All @@ -28,7 +29,6 @@ import {
} from '../request-workspace';
import { ScriptPanel } from '../script';
import { CodeEditor } from './CodeEditor';
import { HttpEditor } from './HttpEditor';
import { RequestSelectorBar } from './RequestSelectorBar';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dead code not fully removed

The PR's stated goal is to remove the legacy HTTP editor, but HttpEditor.tsx itself was never deleted, and two other files still reference it:

  • packages/web/src/components/editor/index.ts (line 4) still re-exports HttpEditor:
    export { HttpEditor } from './HttpEditor';
  • packages/web/src/components/editor/lazy.ts (line 4) still exports a lazy-loaded version:
    export const LazyHttpEditor = lazy(() => import('./HttpEditor'));

Since HttpEditor is no longer consumed anywhere (confirmed via search — only these two export sites reference it), these exports are now dead code that keeps the bundler from tree-shaking the entire HttpEditor module and its dependencies (codemirror, @codemirror/*). The HttpEditor.tsx source file should also be deleted as part of this refactor.

import { ResizableSplitPane } from './ResizableSplitPane';

Expand Down Expand Up @@ -212,10 +212,60 @@ export const EditorWithExecution: Component<EditorWithExecutionProps> = (props)

const selectedExecution = () => observer.selectedExecution();

const handleHttpSave = async () => {
if (activeRequestTab() === 'headers' && requestHeaderDraft.isDirty()) {
await requestHeaderDraft.onSave();
return;
}

if (activeRequestTab() === 'body' && requestBodyDraft.isDirty()) {
await requestBodyDraft.onSave();
return;
}

if (workspace.hasUnsavedChanges(props.path)) {
await workspace.saveFile(props.path);
await workspace.loadRequests(props.path);
}
};

createEffect(() => {
if (fileType() !== 'http' || typeof window === 'undefined') {
return;
}

const handleKeyDown = (event: KeyboardEvent) => {
if (
event.defaultPrevented ||
event.repeat ||
!(event.ctrlKey || event.metaKey) ||
event.shiftKey
) {
return;
}

if (event.key === 'Enter') {
event.preventDefault();
void handleHttpExecute();
return;
}

if (event.key.toLowerCase() === 's') {
event.preventDefault();
void handleHttpSave();
}
};

window.addEventListener('keydown', handleKeyDown);
onCleanup(() => {
window.removeEventListener('keydown', handleKeyDown);
});
});

return (
<div class="flex flex-col h-full">
<Switch>
{/* HTTP files: use HTTP editor with request selector */}
{/* HTTP files: request workspace + execution panel */}
<Match when={fileType() === 'http'}>
<RequestSelectorBar
requests={requests()}
Expand All @@ -231,7 +281,7 @@ export const EditorWithExecution: Component<EditorWithExecutionProps> = (props)
<div class="flex-1 min-h-0">
<ResizableSplitPane
left={
<div class="flex h-full min-h-0 flex-col">
<div class="h-full min-h-0 overflow-auto">
<RequestWorkspaceTabs
activeTab={activeRequestTab()}
onTabChange={setActiveRequestTab}
Expand Down Expand Up @@ -272,9 +322,6 @@ export const EditorWithExecution: Component<EditorWithExecutionProps> = (props)
onSaveBody={requestBodyDraft.onSave}
onDiscardBody={requestBodyDraft.onDiscard}
/>
<div class="flex-1 min-h-0">
<HttpEditor path={props.path} onExecute={handleHttpExecute} />
</div>
</div>
}
right={
Expand Down
138 changes: 0 additions & 138 deletions packages/web/src/components/editor/HttpEditor.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/web/src/components/editor/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { CreateFileDialog } from './CreateFileDialog';
export { EditorTabs } from './EditorTabs';
export { EditorWithExecution } from './EditorWithExecution';
export { HttpEditor } from './HttpEditor';
export { httpAutocomplete } from './http-autocomplete';
export { http, httpLanguage } from './http-language';
export { DiagnosticCodes, httpLintExtension } from './http-linter';
Expand Down
1 change: 0 additions & 1 deletion packages/web/src/components/editor/lazy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { lazy } from 'solid-js';

export const LazyEditorWithExecution = lazy(() => import('./EditorWithExecution'));
export const LazyHttpEditor = lazy(() => import('./HttpEditor'));
export const LazyCodeEditor = lazy(() => import('./CodeEditor'));