Skip to content

Commit beace52

Browse files
author
AI Assistant
committed
Add CI and fix screenshot selection
1 parent ce6971c commit beace52

3 files changed

Lines changed: 62 additions & 15 deletions

File tree

.github/workflows/agentux-ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: AgentUX CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: "20"
19+
cache: npm
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Compile
25+
run: npm run compile
26+
27+
- name: Unit tests
28+
run: npm run test:unit

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# AgentUX — VS Code Extension for Screenshot UX Audits
22

3+
[![AgentUX CI](https://github.com/ai-craftsman404/AgentUX/actions/workflows/agentux-ci.yml/badge.svg)](https://github.com/ai-craftsman404/AgentUX/actions/workflows/agentux-ci.yml)
4+
35
AgentUX reviews static UI screenshots with OpenAI Vision, a strict JSON pipeline, and an interactive VS Code webview. It surfaces spacing, typography, contrast, navigation, interaction, and design-system insights backed by attention heatmaps and region overlays.
46

57
## Two Distinct Output Formats

src/commands/analyzeScreenshot.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,30 +171,47 @@ const resolveLocalPath = (uri?: vscode.Uri): string | null => {
171171
return null;
172172
}
173173

174-
const normalized = path.normalize(fsPath);
175-
return fs.existsSync(normalized) ? normalized : null;
174+
return path.normalize(fsPath);
176175
};
177176

178177
export const analyzeScreenshot = async (
179178
context: vscode.ExtensionContext,
180179
fileUri?: vscode.Uri,
181180
): Promise<void> => {
182181
try {
183-
let screenshotPath: string | null = resolveLocalPath(fileUri);
182+
const INVALID_SELECTION_MESSAGE =
183+
'Invalid file selection. Please select a local image file.';
184184

185-
if (!screenshotPath) {
186-
screenshotPath = resolveLocalPath(getActiveImageEditor());
187-
}
188-
189-
if (!screenshotPath) {
190-
screenshotPath = resolveLocalPath(await pickScreenshot());
191-
}
185+
let screenshotPath: string | null = null;
192186

193-
if (!screenshotPath) {
194-
vscode.window.showErrorMessage(
195-
'Invalid or unreadable screenshot. Please select a local image file.',
196-
);
197-
return;
187+
// If invoked from context menu with a URI, never fall back to the file picker.
188+
if (fileUri) {
189+
const candidate = resolveLocalPath(fileUri);
190+
if (!candidate || !fs.existsSync(candidate)) {
191+
vscode.window.showErrorMessage(INVALID_SELECTION_MESSAGE);
192+
return;
193+
}
194+
screenshotPath = candidate;
195+
} else {
196+
// If an image is open in the active editor, use it (and do not show the picker).
197+
const activeUri = getActiveImageEditor();
198+
if (activeUri) {
199+
const candidate = resolveLocalPath(activeUri);
200+
if (!candidate || !fs.existsSync(candidate)) {
201+
vscode.window.showErrorMessage(INVALID_SELECTION_MESSAGE);
202+
return;
203+
}
204+
screenshotPath = candidate;
205+
} else {
206+
// Otherwise, prompt the user to pick a file.
207+
const pickedUri = await pickScreenshot();
208+
const candidate = resolveLocalPath(pickedUri);
209+
if (!candidate || !fs.existsSync(candidate)) {
210+
vscode.window.showErrorMessage(INVALID_SELECTION_MESSAGE);
211+
return;
212+
}
213+
screenshotPath = candidate;
214+
}
198215
}
199216

200217
const metadata = await resolveMetadata();

0 commit comments

Comments
 (0)