Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Components/Pages/Jobs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3019,9 +3019,10 @@ else
/// Opens a URL in a new tab that automatically closes after a delay.
/// Used for fetch-details fallback where the browser extension captures data.
/// </summary>
private async Task OpenTabAndAutoClose(string url, int delaySeconds = 30)
private async Task OpenTabAndAutoClose(string url, int? delaySeconds = null)
{
await JSRuntime.InvokeVoidAsync("crawlPagesRunner.openAndScheduleClose", url, delaySeconds, true);
var delay = delaySeconds ?? SettingsService.GetSettings().FetchDetailsAutoCloseSeconds;
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

OpenTabAndAutoClose() uses SettingsService.GetSettings().FetchDetailsAutoCloseSeconds directly without enforcing the documented 5–300 second range (or even a > 0 fallback). If the setting is 0/negative/huge (e.g., from manual JSON edits or older data), tabs may close immediately or stay open indefinitely. Consider clamping to the supported bounds (or defaulting to 30) before calling openAndScheduleClose.

Suggested change
var delay = delaySeconds ?? SettingsService.GetSettings().FetchDetailsAutoCloseSeconds;
var configuredDelay = delaySeconds ?? SettingsService.GetSettings().FetchDetailsAutoCloseSeconds;
var delay = Math.Clamp(configuredDelay, 5, 300);

Copilot uses AI. Check for mistakes.
await JSRuntime.InvokeVoidAsync("crawlPagesRunner.openAndScheduleClose", url, delay, true);
}

private async Task ShareToWhatsApp(JobListing job)
Expand Down
32 changes: 32 additions & 0 deletions Components/Pages/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,27 @@
</div>
</div>

<!-- Fetch Details Settings -->
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0"><i class="bi bi-globe"></i> Fetch Details Settings</h5>
</div>
<div class="card-body">
<div class="mb-3">
<label class="form-label">Auto-Close Tab Delay</label>
<div class="input-group" style="max-width: 250px;">
<input type="number" class="form-control" @bind="editFetchDetailsAutoCloseSeconds" min="5" max="300" step="5" />
<span class="input-group-text">seconds</span>
</div>
<small class="text-muted">How long to keep browser tabs open when fetching job details before auto-closing. Default: 30 seconds. Range: 5-300 seconds.</small>
</div>

<button class="btn btn-primary" @onclick="SaveFetchDetailsSettings">
<i class="bi bi-check-lg"></i> Save Fetch Details Settings
</button>
</div>
</div>

<!-- Download Backup -->
<div class="card mb-4">
<div class="card-header">
Expand Down Expand Up @@ -1478,6 +1499,7 @@
// Backup directory
private string editBackupDirectory = "";
private int editHistoryMax = 50000;
private int editFetchDetailsAutoCloseSeconds = 30;
private bool editBackupOnStartup;
private int editBackupsToKeep = 10;

Expand Down Expand Up @@ -1561,6 +1583,7 @@
editBackupOnStartup = settings.BackupOnStartup;
editBackupsToKeep = settings.BackupsToKeep > 0 ? settings.BackupsToKeep : 10;
editHistoryMax = settings.HistoryMaxEntries > 0 ? settings.HistoryMaxEntries : 50000;
editFetchDetailsAutoCloseSeconds = settings.FetchDetailsAutoCloseSeconds > 0 ? settings.FetchDetailsAutoCloseSeconds : 30;
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

LoadSettings() currently accepts any positive FetchDetailsAutoCloseSeconds value (only falls back when <= 0). This can surface out-of-range values (e.g., 1 or 10000) in the UI even though SaveFetchDetailsSettings() enforces a 5–300 second range. Clamp the loaded value to the same 5–300 bounds (or fall back to 30) to keep the UI and persisted constraints consistent.

Suggested change
editFetchDetailsAutoCloseSeconds = settings.FetchDetailsAutoCloseSeconds > 0 ? settings.FetchDetailsAutoCloseSeconds : 30;
editFetchDetailsAutoCloseSeconds = settings.FetchDetailsAutoCloseSeconds > 0
? Math.Clamp(settings.FetchDetailsAutoCloseSeconds, 5, 300)
: 30;

Copilot uses AI. Check for mistakes.
editSmtpHost = settings.SmtpHost;
editSmtpPort = settings.SmtpPort;
editSmtpUsername = settings.SmtpUsername;
Expand Down Expand Up @@ -2195,6 +2218,15 @@
SettingsService.Save();
}

private void SaveFetchDetailsSettings()
{
var settings = SettingsService.GetSettings();
settings.FetchDetailsAutoCloseSeconds = editFetchDetailsAutoCloseSeconds >= 5 && editFetchDetailsAutoCloseSeconds <= 300
? editFetchDetailsAutoCloseSeconds
: 30;
SettingsService.Save();
}

private string GetDefaultBackupPath()
{
if (StorageBackend is not JsonStorageBackend jsonBackend) return "Data/Backups";
Expand Down
1 change: 1 addition & 0 deletions Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class AppSettings
public bool BackupOnStartup { get; set; }
public int BackupsToKeep { get; set; } = 10;
public int HistoryMaxEntries { get; set; } = 50000;
public int FetchDetailsAutoCloseSeconds { get; set; } = 30;
public List<CrawlPage> CrawlPages { get; set; } = new();
Comment on lines 45 to 49
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The repo has a test that claims to round-trip “ALL AppSettings fields” (BackupRestoreTests.RoundTrip_Settings_AllFieldsPreserved) but it doesn’t assert the newly added FetchDetailsAutoCloseSeconds. Please extend that test to set/assert this new field so backups/restores catch regressions for this setting too.

Copilot uses AI. Check for mistakes.
public List<JobSearchQuery> SearchQueries { get; set; } = new();
public SkillExtractionSettings SkillExtraction { get; set; } = new();
Expand Down
Loading