~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Add comprehensive accessibility and keyboard navigation improvements (#427)
LearningCircuit5faba588310d
diff --git a/src/local_deep_research/web/static/css/custom_dropdown.css b/src/local_deep_research/web/static/css/custom_dropdown.cssindex 3f675bd99f..9caafb6ce8 100644--- a/src/local_deep_research/web/static/css/custom_dropdown.css+++ b/src/local_deep_research/web/static/css/custom_dropdown.css@@ -275,3 +275,183 @@ body.dropdown-active {.advanced-options-panel .custom-dropdown-list {z-index: 10000; /* Even higher z-index for dropdowns in the advanced panel */}++/* Accessibility improvements */+.sr-only {+ position: absolute !important;+ width: 1px !important;+ height: 1px !important;+ padding: 0 !important;+ margin: -1px !important;+ overflow: hidden !important;+ clip: rect(0, 0, 0, 0) !important;+ white-space: nowrap !important;+ border: 0 !important;+}++/* Enhanced search hints styling */+.search-hints {+ margin-top: 0.75rem;+ padding: 0.75rem;+ background-color: rgba(64, 191, 255, 0.05);+ border-radius: 6px;+ border: 1px solid rgba(64, 191, 255, 0.1);+}++.hint-row {+ display: flex;+ flex-wrap: wrap;+ gap: 1.5rem;+ margin-bottom: 0.5rem;+}++.hint-row:last-child {+ margin-bottom: 0;+}++.hint-item {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ font-size: 0.85rem;+ color: var(--text-secondary, #c0c0cc);+}++.hint-icon {+ color: var(--accent-tertiary, #40bfff);+ font-size: 0.8rem;+ width: 12px;+ text-align: center;+}++.hint-text {+ font-size: 0.85rem;+ color: var(--text-secondary, #c0c0cc);+}++/* Legacy keyboard hint styling for other components */+.keyboard-hint {+ margin-top: 6px;+}++.keyboard-hint .hint-text {+ font-size: 0.8rem;+ color: var(--text-secondary, #c0c0cc);+ font-style: italic;+}++/* Responsive design for hints */+@media (max-width: 767px) {+ .hint-row {+ flex-direction: column;+ gap: 0.5rem;+ }++ .hint-item {+ font-size: 0.8rem;+ }+}++/* Mode selection accessibility improvements */+.mode-selection {+ outline: none;+}++/* Override label default styles for mode options */+label.mode-option {+ display: flex !important;+ align-items: center !important;+ width: 100%;+ margin: 0;+ font-weight: normal;+}++.mode-option {+ position: relative;+ transition: all 0.2s ease;+}++.mode-option:focus {+ outline: 2px solid var(--accent-primary, #6e4ff6);+ outline-offset: 2px;+}++.mode-option:focus-visible {+ outline: 2px solid var(--accent-primary, #6e4ff6);+ outline-offset: 2px;+}++/* Ensure proper keyboard navigation */+.mode-option[tabindex="0"] {+ cursor: pointer;+}++.mode-option[tabindex="-1"] {+ cursor: pointer;+}++/* Enhanced focus states for better accessibility */+fieldset {+ border: none;+ margin: 0;+ padding: 0;+}++legend {+ font-weight: 600;+ margin-bottom: 0.5rem;+ color: var(--text-primary, #e1e2e4);+}++/* Keyboard shortcut hint styling */+.keyboard-shortcut-hint {+ display: flex;+ justify-content: center;+ align-items: center;+ margin-top: 1rem;+ padding: 0.5rem;+ animation: fadeIn 0.5s ease-in;+}++.keyboard-shortcut-hint .hint-text {+ font-size: 0.9rem;+ color: var(--text-secondary, #c0c0cc);+}++.keyboard-shortcut-hint kbd {+ display: inline-block;+ padding: 0.2rem 0.4rem;+ font-size: 0.875rem;+ font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;+ line-height: 1;+ color: var(--text-primary, #e1e2e4);+ background-color: var(--bg-tertiary, #2a2a3a);+ border: 1px solid var(--border-color, #343452);+ border-radius: 4px;+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);+ font-weight: 600;+}++@keyframes fadeIn {+ from {+ opacity: 0;+ transform: translateY(-10px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+}++/* Results page keyboard hint */+.results-keyboard-hint {+ text-align: right;+ margin-top: 0.5rem;+ padding: 0.25rem 0;+ animation: fadeIn 0.5s ease-in;+}++.results-keyboard-hint .hint-text {+ font-size: 0.85rem;+ color: var(--text-muted, #8a8aa0);+}diff --git a/src/local_deep_research/web/static/css/styles.css b/src/local_deep_research/web/static/css/styles.cssindex 9c6a7c84ba..7978bbfa85 100644--- a/src/local_deep_research/web/static/css/styles.css+++ b/src/local_deep_research/web/static/css/styles.css@@ -315,7 +315,7 @@ textarea:focus, input[type="text"]:focus {}.mode-option.active {- border-color: var (--accent-primary);+ border-color: var(--accent-primary);background-color: rgba(110, 79, 246, 0.1);}diff --git a/src/local_deep_research/web/static/js/components/progress.js b/src/local_deep_research/web/static/js/components/progress.jsindex 8654c62f1e..35ab760d9f 100644--- a/src/local_deep_research/web/static/js/components/progress.js+++ b/src/local_deep_research/web/static/js/components/progress.js@@ -81,6 +81,9 @@cancelButton.addEventListener('click', handleCancelResearch);}+ // Keyboard navigation is now handled by the global keyboard service+ // The Enter key shortcut for viewing results is automatically registered+// Note: Log panel is now automatically initialized by logpanel.js// No need to manually initialize it here@@ -648,6 +651,7 @@}}+/*** Handle research cancellation*/diff --git a/src/local_deep_research/web/static/js/components/research.js b/src/local_deep_research/web/static/js/components/research.jsindex d93cde989c..b641cb8a95 100644--- a/src/local_deep_research/web/static/js/components/research.js+++ b/src/local_deep_research/web/static/js/components/research.js@@ -50,6 +50,30 @@// Track initialization to prevent unwanted saves during initial setuplet isInitializing = true;+ /**+ * Select a research mode (both visual and radio button)+ * @param {HTMLElement} modeElement - The mode option element that was selected+ */+ function selectMode(modeElement) {+ // Update visual appearance+ modeOptions.forEach(m => {+ m.classList.remove('active');+ m.setAttribute('aria-checked', 'false');+ m.setAttribute('tabindex', '-1');+ });++ modeElement.classList.add('active');+ modeElement.setAttribute('aria-checked', 'true');+ modeElement.setAttribute('tabindex', '0');++ // Update the corresponding radio button+ const modeValue = modeElement.getAttribute('data-mode');+ const radioButton = document.getElementById(`mode-${modeValue}`);+ if (radioButton) {+ radioButton.checked = true;+ }+ }+// Model provider options from READMEconst MODEL_PROVIDERS = [{ value: 'OLLAMA', label: 'Ollama (Local)' },@@ -144,6 +168,15 @@setupEventListeners();populateModelProviders();initializeDropdowns();++ // Auto-focus the query input+ if (queryInput) {+ queryInput.focus();+ // Move cursor to end if there's existing text+ if (queryInput.value) {+ queryInput.setSelectionRange(queryInput.value.length, queryInput.value.length);+ }+ }// Set initial state of the advanced options panel based on localStorageconst savedState = localStorage.getItem('advancedOptionsOpen') === 'true';@@ -460,14 +493,54 @@// Form submissionform.addEventListener('submit', handleResearchSubmit);- // Mode selection+ // Mode selection - updated for accessibilitymodeOptions.forEach(mode => {mode.addEventListener('click', function() {- modeOptions.forEach(m => m.classList.remove('active'));- this.classList.add('active');+ selectMode(this);+ });++ mode.addEventListener('keydown', function(event) {+ if (event.key === 'Enter' || event.key === ' ') {+ event.preventDefault();+ selectMode(this);+ } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {+ event.preventDefault();+ const previousMode = this.previousElementSibling;+ if (previousMode && previousMode.classList.contains('mode-option')) {+ selectMode(previousMode);+ previousMode.focus();+ }+ } else if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {+ event.preventDefault();+ const nextMode = this.nextElementSibling;+ if (nextMode && nextMode.classList.contains('mode-option')) {+ selectMode(nextMode);+ nextMode.focus();+ }+ }});});+ // Add keyboard shortcuts for textarea+ if (queryInput) {+ queryInput.addEventListener('keydown', function(event) {+ if (event.key === 'Enter') {+ if (event.shiftKey) {+ // Allow default behavior (new line)+ return;+ } else if (event.ctrlKey || event.metaKey) {+ // Ctrl+Enter or Cmd+Enter = Submit form (common pattern)+ event.preventDefault();+ handleResearchSubmit(new Event('submit'));+ } else {+ // Just Enter = Submit form (keeping existing behavior)+ event.preventDefault();+ handleResearchSubmit(new Event('submit'));+ }+ }+ });+ }+// Model provider changeif (modelProviderSelect) {modelProviderSelect.addEventListener('change', function() {@@ -1768,9 +1841,9 @@startBtn.disabled = true;startBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Starting...';- // Get the selected research mode- const selectedMode = document.querySelector('.mode-option.active');- const mode = selectedMode ? selectedMode.getAttribute('data-mode') : 'quick';+ // Get the selected research mode from radio button (more reliable)+ const selectedModeRadio = document.querySelector('input[name="research_mode"]:checked');+ const mode = selectedModeRadio ? selectedModeRadio.value : 'quick';// Get values from form fieldsconst query = queryInput.value.trim();diff --git a/src/local_deep_research/web/static/js/components/results.js b/src/local_deep_research/web/static/js/components/results.jsindex 50ccb254dc..2469e28c0f 100644--- a/src/local_deep_research/web/static/js/components/results.js+++ b/src/local_deep_research/web/static/js/components/results.js@@ -76,6 +76,7 @@window.location.href = '/research/history';});}+}/**@@ -700,6 +701,7 @@}}+/*** Handle PDF export button click*/diff --git a/src/local_deep_research/web/static/js/services/keyboard.js b/src/local_deep_research/web/static/js/services/keyboard.jsnew file mode 100644index 0000000000..d4eaf467e3--- /dev/null+++ b/src/local_deep_research/web/static/js/services/keyboard.js@@ -0,0 +1,157 @@+/**+ * Global Keyboard Shortcuts Service+ * Provides consistent keyboard shortcuts across the application+ */+(function() {+ 'use strict';++ // Keyboard shortcut registry - simplified to just the essential ones+ const shortcuts = {+ 'newSearch': {+ keys: ['ctrl+enter', 'cmd+enter'],+ description: 'Return to main search',+ handler: () => {+ // Always navigate to main research page+ window.location.href = '/';+ }+ }+ };++ /**+ * Check if a keyboard event matches a shortcut pattern+ */+ function matchesShortcut(event, pattern) {+ const parts = pattern.toLowerCase().split('+');+ const key = parts[parts.length - 1];++ // Check modifiers+ const requiresCtrl = parts.includes('ctrl');+ const requiresCmd = parts.includes('cmd');+ const requiresShift = parts.includes('shift');+ const requiresAlt = parts.includes('alt');++ // For single key shortcuts, ensure NO modifiers are pressed+ if (parts.length === 1) {+ if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {+ return false;+ }+ }++ // Match key+ const eventKey = event.key.toLowerCase();+ if (eventKey !== key && event.code.toLowerCase() !== `key${key}`) {+ // Special handling for special keys+ if (key === '/' && eventKey !== '/') return false;+ else if (key === ',' && eventKey !== ',') return false;+ else if (key !== '/' && key !== ',' && eventKey !== key) return false;+ }++ // Match modifiers (only if required)+ if (requiresCtrl && !event.ctrlKey) return false;+ if (requiresCmd && !event.metaKey) return false;+ if (requiresShift && !event.shiftKey) return false;+ if (requiresAlt && !event.altKey) return false;++ return true;+ }++ /**+ * Initialize keyboard shortcuts+ */+ function initializeKeyboardShortcuts() {+ console.log('Keyboard shortcuts initialized');++ document.addEventListener('keydown', function(event) {+ // Skip if user is typing in an input field+ const activeElement = document.activeElement;+ const isTyping = activeElement && (+ activeElement.tagName === 'INPUT' ||+ activeElement.tagName === 'TEXTAREA' ||+ activeElement.contentEditable === 'true'+ );++ // Allow Escape even when typing+ if (isTyping && event.key !== 'Escape') {+ return;+ }++ // Debug log+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {+ console.log('Key pressed:', event.key, 'Code:', event.code);+ }++ // Check each shortcut+ for (const [name, shortcut] of Object.entries(shortcuts)) {+ for (const pattern of shortcut.keys) {+ if (matchesShortcut(event, pattern)) {+ console.log('Shortcut matched:', name, pattern);+ event.preventDefault();+ shortcut.handler(event);+ return;+ }+ }+ }+ });++ // Add help text to footer if on main pages+ addKeyboardHints();+ }++ /**+ * Add subtle keyboard hints to the UI+ */+ function addKeyboardHints() {+ // Keyboard hints disabled+ }++ /**+ * Get list of available shortcuts for current page+ */+ function getAvailableShortcuts() {+ const currentPath = window.location.pathname;+ const allShortcuts = { ...shortcuts };++ // Add page-specific shortcuts+ if (currentPath.includes('/research/progress/')) {+ allShortcuts.viewResults = {+ keys: ['enter'],+ description: 'View results (when complete)',+ handler: () => {+ const viewBtn = document.getElementById('view-results-btn');+ if (viewBtn && viewBtn.style.display !== 'none') {+ window.location.href = viewBtn.href;+ }+ }+ };+ }++ if (currentPath.includes('/research/results/')) {+ allShortcuts.escape = {+ keys: ['escape'],+ description: 'Back to new search',+ handler: () => window.location.href = '/'+ };+ }++ return allShortcuts;+ }++ // Initialize keyboard shortcuts on all pages+ if (document.readyState === 'loading') {+ document.addEventListener('DOMContentLoaded', initializeKeyboardShortcuts);+ } else {+ initializeKeyboardShortcuts();+ }++ // Expose API for other components+ window.KeyboardService = {+ shortcuts: getAvailableShortcuts,+ addShortcut: (name, config) => {+ shortcuts[name] = config;+ },+ removeShortcut: (name) => {+ delete shortcuts[name];+ }+ };++})();\ No newline at end of filediff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.htmlindex 1ad0b24979..53530aab61 100644--- a/src/local_deep_research/web/templates/base.html+++ b/src/local_deep_research/web/templates/base.html@@ -41,6 +41,7 @@<script src="{{ url_for('research.serve_static', path='js/services/ui.js') }}"></script><script src="{{ url_for('research.serve_static', path='js/services/api.js') }}"></script><script src="{{ url_for('research.serve_static', path='js/services/socket.js') }}"></script>+ <script src="{{ url_for('research.serve_static', path='js/services/keyboard.js') }}"></script><!-- Shared Components --><script src="{{ url_for('research.serve_static', path='js/components/logpanel.js') }}"></script>diff --git a/src/local_deep_research/web/templates/pages/research.html b/src/local_deep_research/web/templates/pages/research.htmlindex c55b449a68..bb32cb87e9 100644--- a/src/local_deep_research/web/templates/pages/research.html+++ b/src/local_deep_research/web/templates/pages/research.html@@ -22,26 +22,47 @@<form id="research-form"><div class="form-group"><label for="query">Research Query</label>- <textarea id="query" name="query" rows="3" placeholder="Enter your research topic or question..."></textarea>+ <textarea id="query" name="query" rows="3" placeholder="Enter your research topic or question..." autofocus></textarea>+ <div class="search-hints">+ <div class="hint-row">+ <span class="hint-item">+ <i class="fas fa-play hint-icon"></i>+ <span class="hint-text"><kbd>Enter</kbd> to search</span>+ </span>+ <span class="hint-item">+ <i class="fas fa-level-down-alt hint-icon"></i>+ <span class="hint-text"><kbd>Shift</kbd>+<kbd>Enter</kbd> for new line</span>+ </span>+ <span class="hint-item">+ <i class="fas fa-home hint-icon"></i>+ <span class="hint-text"><kbd>Ctrl</kbd>+<kbd>Enter</kbd> returns here from anywhere</span>+ </span>+ </div>+ </div></div><div class="form-group">- <label>Research Mode</label>- <div class="mode-selection">- <div class="mode-option active" data-mode="quick">- <div class="mode-icon"><i class="fas fa-bolt"></i></div>- <div class="mode-info">- <h3>Quick Summary</h3>- <p>Generated in a few minutes</p>- </div>+ <fieldset>+ <legend>Research Mode</legend>+ <div class="mode-selection" role="radiogroup" aria-labelledby="mode-legend">+ <input type="radio" id="mode-quick" name="research_mode" value="quick" checked class="sr-only">+ <label for="mode-quick" class="mode-option active" data-mode="quick" role="radio" aria-checked="true" tabindex="0">+ <div class="mode-icon"><i class="fas fa-bolt" aria-hidden="true"></i></div>+ <div class="mode-info">+ <h3>Quick Summary</h3>+ <p>Generated in a few minutes</p>+ </div>+ </label>++ <input type="radio" id="mode-detailed" name="research_mode" value="detailed" class="sr-only">+ <label for="mode-detailed" class="mode-option" data-mode="detailed" role="radio" aria-checked="false" tabindex="-1">+ <div class="mode-icon"><i class="fas fa-microscope" aria-hidden="true"></i></div>+ <div class="mode-info">+ <h3>Detailed Report</h3>+ <p>In-depth analysis (takes longer)</p>+ </div>+ </label></div>- <div class="mode-option" data-mode="detailed">- <div class="mode-icon"><i class="fas fa-microscope"></i></div>- <div class="mode-info">- <h3>Detailed Report</h3>- <p>In-depth analysis (takes longer)</p>- </div>- </div>- </div>+ </fieldset></div><!-- Advanced Options -->