Skip to content

Commit 0456823

Browse files
committed
feat: finalize dual-mode API key strategy (ENV-first + advanced server key store)
1 parent a2eebfd commit 0456823

27 files changed

+1600
-154
lines changed

.github/workflows/phase2-release-gate.yml

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ on:
3838
- 'tests/e2e/**/*.js'
3939
- '.github/workflows/phase2-release-gate.yml'
4040
workflow_dispatch:
41+
inputs:
42+
run_integration_e2e:
43+
description: 'Run optional telemetry integration E2E suite'
44+
required: false
45+
default: false
46+
type: boolean
47+
comfyui_url:
48+
description: 'ComfyUI backend URL for optional integration suite'
49+
required: false
50+
default: 'http://127.0.0.1:8188'
51+
type: string
4152

4253
jobs:
4354
phase2-python-gate:
@@ -92,7 +103,7 @@ jobs:
92103
echo "- Outbound payload safety: PASS"
93104
94105
phase2-e2e-gate:
95-
name: Phase 2 E2E Regression Tests
106+
name: Phase 2 E2E Regression Tests (Required)
96107
runs-on: ubuntu-latest
97108
timeout-minutes: 10
98109

@@ -105,27 +116,16 @@ jobs:
105116
with:
106117
node-version: '18'
107118

108-
- name: Set up Python 3.10 (for HTTP server)
109-
uses: actions/setup-python@v5
110-
with:
111-
python-version: '3.10'
112-
113119
- name: Install npm dependencies
114120
run: npm ci
115121

116122
- name: Install Playwright browsers
117123
run: npx playwright install chromium --with-deps
118124

119-
- name: Verify Python is available
120-
run: |
121-
python3 --version
122-
which python3
123-
124125
- name: Run E2E tests
125126
run: npm test
126127
env:
127128
CI: true
128-
PW_PYTHON: python3
129129
timeout-minutes: 8
130130

131131
- name: Upload test results
@@ -147,11 +147,66 @@ jobs:
147147
- name: Summary
148148
if: success()
149149
run: |
150-
echo "✅ Phase 2 E2E Gate Passed"
150+
echo "✅ Phase 2 Required E2E Gate Passed"
151151
echo "- Preact loader: PASS"
152152
echo "- Settings UI: PASS"
153153
echo "- Statistics UI: PASS"
154154
echo "- Sidebar UI: PASS"
155+
echo "- Integration-tagged E2E: excluded by design"
156+
157+
phase2-e2e-integration-optional:
158+
name: Phase 2 E2E Integration (Optional)
159+
runs-on: ubuntu-latest
160+
timeout-minutes: 10
161+
if: |
162+
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_integration_e2e == 'true') ||
163+
(vars.RUN_INTEGRATION_E2E == 'true')
164+
165+
steps:
166+
- name: Checkout code
167+
uses: actions/checkout@v4
168+
169+
- name: Set up Node.js 18
170+
uses: actions/setup-node@v4
171+
with:
172+
node-version: '18'
173+
174+
- name: Install npm dependencies
175+
run: npm ci
176+
177+
- name: Install Playwright browsers
178+
run: npx playwright install chromium --with-deps
179+
180+
- name: Run optional integration E2E tests
181+
run: npm run test:integration
182+
env:
183+
CI: true
184+
COMFYUI_URL: ${{ github.event.inputs.comfyui_url || vars.COMFYUI_URL || 'http://127.0.0.1:8188' }}
185+
timeout-minutes: 8
186+
187+
- name: Upload integration report
188+
if: failure()
189+
uses: actions/upload-artifact@v4
190+
with:
191+
name: playwright-report-integration
192+
path: playwright-report/
193+
retention-days: 7
194+
195+
- name: Upload integration screenshots
196+
if: failure()
197+
uses: actions/upload-artifact@v4
198+
with:
199+
name: playwright-screenshots-integration
200+
path: test-results/
201+
retention-days: 7
202+
203+
- name: Summary
204+
if: success()
205+
run: |
206+
echo "✅ Optional integration E2E suite completed"
207+
echo "- Command: npm run test:integration"
208+
echo "- Backend URL: ${{ github.event.inputs.comfyui_url || vars.COMFYUI_URL || 'http://127.0.0.1:8188' }}"
209+
echo "- This job does not block release gate."
155210
156211
phase2-gate-complete:
157212
name: Phase 2 Gate Complete
@@ -171,8 +226,11 @@ jobs:
171226
echo " ✅ Dependency policy (2 tests)"
172227
echo " ✅ Outbound payload safety (4 tests)"
173228
echo ""
174-
echo "Frontend Regression:"
175-
echo " ✅ E2E tests (61 tests)"
229+
echo "Frontend Regression (Required):"
230+
echo " ✅ E2E tests (npm test)"
231+
echo ""
232+
echo "Optional Integration:"
233+
echo " ℹ️ E2E integration suite is separate and non-blocking"
176234
echo ""
177235
echo "This change is safe to merge."
178236
exit 0

README.md

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22

33
[繁中](docs/readme/README.zh-TW.md) | [简中](docs/readme/README.zh-CN.md) | [日本語](docs/readme/README.ja.md) | [한국어](docs/readme/README.ko.md) | [Deutsch](docs/readme/README.de.md) | [Français](docs/readme/README.fr.md) | [Italiano](docs/readme/README.it.md) | [Español](docs/readme/README.es.md) | English |
44

5+
<div align="center">
6+
<img src="assets/icon.png" alt="ComfyUI Doctor">
7+
</div>
8+
59
A continuous, real-time runtime diagnostics suite for ComfyUI featuring **LLM-powered analysis**, **interactive debugging chat**, and **50+ fix patterns**. Automatically intercepts all terminal output from startup, captures complete Python tracebacks, and delivers prioritized fix suggestions with node-level context extraction. Now supports **JSON-based pattern management** with hot-reload and **full i18n support** for 9 languages (en, zh_TW, zh_CN, ja, de, fr, it, es, ko).
610

7-
## Table of Contents
11+
## Latest Updates (Feb 2026) - Click to expand
812

9-
- [Latest Updates](#latest-updates-jan-2026---click-to-expand)
10-
- [Features](#features)
11-
- [Installation](#installation)
12-
- [Usage](#usage)
13-
- [Frontend UI](#frontend-ui)
14-
- [Settings](#settings)
15-
- [API Endpoints](#api-endpoints)
16-
- [Supported Error Patterns](#supported-error-patterns)
17-
- [Phase 2 Release Gate](#phase-2-release-gate)
18-
- [CSP Compatibility](#csp-compatibility)
19-
- [Contributing](#contributing)
13+
<details>
14+
<summary><strong>(v1.6.3): Dual-Mode API Key Strategy (ENV-first + Advanced Server Key Store)</strong></summary>
2015

21-
## Latest Updates (Jan 2026) - Click to expand
16+
- API keys are no longer persisted in frontend settings; the API key input is session-only by default.
17+
- Added a default-collapsed **🔐 Advanced Key Store (Server-side)** section for explicit save/delete actions.
18+
- Backend key resolution order is now: request key → provider ENV → generic ENV → optional server store.
19+
- Existing users with legacy frontend-stored keys are auto-migrated once to runtime memory, then the persisted key is cleared.
20+
- UI now includes inline risk guidance (`?`) warning that server store uses plaintext `secrets.json`; ENV keys remain the recommended path.
21+
22+
</details>
2223

2324
<details>
24-
<summary><strong>New: F14 Proactive Diagnostics (Health Check + Intent Signature)</strong></summary>
25+
<summary><strong>Proactive Diagnostics (Health Check + Intent Signature)</strong></summary>
2526

2627
- Added a **Diagnostics** section to the **Statistics** tab for proactive workflow troubleshooting (no LLM required).
2728
- **Health checks**: workflow lint + environment/deps + privacy/safety checks, with actionable issues.
@@ -321,6 +322,19 @@ ComfyUI Settings panel now only shows the Enable/Disable toggle - all other sett
321322

322323
</details>
323324

325+
## Table of Contents
326+
327+
- [Features](#features)
328+
- [Installation](#installation)
329+
- [Usage](#usage)
330+
- [Frontend UI](#frontend-ui)
331+
- [Settings](#settings)
332+
- [API Endpoints](#api-endpoints)
333+
- [Supported Error Patterns](#supported-error-patterns)
334+
- [Phase 2 Release Gate](#phase-2-release-gate)
335+
- [CSP Compatibility](#csp-compatibility)
336+
- [Contributing](#contributing)
337+
324338
## Features
325339

326340
- **Automatic Error Monitoring**: Captures all terminal output and detects Python tracebacks in real-time
@@ -539,13 +553,13 @@ ComfyUI-Doctor integrates with popular LLM services to provide intelligent, cont
539553
540554
### Configuration
541555

542-
![Settings Panel](./assets/settings.png)
556+
<img src="assets/settings.png" alt="side bar - settings">
543557

544558
Configure AI analysis in the **Doctor Sidebar****Settings** panel:
545559

546560
1. **AI Provider**: Select from the dropdown menu. The Base URL will auto-fill.
547561
2. **AI Base URL**: The API endpoint (auto-populated, but customizable)
548-
3. **AI API Key**: Your API key (leave empty for local LLMs like Ollama/LMStudio)
562+
3. **AI API Key**: Session-only key input for cloud providers (leave empty for local LLMs like Ollama/LMStudio)
549563
4. **AI Model Name**:
550564
- Select a model from the dropdown list (automatically populated from your provider's API)
551565
- Click the 🔄 refresh button to reload available models
@@ -559,7 +573,7 @@ Configure AI analysis in the **Doctor Sidebar** → **Settings** panel:
559573
3. Wait for the LLM to analyze the error (typically 3-10 seconds).
560574
4. Review the AI-generated debugging suggestions.
561575

562-
**Security Note**: Your API key is transmitted securely from frontend to backend for the analysis request only. It is never logged or stored persistently.
576+
**Security Note**: API keys are **session-only** in the browser (cleared on reload). The backend resolves keys via this priority chain: request key → `DOCTOR_{PROVIDER}_API_KEY``DOCTOR_LLM_API_KEY` → optional server-side store (`secrets.json`). Keys are never logged and the server store is admin-gated. `secrets.json` is plaintext on disk (OS-permission protected), so for maximum security use environment variables.
563577

564578
### Privacy Mode (PII Sanitization)
565579

@@ -702,7 +716,18 @@ You can customize ComfyUI-Doctor behavior via the **Doctor sidebar → Settings*
702716

703717
**Function**: Your API key for authentication with cloud LLM services.
704718
**Usage**: Required for cloud providers (OpenAI, DeepSeek, etc.). Leave empty for local LLMs (Ollama, LMStudio).
705-
**Security**: The key is only transmitted during analysis requests and is never logged or persisted.
719+
**Default Behavior**: Session-only in frontend (cleared on reload); not persisted in ComfyUI settings.
720+
**Runtime Resolution Priority**: Request key → provider-specific ENV → generic ENV → optional server-side key store.
721+
**Security Warning**: The server-side key store writes plaintext `secrets.json` to disk. Use ENV for production or multi-user environments.
722+
723+
**Advanced Key Store Setup (optional)**:
724+
725+
<img src="assets/key_store.png" alt="side bar - Advanced Key Store">
726+
727+
1. Expand **🔐 Advanced Key Store (Server-side)** in Settings (collapsed by default).
728+
2. Select provider, paste API key, and provide admin token if configured.
729+
3. Click **💾 Save to Server** to persist, or **🗑️ Delete** to remove.
730+
4. Confirm provider status badge (`ENV`, `Server`, `None`) to verify effective source.
706731

707732
### 9. AI Model Name
708733

0 commit comments

Comments
 (0)