Skip to content

[STORY] Manual Scan Trigger #75

@jsbattig

Description

@jsbattig

Part of: #71

Feature: Web UI and Observability

Story: Manual Scan Trigger

Overview

Objective: Implement a "Run Now" button to manually trigger a self-monitoring scan.

User Value: As an admin, I want to manually trigger a self-monitoring scan so that I can test the feature or run an immediate analysis without waiting for the scheduled time.

Acceptance Criteria

AC1: Run Now Button

Given the Self-Monitoring page status section
When displayed
Then a "Run Now" button is visible
And it is enabled only when self-monitoring is configured (GitHub CI/CD present)
And it is disabled while a scan is already running

AC2: Trigger Scan

Given the admin clicks "Run Now"
When the scan is triggered
Then a job is submitted to the existing Claude job queue
And the job is tagged as "self_monitoring" type
And the button changes to disabled with "Running..." text
And the status section updates to show scan in progress

AC3: Queue Concurrency

Given a scheduled scan is already running
When admin clicks "Run Now"
Then the manual scan is queued (not rejected)
And it executes after the current scan completes
And no concurrent self-monitoring scans run simultaneously

AC4: Completion Status

Given a manual scan completes
When the result is available
Then the status section updates to show: Completed, issues created count, any errors
And the button returns to enabled state with "Run Now" text
And the scan history table includes the manual scan entry
And any created issues appear in the issues list

AC5: Simple Status Display

Given a scan is in progress
When the status is displayed
Then it shows simply "Running..." (no detailed progress)
When the scan completes
Then it shows "Completed" or "Failed" with timestamp

Technical Requirements

API Endpoint

  • POST /admin/self-monitoring/run-now
  • Returns: { "status": "queued", "scan_id": "..." } or error

Files to Modify

  • src/code_indexer/server/web/routes/self_monitoring.py (add endpoint)
  • src/code_indexer/server/web/templates/self_monitoring.html (add button and HTMX)
  • src/code_indexer/server/self_monitoring/service.py (add trigger_scan method)

HTMX Integration

  • Button uses hx-post to trigger scan
  • Status section uses hx-get with polling to update while running
  • Uses hx-swap to update status dynamically

Testing Requirements

  • Unit test for run-now endpoint
  • Unit test for queue submission
  • Integration test for full trigger flow
  • Test for concurrent scan prevention

Definition of Done

  • Run Now button visible and functional
  • Scan is queued via existing job queue
  • Button shows Running state while scan in progress
  • Status updates on completion
  • Concurrent scans properly queued (not rejected)
  • Scan history updated with manual scan entry
  • All tests pass
  • Code review approved

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions