From 3c3bd47ff0a5bb008a698c95c6b55175a4653bdc Mon Sep 17 00:00:00 2001 From: Kishan Gupta Date: Mon, 22 Sep 2025 17:38:26 +0530 Subject: [PATCH 1/6] fix the ai-test-bug --- .../sub-components/script/Script.svelte | 240 +++++++++++++++--- 1 file changed, 205 insertions(+), 35 deletions(-) diff --git a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte index 0703094773..a3f4cd1d2d 100644 --- a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte +++ b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte @@ -62,6 +62,7 @@ let originalTestContent = ""; let currentPrompt = ""; let originalLineCount = 0; + let temporaryDisplayContent = ""; // Persistent highlighting variables let observer: MutationObserver | null = null; @@ -82,38 +83,177 @@ s.title.toLowerCase().includes(trimmedSearch), ); + $: editorReadOnly = showGeneratedTestActions; + const updateBeautifiedState = (val: boolean): void => { isBodyBeautified = val; }; + //handler function to remove the changes on tab switch export const handleTabChange = () => { if (showGeneratedTestActions) { rejectGeneratedTest(); } }; - const handleCodeMirrorChange = (e: any) => { - onTestsChange({ ...tests, script: e.detail }); + const newContent = e.detail; + + // If we have generated test actions showing, protect the generated content + if (showGeneratedTestActions) { + // Extract the actual generated content from both old and new content + const originalGeneratedContent = extractGeneratedContent( + temporaryDisplayContent, + ); + const newGeneratedContent = extractGeneratedContent(newContent); + + // Check if the generated content itself has been modified + if (originalGeneratedContent !== newGeneratedContent) { + // Generated content was modified - block the change + tick().then(() => { + // Force revert by not updating temporaryDisplayContent + temporaryDisplayContent = temporaryDisplayContent; + highlightGeneratedContent(); + }); + return; + } - // Re-apply highlights immediately after any content change if we have generated content + // Generated content is intact - allow the change and recalculate positions + temporaryDisplayContent = newContent; + + // Recalculate where the generated content is now located + recalculateGeneratedContentLines(); + + const nonGeneratedContent = extractNonGeneratedContent(newContent); + onTestsChange({ ...tests, script: nonGeneratedContent }); + } else { + // Normal behavior when no generated content is protected + onTestsChange({ ...tests, script: newContent }); + } + + // Re-apply highlights if we have generated content if (showGeneratedTestActions) { if (rafId) cancelAnimationFrame(rafId); rafId = requestAnimationFrame(() => { highlightGeneratedContent(); - // Double-check after a tiny delay - setTimeout(() => highlightGeneratedContent(), 1); }); } }; + // Helper function to extract only the generated content + const extractGeneratedContent = (fullContent: string): string => { + if (!generatedTestContent) return ""; + + // Find the generated content by exact string matching + const generatedLines = generatedTestContent.split("\n"); + const allLines = fullContent.split("\n"); + + // Look for consecutive lines that match the generated content + for (let i = 0; i <= allLines.length - generatedLines.length; i++) { + let matches = true; + for (let j = 0; j < generatedLines.length; j++) { + if (allLines[i + j] !== generatedLines[j]) { + matches = false; + break; + } + } + if (matches) { + return generatedLines.join("\n"); + } + } + + return ""; // Generated content not found (might have been deleted) + }; + + // Helper function to recalculate line positions after content changes + const recalculateGeneratedContentLines = () => { + if (!generatedTestContent || !temporaryDisplayContent) return; + + const allLines = temporaryDisplayContent.split("\n"); + const generatedLines = generatedTestContent.split("\n"); + + // Find the generated content by looking for the exact match + let foundStart = -1; + + for (let i = 0; i <= allLines.length - generatedLines.length; i++) { + let matches = true; + for (let j = 0; j < generatedLines.length; j++) { + if (allLines[i + j] !== generatedLines[j]) { + matches = false; + break; + } + } + if (matches) { + foundStart = i; + break; + } + } + + if (foundStart >= 0) { + generatedContentStartLine = foundStart; + generatedContentEndLine = foundStart + generatedLines.length - 1; + } + }; + + // Helper function to extract non-generated content + const extractNonGeneratedContent = (fullContent: string): string => { + if (!showGeneratedTestActions || !generatedTestContent) { + return fullContent; + } + + // Remove the generated content by string replacement + const separator = originalTestContent ? "\n\n" : ""; + const generatedPart = separator + generatedTestContent; + + let result = fullContent.replace(generatedPart, ""); + + // If string replacement didn't work (content might be modified), + // fall back to line-by-line extraction + if (result === fullContent) { + const lines = fullContent.split("\n"); + const nonGeneratedLines = []; + + for (let i = 0; i < lines.length; i++) { + // Only include lines that are NOT in the generated range + if (i < generatedContentStartLine || i > generatedContentEndLine) { + nonGeneratedLines.push(lines[i]); + } + } + + result = nonGeneratedLines.join("\n"); + } + + return result; + }; + const toggleLeftPanel = (): void => { isLeftPanelCollapsed = !isLeftPanelCollapsed; }; + // Update the selectSnippet function to handle bulk additions properly const selectSnippet = (data: string): void => { - let value = tests?.script || ""; - value += value ? `\n${data}` : data; - onTestsChange({ ...tests, script: value }); + let value = showGeneratedTestActions + ? temporaryDisplayContent + : tests?.script || ""; + + const newValue = value ? `${value}\n${data}` : data; + + if (showGeneratedTestActions) { + temporaryDisplayContent = newValue; + + // Recalculate line positions after adding snippet + recalculateGeneratedContentLines(); + + // Update only the non-generated part + const nonGeneratedContent = extractNonGeneratedContent(newValue); + onTestsChange({ ...tests, script: nonGeneratedContent }); + + // Reapply highlights with new line positions + setTimeout(() => { + highlightGeneratedContent(); + }, 0); + } else { + onTestsChange({ ...tests, script: newValue }); + } }; const highlightMatch = (text: string, searchTerm: string): string => { @@ -156,8 +296,8 @@ testCasePrompt = ""; generatedTestContent = result.generatedContent; - // Directly insert the generated content into the editor - await insertGeneratedContentDirectly(); + // Show generated content temporarily (don't save to tests object) + await showGeneratedContentTemporarily(); // Show the action buttons showGeneratedTestActions = true; @@ -167,28 +307,23 @@ testCasePrompt = ""; } }; - const insertGeneratedContentDirectly = async () => { - // Insert the generated test content into the current script - const currentScript = tests?.script || ""; - // Calculate the exact line positions where generated content will be placed - const currentLines = currentScript ? currentScript.split("\n") : []; + const showGeneratedContentTemporarily = async () => { + // Calculate line positions for highlighting + const currentScript = originalTestContent; const separator = currentScript ? "\n\n" : ""; - // Store where generated content starts - generatedContentStartLine = currentLines.length + (currentScript ? 2 : 0); - - // Store where generated content ends - const generatedContentLines = generatedTestContent.split("\n"); - generatedContentEndLine = - generatedContentStartLine + generatedContentLines.length - 1; + // Create the temporary display content first + temporaryDisplayContent = currentScript + separator + generatedTestContent; - const newScript = currentScript + separator + generatedTestContent; + // Now calculate line positions based on the actual combined content + const allLines = temporaryDisplayContent.split("\n"); + const generatedLines = generatedTestContent.split("\n"); - onTestsChange({ - ...tests, - script: newScript, - }); + // Find where generated content starts by working backwards + generatedContentEndLine = allLines.length - 1; + generatedContentStartLine = + generatedContentEndLine - generatedLines.length + 1; await tick(); @@ -320,6 +455,7 @@ } }); }; + const removeHighlight = () => { if (observer) { observer.disconnect(); @@ -369,10 +505,14 @@ const acceptGeneratedTest = () => { removeHighlight(); - // Keep the generated content that's already in the editor + // NOW save the generated content to the tests object + onTestsChange({ ...tests, script: temporaryDisplayContent }); + + // Clear temporary state showGeneratedTestActions = false; generatedTestContent = ""; originalTestContent = ""; + temporaryDisplayContent = ""; currentPrompt = ""; originalLineCount = 0; generatedContentStartLine = 0; @@ -382,15 +522,43 @@ const rejectGeneratedTest = () => { removeHighlight(); - // Revert to original content - onTestsChange({ ...tests, script: originalTestContent }); + // Remove the generated content by replacing it with empty string + const currentContent = temporaryDisplayContent; + const separator = originalTestContent ? "\n\n" : ""; + const expectedGeneratedPart = separator + generatedTestContent; + + // Remove the generated content from the current content + let preservedContent = currentContent.replace(expectedGeneratedPart, ""); + + // If that didn't work (content might have been modified), fall back to original + manual extraction + if (preservedContent === currentContent) { + // Fallback: manually extract non-generated content + const lines = currentContent.split("\n"); + const preservedLines = []; + + for (let i = 0; i < lines.length; i++) { + // Keep lines that are outside the generated range + if (i < generatedContentStartLine || i > generatedContentEndLine) { + preservedLines.push(lines[i]); + } + } + + preservedContent = preservedLines.join("\n"); + } + + // Save the preserved content + onTestsChange({ ...tests, script: preservedContent }); + + // Clear temporary state showGeneratedTestActions = false; generatedTestContent = ""; originalTestContent = ""; + temporaryDisplayContent = ""; currentPrompt = ""; originalLineCount = 0; + generatedContentStartLine = 0; + generatedContentEndLine = 0; }; - const regenerateTest = async () => { // Remove current highlights removeHighlight(); @@ -399,7 +567,7 @@ showGeneratedTestActions = false; // Revert to original content first - onTestsChange({ ...tests, script: originalTestContent }); + temporaryDisplayContent = originalTestContent; // Use the same prompt to regenerate const result = await onGenerateTestCases(currentPrompt); @@ -412,8 +580,8 @@ errorMessage = ""; generatedTestContent = result.generatedContent; - // Insert the new generated content - await insertGeneratedContentDirectly(); + // Show the new generated content temporarily + await showGeneratedContentTemporarily(); // Show the action buttons again showGeneratedTestActions = true; @@ -549,7 +717,9 @@ > Date: Mon, 22 Sep 2025 18:21:50 +0530 Subject: [PATCH 2/6] fix the generate-test-bug --- .../request-tests/sub-components/script/Script.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte index a3f4cd1d2d..cdb21c1ca6 100644 --- a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte +++ b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte @@ -83,8 +83,6 @@ s.title.toLowerCase().includes(trimmedSearch), ); - $: editorReadOnly = showGeneratedTestActions; - const updateBeautifiedState = (val: boolean): void => { isBodyBeautified = val; }; From 31b9ca819a5b041d539bd5e7bee2f49bd7cb0b65 Mon Sep 17 00:00:00 2001 From: Kishan Gupta Date: Mon, 22 Sep 2025 19:06:20 +0530 Subject: [PATCH 3/6] fix teh first occurence of generated content --- .../sub-components/script/Script.svelte | 98 ++++++++++++------- 1 file changed, 63 insertions(+), 35 deletions(-) diff --git a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte index cdb21c1ca6..3294d6f4cf 100644 --- a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte +++ b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte @@ -98,14 +98,27 @@ // If we have generated test actions showing, protect the generated content if (showGeneratedTestActions) { - // Extract the actual generated content from both old and new content - const originalGeneratedContent = extractGeneratedContent( - temporaryDisplayContent, - ); - const newGeneratedContent = extractGeneratedContent(newContent); + const newLines = newContent.split("\n"); + + // Check if lines in the generated range have been modified + let generatedContentModified = false; + const originalGeneratedLines = generatedTestContent.split("\n"); + + for (let i = 0; i < originalGeneratedLines.length; i++) { + const lineIndex = generatedContentStartLine + i; + if (lineIndex < newLines.length) { + if (newLines[lineIndex] !== originalGeneratedLines[i]) { + generatedContentModified = true; + break; + } + } else { + // Generated content was deleted + generatedContentModified = true; + break; + } + } - // Check if the generated content itself has been modified - if (originalGeneratedContent !== newGeneratedContent) { + if (generatedContentModified) { // Generated content was modified - block the change tick().then(() => { // Force revert by not updating temporaryDisplayContent @@ -115,13 +128,21 @@ return; } - // Generated content is intact - allow the change and recalculate positions + // Generated content is intact - allow the change temporaryDisplayContent = newContent; - // Recalculate where the generated content is now located - recalculateGeneratedContentLines(); + // Extract only the non-generated content for saving + const nonGeneratedLines = []; + const allLines = newContent.split("\n"); + + for (let i = 0; i < allLines.length; i++) { + // Only include lines that are NOT in the generated range + if (i < generatedContentStartLine || i > generatedContentEndLine) { + nonGeneratedLines.push(allLines[i]); + } + } - const nonGeneratedContent = extractNonGeneratedContent(newContent); + const nonGeneratedContent = nonGeneratedLines.join("\n"); onTestsChange({ ...tests, script: nonGeneratedContent }); } else { // Normal behavior when no generated content is protected @@ -136,30 +157,28 @@ }); } }; - // Helper function to extract only the generated content const extractGeneratedContent = (fullContent: string): string => { - if (!generatedTestContent) return ""; + if ( + !generatedTestContent || + generatedContentStartLine < 0 || + generatedContentEndLine < 0 + ) + return ""; - // Find the generated content by exact string matching - const generatedLines = generatedTestContent.split("\n"); const allLines = fullContent.split("\n"); - // Look for consecutive lines that match the generated content - for (let i = 0; i <= allLines.length - generatedLines.length; i++) { - let matches = true; - for (let j = 0; j < generatedLines.length; j++) { - if (allLines[i + j] !== generatedLines[j]) { - matches = false; - break; - } - } - if (matches) { - return generatedLines.join("\n"); - } + // Extract content only from the known generated range + const extractedLines = []; + for ( + let i = generatedContentStartLine; + i <= generatedContentEndLine && i < allLines.length; + i++ + ) { + extractedLines.push(allLines[i]); } - return ""; // Generated content not found (might have been deleted) + return extractedLines.join("\n"); }; // Helper function to recalculate line positions after content changes @@ -311,17 +330,26 @@ const currentScript = originalTestContent; const separator = currentScript ? "\n\n" : ""; - // Create the temporary display content first + // Create the temporary display content temporaryDisplayContent = currentScript + separator + generatedTestContent; - // Now calculate line positions based on the actual combined content - const allLines = temporaryDisplayContent.split("\n"); - const generatedLines = generatedTestContent.split("\n"); + // Calculate exact line positions based on the original content length + const originalLines = currentScript ? currentScript.split("\n") : []; + const separatorLines = separator ? separator.split("\n") : []; - // Find where generated content starts by working backwards - generatedContentEndLine = allLines.length - 1; + // Calculate start position: original content + separator generatedContentStartLine = - generatedContentEndLine - generatedLines.length + 1; + originalLines.length + separatorLines.length - 1; + if (currentScript && separator) { + generatedContentStartLine = originalLines.length + 1; // +1 for the empty line from separator + } else if (!currentScript) { + generatedContentStartLine = 0; + } + + // Calculate end position + const generatedLines = generatedTestContent.split("\n"); + generatedContentEndLine = + generatedContentStartLine + generatedLines.length - 1; await tick(); From b567494a7bd0116419a7cdf089a154c1511a5109 Mon Sep 17 00:00:00 2001 From: Kishan Gupta Date: Tue, 23 Sep 2025 10:22:52 +0530 Subject: [PATCH 4/6] fix the rejection of generated content when snippet is being added --- .../sub-components/script/Script.svelte | 130 ++++++++++-------- 1 file changed, 74 insertions(+), 56 deletions(-) diff --git a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte index 3294d6f4cf..0beb7d243e 100644 --- a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte +++ b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte @@ -63,6 +63,7 @@ let currentPrompt = ""; let originalLineCount = 0; let temporaryDisplayContent = ""; + let contentAddedDuringGeneration = ""; // Persistent highlighting variables let observer: MutationObserver | null = null; @@ -123,6 +124,7 @@ tick().then(() => { // Force revert by not updating temporaryDisplayContent temporaryDisplayContent = temporaryDisplayContent; + recalculateGeneratedContentLines(); highlightGeneratedContent(); }); return; @@ -188,20 +190,41 @@ const allLines = temporaryDisplayContent.split("\n"); const generatedLines = generatedTestContent.split("\n"); - // Find the generated content by looking for the exact match + // Only look for generated content in a very narrow range around the expected position + // This prevents matching similar content elsewhere let foundStart = -1; - for (let i = 0; i <= allLines.length - generatedLines.length; i++) { + // Search in a very small window around the current position + const searchStart = Math.max(0, generatedContentStartLine - 1); + const searchEnd = Math.min( + allLines.length - generatedLines.length + 1, + generatedContentStartLine + 3, // Very narrow search window + ); + + for (let i = searchStart; i < searchEnd; i++) { let matches = true; + + // Check if ALL lines match exactly for (let j = 0; j < generatedLines.length; j++) { - if (allLines[i + j] !== generatedLines[j]) { + if (i + j >= allLines.length || allLines[i + j] !== generatedLines[j]) { matches = false; break; } } + + // Additional check: make sure we're not matching content that was there before if (matches) { - foundStart = i; - break; + // Verify this is actually the generated content block by checking context + // The generated content should be preceded by original content + separator + const hasProperContext = + i === 0 || // At the beginning + (originalTestContent && i > 0) || // After original content + (!originalTestContent && i === 0); // No original content, starts at beginning + + if (hasProperContext) { + foundStart = i; + break; + } } } @@ -217,36 +240,25 @@ return fullContent; } - // Remove the generated content by string replacement - const separator = originalTestContent ? "\n\n" : ""; - const generatedPart = separator + generatedTestContent; - - let result = fullContent.replace(generatedPart, ""); + // Use line-by-line extraction based on known positions + const lines = fullContent.split("\n"); + const nonGeneratedLines = []; - // If string replacement didn't work (content might be modified), - // fall back to line-by-line extraction - if (result === fullContent) { - const lines = fullContent.split("\n"); - const nonGeneratedLines = []; - - for (let i = 0; i < lines.length; i++) { - // Only include lines that are NOT in the generated range - if (i < generatedContentStartLine || i > generatedContentEndLine) { - nonGeneratedLines.push(lines[i]); - } + for (let i = 0; i < lines.length; i++) { + // Only include lines that are NOT in the generated range + if (i < generatedContentStartLine || i > generatedContentEndLine) { + nonGeneratedLines.push(lines[i]); } - - result = nonGeneratedLines.join("\n"); } - return result; + return nonGeneratedLines.join("\n"); }; const toggleLeftPanel = (): void => { isLeftPanelCollapsed = !isLeftPanelCollapsed; }; - // Update the selectSnippet function to handle bulk additions properly + // Update the selectSnippet function to properly handle snippets without affecting generated content tracking const selectSnippet = (data: string): void => { let value = showGeneratedTestActions ? temporaryDisplayContent @@ -255,20 +267,36 @@ const newValue = value ? `${value}\n${data}` : data; if (showGeneratedTestActions) { + const snippetLines = data.split("\n").length; + const addedNewlines = value ? 1 : 0; + + // Update the content first temporaryDisplayContent = newValue; - // Recalculate line positions after adding snippet - recalculateGeneratedContentLines(); + // Calculate where the snippet was inserted + const oldLines = value.split("\n"); + const insertionPoint = oldLines.length; - // Update only the non-generated part - const nonGeneratedContent = extractNonGeneratedContent(newValue); - onTestsChange({ ...tests, script: nonGeneratedContent }); + // Only adjust if snippet was inserted before generated content + if (insertionPoint <= generatedContentStartLine) { + generatedContentStartLine += snippetLines + addedNewlines; + generatedContentEndLine += snippetLines + addedNewlines; + } + + // Track the snippet added during generation + contentAddedDuringGeneration = contentAddedDuringGeneration + ? `${contentAddedDuringGeneration}\n${data}` + : data; - // Reapply highlights with new line positions + // DON'T update the stored tests.script during generation + // This preserves the original content for rejection + + // Reapply highlights setTimeout(() => { highlightGeneratedContent(); }, 0); } else { + // Normal behavior when no generated content is active onTestsChange({ ...tests, script: newValue }); } }; @@ -294,6 +322,7 @@ const handleGenerateTestCases = async () => { // Store the original content and current prompt originalTestContent = tests?.script || ""; + contentAddedDuringGeneration = ""; originalLineCount = originalTestContent.trim() ? originalTestContent.split("\n").length : 0; @@ -531,7 +560,7 @@ const acceptGeneratedTest = () => { removeHighlight(); - // NOW save the generated content to the tests object + // Save the complete content (original + snippets + generated) onTestsChange({ ...tests, script: temporaryDisplayContent }); // Clear temporary state @@ -543,39 +572,26 @@ originalLineCount = 0; generatedContentStartLine = 0; generatedContentEndLine = 0; + contentAddedDuringGeneration = ""; // Clear snippets tracker }; const rejectGeneratedTest = () => { removeHighlight(); - // Remove the generated content by replacing it with empty string - const currentContent = temporaryDisplayContent; - const separator = originalTestContent ? "\n\n" : ""; - const expectedGeneratedPart = separator + generatedTestContent; - - // Remove the generated content from the current content - let preservedContent = currentContent.replace(expectedGeneratedPart, ""); - - // If that didn't work (content might have been modified), fall back to original + manual extraction - if (preservedContent === currentContent) { - // Fallback: manually extract non-generated content - const lines = currentContent.split("\n"); - const preservedLines = []; + // Calculate what content to revert to: + // Original content + any snippets added during generation + let revertedContent = originalTestContent || ""; - for (let i = 0; i < lines.length; i++) { - // Keep lines that are outside the generated range - if (i < generatedContentStartLine || i > generatedContentEndLine) { - preservedLines.push(lines[i]); - } - } - - preservedContent = preservedLines.join("\n"); + if (contentAddedDuringGeneration) { + revertedContent = revertedContent + ? `${revertedContent}\n${contentAddedDuringGeneration}` + : contentAddedDuringGeneration; } - // Save the preserved content - onTestsChange({ ...tests, script: preservedContent }); + // Save the reverted content (original + snippets, but no AI generation) + onTestsChange({ ...tests, script: revertedContent }); - // Clear temporary state + // Clear all temporary state showGeneratedTestActions = false; generatedTestContent = ""; originalTestContent = ""; @@ -584,7 +600,9 @@ originalLineCount = 0; generatedContentStartLine = 0; generatedContentEndLine = 0; + contentAddedDuringGeneration = ""; }; + const regenerateTest = async () => { // Remove current highlights removeHighlight(); From 6c7df8e46e1fc18d93b78f70f68db4e3efda5cd8 Mon Sep 17 00:00:00 2001 From: Kishan Gupta Date: Tue, 23 Sep 2025 22:51:25 +0530 Subject: [PATCH 5/6] remove the unnecessary function --- .../sub-components/script/Script.svelte | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte index 0beb7d243e..0023ac1209 100644 --- a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte +++ b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte @@ -234,26 +234,6 @@ } }; - // Helper function to extract non-generated content - const extractNonGeneratedContent = (fullContent: string): string => { - if (!showGeneratedTestActions || !generatedTestContent) { - return fullContent; - } - - // Use line-by-line extraction based on known positions - const lines = fullContent.split("\n"); - const nonGeneratedLines = []; - - for (let i = 0; i < lines.length; i++) { - // Only include lines that are NOT in the generated range - if (i < generatedContentStartLine || i > generatedContentEndLine) { - nonGeneratedLines.push(lines[i]); - } - } - - return nonGeneratedLines.join("\n"); - }; - const toggleLeftPanel = (): void => { isLeftPanelCollapsed = !isLeftPanelCollapsed; }; From 98e07c8fbd052cf82116dde780a755b10d8f6d29 Mon Sep 17 00:00:00 2001 From: Kishan Gupta Date: Tue, 14 Oct 2025 13:31:32 +0530 Subject: [PATCH 6/6] remove the unnecessary function --- .../sub-components/script/Script.svelte | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte index 0023ac1209..d609585015 100644 --- a/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte +++ b/packages/@sparrow-workspaces/src/features/rest-explorer/components/request-tests/sub-components/script/Script.svelte @@ -159,29 +159,6 @@ }); } }; - // Helper function to extract only the generated content - const extractGeneratedContent = (fullContent: string): string => { - if ( - !generatedTestContent || - generatedContentStartLine < 0 || - generatedContentEndLine < 0 - ) - return ""; - - const allLines = fullContent.split("\n"); - - // Extract content only from the known generated range - const extractedLines = []; - for ( - let i = generatedContentStartLine; - i <= generatedContentEndLine && i < allLines.length; - i++ - ) { - extractedLines.push(allLines[i]); - } - - return extractedLines.join("\n"); - }; // Helper function to recalculate line positions after content changes const recalculateGeneratedContentLines = () => {