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
52 changes: 29 additions & 23 deletions AutoSnap/test-enhanced-flow-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,21 @@ async function navigateToWorklist(page) {
}
}

/**
* Check if a file path is in the docs folder
* @param {string} filePath - Path to check
* @returns {boolean} True if the file is in the docs folder
*/
function isInDocsFolder(filePath) {
if (!filePath) return false;

const normalizedPath = filePath.toLowerCase();
return normalizedPath.startsWith('docs/') ||
normalizedPath.startsWith('docs\\') ||
normalizedPath.includes('/docs/') ||
normalizedPath.includes('\\docs\\');
}

/**
* Detect language from folder path
* @param {string} folderPath - Path to the documentation folder
Expand All @@ -453,17 +468,15 @@ async function navigateToWorklist(page) {
function detectLanguageFromFolder(folderPath) {
if (!folderPath) return 'English';

const normalizedPath = folderPath.toLowerCase();

// Check if path is in the main docs folder (English)
if (normalizedPath.startsWith('docs/') ||
normalizedPath.startsWith('docs\\') ||
normalizedPath.includes('/docs/') ||
normalizedPath.includes('\\docs\\')) {
console.log(`🔍 Detected English documentation from docs folder: ${folderPath}`);
// IMPORTANT: First check if path is in the main docs folder (English)
// This check must come before any other language pattern checks
if (isInDocsFolder(folderPath)) {
console.log(`✅ DOCS FOLDER DETECTED: ${folderPath} - Setting language to English`);
return 'English';
}

const normalizedPath = folderPath.toLowerCase();

// Common patterns for language folders
const languagePatterns = {
'Spanish': ['spanish', 'es', 'docs-es', 'docs-spanish', '/es/', '\\es\\'],
Expand Down Expand Up @@ -2407,23 +2420,17 @@ if (hasNoDocumentContent) {
console.log(`🎯 Single file mode: Using specified language from command line: ${languageCodeArg}`);
detectedLanguage = languageCodeArg;
} else {
// Simple check: if path contains 'docs/', it's English
const normalizedPath = singleFilePath.toLowerCase();
if (normalizedPath.includes('docs/') || normalizedPath.includes('docs\\')) {
console.log(`🔍 File is in docs folder, setting language to English: ${singleFilePath}`);
detectedLanguage = 'English';
} else {
detectedLanguage = detectLanguageFromFolder(singleFilePath);
}
// We'll use the detectLanguageFromFolder function which now has proper docs folder detection
console.log(`🔍 Detecting language for file: ${singleFilePath}`);
detectedLanguage = detectLanguageFromFolder(singleFilePath);
}

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

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

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

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

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

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

Expand Down Expand Up @@ -2638,7 +2644,7 @@ if (hasNoDocumentContent) {
throw new Error('Could not import AIUtilsEnhanced from any location');
}
}
const aiUtils = new AIUtilsEnhanced(page);
const aiUtils = new AIUtilsEnhanced(page, { mode });

// Set the current markdown file path for image reference
// Priority order: processedFileResults -> processedFiles -> testDocPath -> default
Expand Down
2 changes: 1 addition & 1 deletion AutoSnap/test-enhanced-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,7 @@ if (hasNoDocumentContent) {
throw new Error('Could not import AIUtilsEnhanced from any location');
}
}
const aiUtils = new AIUtilsEnhanced(page);
const aiUtils = new AIUtilsEnhanced(page, { mode });

// Set the current markdown file path for image reference
// Priority order: processedFileResults -> processedFiles -> testDocPath -> default
Expand Down
41 changes: 31 additions & 10 deletions AutoSnap/tracewrightt/src/ai_utils_enhanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,24 @@ export class AIUtilsEnhanced {
if (fileContent && fileContent.length > 0) {
console.log(`✅ Path file contains: ${fileContent}`);

// Use the path from the file as the source of truth
const pathFromFile = this.normalizePath(fileContent);
// Check if the file content contains mode information (path|mode format)
let pathFromFile: string;
let mode: string = 'default';

if (fileContent.includes('|')) {
const [filePath, modeInfo] = fileContent.split('|');
pathFromFile = this.normalizePath(filePath);
mode = modeInfo.trim();
console.log(`📝 Detected mode information: ${mode}`);
// Store mode as an environment variable
process.env.CURRENT_MD_MODE = mode;
// Store mode as a class property for use in other methods
this.currentMode = mode;
} else {
// Legacy format - just the path
pathFromFile = this.normalizePath(fileContent);
}

this.currentMdPath = pathFromFile;

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

// First, check for placeholders and replace them if found
console.log(`🔄 Checking for placeholders to replace with image: ${imageName}`);
const placeholderUpdated = this.replacePlaceholderWithImage(updatedContent, imageName);
if (placeholderUpdated.updated) {
console.log(`✅ Successfully replaced ${placeholderUpdated.count} placeholder(s) with image reference`);
updatedContent = placeholderUpdated.content;
updatesCount += placeholderUpdated.count;
// First, check for placeholders and replace them if found - but only in new_feature mode
if (this.currentMode === 'new_feature') {
console.log(`🔍 Mode is new_feature - looking for placeholders to replace`);
console.log(`🔄 Checking for placeholders to replace with image: ${imageName}`);
const placeholderUpdated = this.replacePlaceholderWithImage(updatedContent, imageName);
if (placeholderUpdated.updated) {
console.log(`✅ Successfully replaced ${placeholderUpdated.count} placeholder(s) with image reference`);
updatedContent = placeholderUpdated.content;
updatesCount += placeholderUpdated.count;
} else {
console.log(`ℹ️ No placeholders were replaced for image: ${imageName}`);
}
} else {
console.log(`ℹ️ No placeholders were replaced for image: ${imageName}`);
console.log(`🔍 Mode is ${this.currentMode || 'default'} - skipping placeholder replacement`);
}

// Then, update existing image paths in markdown content for this specific image
Expand Down
15 changes: 9 additions & 6 deletions browser_automation_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,22 +935,25 @@ def main():
# Set as environment variable for potential use in instruction generation
os.environ['CURRENT_PROCESSING_FILE'] = args.current_file

# Write the current file path to multiple locations to ensure it's found
# Write the current file path and mode to multiple locations to ensure it's found
try:
# Include the mode in the file content
file_content = f"{args.current_file}|{scenario_type}"

# Write to the project root
root_path_file = 'current_md_path.txt'
print(f"Writing current file path to project root: {root_path_file}")
print(f"Writing current file path and mode to project root: {root_path_file}")
with open(root_path_file, 'w', encoding='utf-8') as f:
f.write(args.current_file)
f.write(file_content)

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

print(f"Successfully wrote current file path to text files")
print(f"Successfully wrote current file path and mode ({scenario_type}) to text files")
except Exception as e:
print(f"ERROR: Failed to write current file path to text file: {e}")

Expand Down
14 changes: 7 additions & 7 deletions docs/6-Image-Viewer/4_MoreOptionsToolbarMenu.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ below features:

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

![image1](./img/mo3.png)
![image1](img/mo3.png)

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

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

![mo4](./img/mo4.png)
![mo4](img/mo4.png)

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

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

![mo5](./img/mo5.png)
![mo5](img/mo5.png)

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

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

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

### 1. Hanging Protocols

Expand Down Expand Up @@ -177,17 +177,17 @@ seen below).
- **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.


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

**Popout in Window**

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

![mo7](./img/mo7.png)
![mo7](img/mo7.png)

**Fullscreen Mode (Toggle Button)**

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

![mo8](./img/mo8.png)
![mo8](img/mo8.png)
Binary file modified docs/6-Image-Viewer/img/mo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/mo8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/6-Image-Viewer/img/toggle-viewport-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.