fix(ai): Use context.Background() for forced patrol runs

The ForcePatrol() function was using the HTTP request context, which gets
cancelled immediately when the API response is sent. This caused LLM analysis
to fail with 'context canceled' before it could complete.

Now uses context.Background() so the goroutine runs independently of the
HTTP request lifecycle.

Also fixed dropdown hover gap issue in the dismiss menu.
This commit is contained in:
rcourtman 2025-12-10 23:31:21 +00:00
parent fd8cc4a32e
commit b1199b3cbf
2 changed files with 67 additions and 64 deletions

View file

@ -2657,8 +2657,9 @@ function OverviewTab(props: {
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg> </svg>
</button> </button>
{/* Dropdown menu */} {/* Dropdown menu - pt-2 creates visual gap while maintaining hover area */}
<div class="absolute right-0 mt-1 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50"> <div class="absolute right-0 top-full pt-1 w-48 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50">
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700">
<button <button
class="w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-gray-700 rounded-t-lg transition-colors" class="w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-gray-700 rounded-t-lg transition-colors"
onClick={async (e) => { onClick={async (e) => {
@ -2733,6 +2734,7 @@ function OverviewTab(props: {
</div> </div>
</div> </div>
</div> </div>
</div>
</Show> </Show>
</div> </div>
); );

View file

@ -1099,8 +1099,9 @@ func (p *PatrolService) GetFindingsHistory(startTime *time.Time) []*Finding {
// ForcePatrol triggers an immediate patrol run // ForcePatrol triggers an immediate patrol run
// The deep parameter is kept for API backwards compatibility but is ignored // The deep parameter is kept for API backwards compatibility but is ignored
// Uses context.Background() since this runs async after the HTTP response
func (p *PatrolService) ForcePatrol(ctx context.Context, deep bool) { func (p *PatrolService) ForcePatrol(ctx context.Context, deep bool) {
go p.runPatrol(ctx) go p.runPatrol(context.Background())
} }
// analyzePBSInstance checks a PBS backup server for issues // analyzePBSInstance checks a PBS backup server for issues