Skip to content

Commit 0e97c38

Browse files
authored
Merge pull request #102 from ramsoft-inc/test-enhanced-flow-fix
Update CI version with robust docs folder detection
2 parents ab1b418 + b54d3b3 commit 0e97c38

File tree

14 files changed

+77
-47
lines changed

14 files changed

+77
-47
lines changed

AutoSnap/test-enhanced-flow-ci.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,21 @@ async function navigateToWorklist(page) {
445445
}
446446
}
447447

448+
/**
449+
* Check if a file path is in the docs folder
450+
* @param {string} filePath - Path to check
451+
* @returns {boolean} True if the file is in the docs folder
452+
*/
453+
function isInDocsFolder(filePath) {
454+
if (!filePath) return false;
455+
456+
const normalizedPath = filePath.toLowerCase();
457+
return normalizedPath.startsWith('docs/') ||
458+
normalizedPath.startsWith('docs\\') ||
459+
normalizedPath.includes('/docs/') ||
460+
normalizedPath.includes('\\docs\\');
461+
}
462+
448463
/**
449464
* Detect language from folder path
450465
* @param {string} folderPath - Path to the documentation folder
@@ -453,17 +468,15 @@ async function navigateToWorklist(page) {
453468
function detectLanguageFromFolder(folderPath) {
454469
if (!folderPath) return 'English';
455470

456-
const normalizedPath = folderPath.toLowerCase();
457-
458-
// Check if path is in the main docs folder (English)
459-
if (normalizedPath.startsWith('docs/') ||
460-
normalizedPath.startsWith('docs\\') ||
461-
normalizedPath.includes('/docs/') ||
462-
normalizedPath.includes('\\docs\\')) {
463-
console.log(`🔍 Detected English documentation from docs folder: ${folderPath}`);
471+
// IMPORTANT: First check if path is in the main docs folder (English)
472+
// This check must come before any other language pattern checks
473+
if (isInDocsFolder(folderPath)) {
474+
console.log(`✅ DOCS FOLDER DETECTED: ${folderPath} - Setting language to English`);
464475
return 'English';
465476
}
466477

478+
const normalizedPath = folderPath.toLowerCase();
479+
467480
// Common patterns for language folders
468481
const languagePatterns = {
469482
'Spanish': ['spanish', 'es', 'docs-es', 'docs-spanish', '/es/', '\\es\\'],
@@ -2407,23 +2420,17 @@ if (hasNoDocumentContent) {
24072420
console.log(`🎯 Single file mode: Using specified language from command line: ${languageCodeArg}`);
24082421
detectedLanguage = languageCodeArg;
24092422
} else {
2410-
// Simple check: if path contains 'docs/', it's English
2411-
const normalizedPath = singleFilePath.toLowerCase();
2412-
if (normalizedPath.includes('docs/') || normalizedPath.includes('docs\\')) {
2413-
console.log(`🔍 File is in docs folder, setting language to English: ${singleFilePath}`);
2414-
detectedLanguage = 'English';
2415-
} else {
2416-
detectedLanguage = detectLanguageFromFolder(singleFilePath);
2417-
}
2423+
// We'll use the detectLanguageFromFolder function which now has proper docs folder detection
2424+
console.log(`🔍 Detecting language for file: ${singleFilePath}`);
2425+
detectedLanguage = detectLanguageFromFolder(singleFilePath);
24182426
}
24192427

24202428
// Check if detected language is English (case-insensitive)
24212429
const isEnglish = detectedLanguage.toLowerCase() === 'english' || detectedLanguage.toLowerCase() === 'en';
24222430

24232431
// Check if this is ui_change or new_feature mode and file is not from docs folder
2424-
const normalizedPath = singleFilePath.toLowerCase();
2425-
// Simple check: if path contains 'docs/', it's in the docs folder
2426-
const isDocsFolder = normalizedPath.includes('docs/') || normalizedPath.includes('docs\\');
2432+
// We'll use a function to check if the file is in the docs folder
2433+
const isDocsFolder = isInDocsFolder(singleFilePath);
24272434

24282435
console.log(`🔍 Checking if file is from docs folder: ${singleFilePath} - isDocsFolder: ${isDocsFolder}`);
24292436

@@ -2498,9 +2505,8 @@ if (hasNoDocumentContent) {
24982505
const nonDocsFiles = processedFileResults.filter(result => {
24992506
if (!result.filePath) return false;
25002507

2501-
const normalizedPath = result.filePath.toLowerCase();
2502-
// Simple check: if path contains 'docs/', it's in the docs folder
2503-
const isDocsFolder = normalizedPath.includes('docs/') || normalizedPath.includes('docs\\');
2508+
// Use our helper function to check if the file is in the docs folder
2509+
const isDocsFolder = isInDocsFolder(result.filePath);
25042510

25052511
console.log(`🔍 Checking if file is from docs folder: ${result.filePath} - isDocsFolder: ${isDocsFolder}`);
25062512

@@ -2638,7 +2644,7 @@ if (hasNoDocumentContent) {
26382644
throw new Error('Could not import AIUtilsEnhanced from any location');
26392645
}
26402646
}
2641-
const aiUtils = new AIUtilsEnhanced(page);
2647+
const aiUtils = new AIUtilsEnhanced(page, { mode });
26422648

26432649
// Set the current markdown file path for image reference
26442650
// Priority order: processedFileResults -> processedFiles -> testDocPath -> default

AutoSnap/test-enhanced-flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ if (hasNoDocumentContent) {
25932593
throw new Error('Could not import AIUtilsEnhanced from any location');
25942594
}
25952595
}
2596-
const aiUtils = new AIUtilsEnhanced(page);
2596+
const aiUtils = new AIUtilsEnhanced(page, { mode });
25972597

25982598
// Set the current markdown file path for image reference
25992599
// Priority order: processedFileResults -> processedFiles -> testDocPath -> default

AutoSnap/tracewrightt/src/ai_utils_enhanced.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,24 @@ export class AIUtilsEnhanced {
128128
if (fileContent && fileContent.length > 0) {
129129
console.log(`✅ Path file contains: ${fileContent}`);
130130

131-
// Use the path from the file as the source of truth
132-
const pathFromFile = this.normalizePath(fileContent);
131+
// Check if the file content contains mode information (path|mode format)
132+
let pathFromFile: string;
133+
let mode: string = 'default';
134+
135+
if (fileContent.includes('|')) {
136+
const [filePath, modeInfo] = fileContent.split('|');
137+
pathFromFile = this.normalizePath(filePath);
138+
mode = modeInfo.trim();
139+
console.log(`📝 Detected mode information: ${mode}`);
140+
// Store mode as an environment variable
141+
process.env.CURRENT_MD_MODE = mode;
142+
// Store mode as a class property for use in other methods
143+
this.currentMode = mode;
144+
} else {
145+
// Legacy format - just the path
146+
pathFromFile = this.normalizePath(fileContent);
147+
}
148+
133149
this.currentMdPath = pathFromFile;
134150

135151
console.log(`📝 Using path from file: ${this.currentMdPath}`);
@@ -672,15 +688,20 @@ export class AIUtilsEnhanced {
672688
let updatedContent = mdContent;
673689
let updatesCount = 0;
674690

675-
// First, check for placeholders and replace them if found
676-
console.log(`🔄 Checking for placeholders to replace with image: ${imageName}`);
677-
const placeholderUpdated = this.replacePlaceholderWithImage(updatedContent, imageName);
678-
if (placeholderUpdated.updated) {
679-
console.log(`✅ Successfully replaced ${placeholderUpdated.count} placeholder(s) with image reference`);
680-
updatedContent = placeholderUpdated.content;
681-
updatesCount += placeholderUpdated.count;
691+
// First, check for placeholders and replace them if found - but only in new_feature mode
692+
if (this.currentMode === 'new_feature') {
693+
console.log(`🔍 Mode is new_feature - looking for placeholders to replace`);
694+
console.log(`🔄 Checking for placeholders to replace with image: ${imageName}`);
695+
const placeholderUpdated = this.replacePlaceholderWithImage(updatedContent, imageName);
696+
if (placeholderUpdated.updated) {
697+
console.log(`✅ Successfully replaced ${placeholderUpdated.count} placeholder(s) with image reference`);
698+
updatedContent = placeholderUpdated.content;
699+
updatesCount += placeholderUpdated.count;
700+
} else {
701+
console.log(`ℹ️ No placeholders were replaced for image: ${imageName}`);
702+
}
682703
} else {
683-
console.log(`ℹ️ No placeholders were replaced for image: ${imageName}`);
704+
console.log(`🔍 Mode is ${this.currentMode || 'default'} - skipping placeholder replacement`);
684705
}
685706

686707
// Then, update existing image paths in markdown content for this specific image

browser_automation_instructions.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -935,22 +935,25 @@ def main():
935935
# Set as environment variable for potential use in instruction generation
936936
os.environ['CURRENT_PROCESSING_FILE'] = args.current_file
937937

938-
# Write the current file path to multiple locations to ensure it's found
938+
# Write the current file path and mode to multiple locations to ensure it's found
939939
try:
940+
# Include the mode in the file content
941+
file_content = f"{args.current_file}|{scenario_type}"
942+
940943
# Write to the project root
941944
root_path_file = 'current_md_path.txt'
942-
print(f"Writing current file path to project root: {root_path_file}")
945+
print(f"Writing current file path and mode to project root: {root_path_file}")
943946
with open(root_path_file, 'w', encoding='utf-8') as f:
944-
f.write(args.current_file)
947+
f.write(file_content)
945948

946949
# Also write to the AutoSnap directory
947950
autosnap_path_file = os.path.join('AutoSnap', 'current_md_path.txt')
948-
print(f"Writing current file path to AutoSnap dir: {autosnap_path_file}")
951+
print(f"Writing current file path and mode to AutoSnap dir: {autosnap_path_file}")
949952
os.makedirs(os.path.dirname(autosnap_path_file), exist_ok=True)
950953
with open(autosnap_path_file, 'w', encoding='utf-8') as f:
951-
f.write(args.current_file)
954+
f.write(file_content)
952955

953-
print(f"Successfully wrote current file path to text files")
956+
print(f"Successfully wrote current file path and mode ({scenario_type}) to text files")
954957
except Exception as e:
955958
print(f"ERROR: Failed to write current file path to text file: {e}")
956959

docs/6-Image-Viewer/4_MoreOptionsToolbarMenu.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ below features:
5252

5353
- **Overlay:** Allows you to overlay different image layers.
5454

55-
![image1](./img/mo3.png)
55+
![image1](img/mo3.png)
5656

5757
- **Scout Lines:** Enables you to view scout lines on the image.
5858

@@ -104,7 +104,7 @@ Here's a structured layout for the **Calibration Tool** section in the Help Manu
104104
This feature links multiple series of images together. It offers two
105105
options:
106106

107-
![mo4](./img/mo4.png)
107+
![mo4](img/mo4.png)
108108

109109
- **Unlink**: Click to unlink the series.
110110

@@ -117,7 +117,7 @@ options:
117117
This feature allows you to download the current image or study. It
118118
offers two options:
119119

120-
![mo5](./img/mo5.png)
120+
![mo5](img/mo5.png)
121121

122122
- **Download Image**: Downloads the currently viewed image.
123123

@@ -129,7 +129,7 @@ Allows you to change the settings of the Image Viewer for several
129129
categories as well as view the About Image Viewer software details (as
130130
seen below).
131131

132-
![mo6-1](./img/mo6-1.png)
132+
![mo6-1](img/mo6-1.png)
133133

134134
### 1. Hanging Protocols
135135

@@ -177,17 +177,17 @@ seen below).
177177
- **Functionality:** Users can toggle this setting to automatically hide or show the viewport menu for a cleaner workspace. When enabled, the menu remains hidden until the user actively interacts with it.
178178

179179

180-
<!-- placeholder for screenshot: toggle-viewport-menu.png -->
180+
![toggle-viewport-menu](img/toggle-viewport-menu.png)
181181

182182
**Popout in Window**
183183

184184
Allows you to open the current image in a separate window.
185185

186-
![mo7](./img/mo7.png)
186+
![mo7](img/mo7.png)
187187

188188
**Fullscreen Mode (Toggle Button)**
189189

190190
Allows you to view the image in full screen mode. Clicking the button
191191
again will exit full screen mode.
192192

193-
![mo8](./img/mo8.png)
193+
![mo8](img/mo8.png)

docs/6-Image-Viewer/img/mo1.png

135 Bytes
Loading

docs/6-Image-Viewer/img/mo2.png

3.42 KB
Loading

docs/6-Image-Viewer/img/mo3.png

-356 KB
Loading

docs/6-Image-Viewer/img/mo4.png

-67.2 KB
Loading

docs/6-Image-Viewer/img/mo5.png

-78.8 KB
Loading

0 commit comments

Comments
 (0)