Skip to content

Feature/firefox api key copy - #38

Merged
mitchins merged 5 commits into
mainfrom
feature/firefox-api-key-copy
Jul 22, 2026
Merged

mitchins merged 5 commits into
mainfrom
feature/firefox-api-key-copy

Conversation

@mitchins

@mitchins mitchins commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Improved API-key reveal/copy UX with dedicated controls, clearer feedback states, and safer manual-copy fallback.
    • Redesigned project presentation across dashboard and project/request views, with richer project cells and consistent “Project” labeling.
  • Bug Fixes
    • Strengthened HTML/attribute escaping for identity and project values to prevent unsafe rendering.
    • Refined clipboard behavior and UI state handling for secure vs fallback environments.
  • Tests
    • Added/updated automated coverage for API-key copy behavior, UI rendering/escaping, and rate-limit TTL timing.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d994f21-7e84-4e5f-8582-561ef854f49b

📥 Commits

Reviewing files that changed from the base of the PR and between a888131 and a8c0c3e.

📒 Files selected for processing (3)
  • smolrouter/templates/request_detail.html
  • tests/unit/test_api_key_copy_js.py
  • tests/unit/test_app.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/unit/test_api_key_copy_js.py
  • smolrouter/templates/request_detail.html
  • tests/unit/test_app.py

📝 Walkthrough

Walkthrough

The PR redesigns project identity presentation, extracts API-key copying into a reusable controller, adds browser and rendering coverage, updates application UI assertions, and makes rate-limit TTL tests wall-clock aware.

Changes

Project UI rendering

Layer / File(s) Summary
Project identity rendering and page wiring
smolrouter/templates/index.html, smolrouter/templates/client_dashboard.html, smolrouter/templates/projects.html, smolrouter/templates/request_detail.html
Project labels, conditional identity details, escaped project links, navigation handling, and table layouts are updated across dashboard and project views.
Project rendering and visible-text validation
tests/js/test_project_ui_rendering.js, tests/unit/test_app.py
Tests cover project rendering, URL and HTML escaping, injection handling, unknown identities, and updated visible page content.

API-key copy controller

Layer / File(s) Summary
Copy controller and project-detail integration
smolrouter/static/vendor/api-key-copy.js, smolrouter/templates/project_detail.html
API-key copying, fallback behavior, feedback, dismissal, and secret cleanup are centralized in a browser controller wired into the project detail page.
Copy behavior and UI contract tests
tests/js/test_api_key_copy.js, tests/unit/test_api_key_copy_js.py, tests/unit/test_project_key_manager.py
Tests cover clipboard paths, controller state, cleanup, accessibility markup, and script integration.

Rate-limit TTL test updates

Layer / File(s) Summary
Wall-clock TTL assertions
tests/unit/test_request_rate_limits.py
Fake and real Redis TTL checks now account for elapsed wall-clock time.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProjectDetail
  participant SecretController
  participant Clipboard
  participant SecretPanel
  ProjectDetail->>SecretController: showSecret(result.secret)
  SecretController->>SecretPanel: display secret and reset status
  SecretController->>Clipboard: copyText(secret)
  Clipboard-->>SecretController: return copy result
  SecretController->>SecretPanel: update status and cleanup timers
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding API key copy functionality and related Firefox-focused support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/firefox-api-key-copy

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.35%. Comparing base (38f4b08) to head (a8c0c3e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   76.29%   76.35%   +0.06%     
==========================================
  Files          38       38              
  Lines       10736    10736              
  Branches     1653     1653              
==========================================
+ Hits         8191     8198       +7     
+ Misses       1943     1938       -5     
+ Partials      602      600       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mitchins
mitchins marked this pull request as ready for review July 22, 2026 03:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
smolrouter/templates/request_detail.html (1)

322-325: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use the canonical value in the tooltip, or drop the title. title="Identity" just repeats the label; request_identity.canonical would be more useful here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@smolrouter/templates/request_detail.html` around lines 322 - 325, Update the
Identity detail span in the request template to use request_identity.canonical
as the title value instead of the redundant “Identity” label, or remove the
title attribute. Preserve the displayed canonical value and surrounding
conditional rendering.
tests/unit/test_api_key_copy_js.py (1)

12-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Surface Node script output on failure for easier CI debugging.

check=True + capture_output=True means a failing Node assertion raises CalledProcessError, whose default message doesn't include the captured stdout/stderr — the actual assertion failure text gets swallowed in CI logs.

♻️ Proposed fix: include captured output in the failure message
     repository = Path(__file__).resolve().parents[2]
-    subprocess.run(
+    result = subprocess.run(
         [node, script],
         cwd=repository,
-        check=True,
         text=True,
         capture_output=True,
     )
+    assert result.returncode == 0, result.stdout + result.stderr
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_api_key_copy_js.py` around lines 12 - 23, Update the
test_browser_behaviour helper to preserve captured Node output when
subprocess.run raises CalledProcessError: catch the failure, include its stdout
and stderr in the raised failure message, and retain successful execution and
Node-missing skip behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@smolrouter/templates/request_detail.html`:
- Around line 322-325: Update the Identity detail span in the request template
to use request_identity.canonical as the title value instead of the redundant
“Identity” label, or remove the title attribute. Preserve the displayed
canonical value and surrounding conditional rendering.

In `@tests/unit/test_api_key_copy_js.py`:
- Around line 12-23: Update the test_browser_behaviour helper to preserve
captured Node output when subprocess.run raises CalledProcessError: catch the
failure, include its stdout and stderr in the raised failure message, and retain
successful execution and Node-missing skip behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a037ea52-9265-420f-aef9-26c09989f1cc

📥 Commits

Reviewing files that changed from the base of the PR and between 38f4b08 and a888131.

📒 Files selected for processing (12)
  • smolrouter/static/vendor/api-key-copy.js
  • smolrouter/templates/client_dashboard.html
  • smolrouter/templates/index.html
  • smolrouter/templates/project_detail.html
  • smolrouter/templates/projects.html
  • smolrouter/templates/request_detail.html
  • tests/js/test_api_key_copy.js
  • tests/js/test_project_ui_rendering.js
  • tests/unit/test_api_key_copy_js.py
  • tests/unit/test_app.py
  • tests/unit/test_project_key_manager.py
  • tests/unit/test_request_rate_limits.py

@sonarqubecloud

Copy link
Copy Markdown

@mitchins
mitchins merged commit de3c662 into main Jul 22, 2026
10 checks passed
@mitchins
mitchins deleted the feature/firefox-api-key-copy branch July 22, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant