Skip to content

Commit 13c5359

Browse files
authored
Merge pull request #6 from streed/copilot/fix-74f1c7aa-adf3-4f2d-a0b5-b55b3b99b121
Implement comprehensive settings UI to configure all application settings
2 parents 2aaff96 + 0cbea41 commit 13c5359

3 files changed

Lines changed: 60 additions & 38 deletions

File tree

cmd/config.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ var configSetCmd = &cobra.Command{
3737
Available keys:
3838
- data-dir: Data directory for storing notes database
3939
- ollama-endpoint: Ollama API endpoint
40-
- embedding-model: Embedding model name
41-
- vector-dimensions: Number of vector dimensions
42-
- enable-vector: Enable/disable vector search (true/false)
4340
- debug: Enable/disable debug logging (true/false)
4441
- summarization-model: Model to use for summarization
4542
- enable-summarization: Enable/disable summarization features (true/false)
4643
- editor: Default editor to use for editing notes (e.g., "vim", "code --wait")
44+
- enable-auto-tagging: Enable/disable AI auto-tagging features (true/false)
45+
- auto-tag-model: Model to use for auto-tagging (leave empty to use summarization model)
46+
- max-auto-tags: Maximum number of tags to auto-generate per note (1-20)
4747
- github-owner: GitHub repository owner for updates (default: streed)
48-
- github-repo: GitHub repository name for updates (default: ml-notes)`,
48+
- github-repo: GitHub repository name for updates (default: ml-notes)
49+
- lilrag-url: Lil-Rag service endpoint for enhanced semantic search`,
4950
Args: cobra.ExactArgs(2),
5051
RunE: runConfigSet,
5152
}
@@ -168,6 +169,8 @@ func runConfigSet(cmd *cobra.Command, args []string) error {
168169
cfg.GitHubOwner = value
169170
case "github-repo":
170171
cfg.GitHubRepo = value
172+
case "lilrag-url":
173+
cfg.LilRagURL = value
171174
default:
172175
return fmt.Errorf("%w: %s", interrors.ErrUnknownConfigKey, key)
173176
}

internal/api/server.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ type UpdateSettingsRequest struct {
114114
EnableSummarization *bool `json:"enable_summarization,omitempty"`
115115
Editor string `json:"editor,omitempty"`
116116
EnableAutoTagging *bool `json:"enable_auto_tagging,omitempty"`
117+
AutoTagModel string `json:"auto_tag_model,omitempty"`
117118
MaxAutoTags *int `json:"max_auto_tags,omitempty"`
118119
GitHubOwner string `json:"github_owner,omitempty"`
119120
GitHubRepo string `json:"github_repo,omitempty"`
121+
LilRagURL string `json:"lilrag_url,omitempty"`
122+
WebUITheme string `json:"webui_theme,omitempty"`
120123
}
121124

122125
func NewAPIServer(cfg *config.Config, db *sql.DB, repo *models.NoteRepository, vectorSearch search.SearchProvider, assetProvider AssetProvider) *APIServer {
@@ -1411,9 +1414,11 @@ func (s *APIServer) handleGetSettings(w http.ResponseWriter, r *http.Request) {
14111414
"enable_summarization": s.cfg.EnableSummarization,
14121415
"editor": s.cfg.Editor,
14131416
"enable_auto_tagging": s.cfg.EnableAutoTagging,
1417+
"auto_tag_model": s.cfg.AutoTagModel,
14141418
"max_auto_tags": s.cfg.MaxAutoTags,
14151419
"github_owner": s.cfg.GitHubOwner,
14161420
"github_repo": s.cfg.GitHubRepo,
1421+
"lilrag_url": s.cfg.LilRagURL,
14171422
"webui_theme": s.cfg.WebUITheme,
14181423
}
14191424

@@ -1448,6 +1453,9 @@ func (s *APIServer) handleUpdateSettings(w http.ResponseWriter, r *http.Request)
14481453
if req.EnableAutoTagging != nil {
14491454
newCfg.EnableAutoTagging = *req.EnableAutoTagging
14501455
}
1456+
if req.AutoTagModel != "" {
1457+
newCfg.AutoTagModel = req.AutoTagModel
1458+
}
14511459
if req.MaxAutoTags != nil {
14521460
if *req.MaxAutoTags < 1 || *req.MaxAutoTags > 20 {
14531461
s.writeError(w, http.StatusBadRequest, fmt.Errorf("max auto tags must be between 1 and 20"))
@@ -1461,6 +1469,12 @@ func (s *APIServer) handleUpdateSettings(w http.ResponseWriter, r *http.Request)
14611469
if req.GitHubRepo != "" {
14621470
newCfg.GitHubRepo = req.GitHubRepo
14631471
}
1472+
if req.LilRagURL != "" {
1473+
newCfg.LilRagURL = req.LilRagURL
1474+
}
1475+
if req.WebUITheme != "" {
1476+
newCfg.WebUITheme = req.WebUITheme
1477+
}
14641478

14651479
// Save the updated configuration
14661480
if err := config.Save(&newCfg); err != nil {
@@ -1483,9 +1497,11 @@ func (s *APIServer) handleUpdateSettings(w http.ResponseWriter, r *http.Request)
14831497
"enable_summarization": s.cfg.EnableSummarization,
14841498
"editor": s.cfg.Editor,
14851499
"enable_auto_tagging": s.cfg.EnableAutoTagging,
1500+
"auto_tag_model": s.cfg.AutoTagModel,
14861501
"max_auto_tags": s.cfg.MaxAutoTags,
14871502
"github_owner": s.cfg.GitHubOwner,
14881503
"github_repo": s.cfg.GitHubRepo,
1504+
"lilrag_url": s.cfg.LilRagURL,
14891505
"webui_theme": s.cfg.WebUITheme,
14901506
},
14911507
}

web/templates/settings.html

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,6 @@ <h2 class="settings-title">⚙️ Configuration Settings</h2>
4545
<!-- Alert messages will be shown as floating notifications -->
4646

4747
<form id="settings-form" class="settings-form">
48-
<!-- Vector Search Settings -->
49-
<section class="settings-section">
50-
<h3 class="section-title">🔍 Vector Search & Embeddings</h3>
51-
<div class="form-group">
52-
<label for="enable-vector-search" class="form-label">
53-
<input type="checkbox" id="enable-vector-search" name="enable_vector_search" {{if .Config.EnableVectorSearch}}checked{{end}}>
54-
Enable Vector Search
55-
</label>
56-
<p class="form-help">Enable semantic search using vector embeddings for better note discovery</p>
57-
</div>
58-
<div class="form-group">
59-
<label for="embedding-model" class="form-label">Embedding Model</label>
60-
<input type="text" id="embedding-model" name="embedding_model" class="form-input"
61-
value="{{.Config.EmbeddingModel}}" placeholder="e.g., nomic-embed-text">
62-
<p class="form-help">The model to use for generating text embeddings</p>
63-
</div>
64-
<div class="form-group">
65-
<label for="vector-dimensions" class="form-label">Vector Dimensions</label>
66-
<input type="number" id="vector-dimensions" name="vector_dimensions" class="form-input"
67-
value="{{.Config.VectorDimensions}}" min="1" max="4096" placeholder="384">
68-
<p class="form-help">Number of dimensions for vector embeddings (must match your model)</p>
69-
</div>
70-
</section>
71-
7248
<!-- Ollama Settings -->
7349
<section class="settings-section">
7450
<h3 class="section-title">🦙 Ollama Integration</h3>
@@ -80,6 +56,17 @@ <h3 class="section-title">🦙 Ollama Integration</h3>
8056
</div>
8157
</section>
8258

59+
<!-- Lil-Rag Settings -->
60+
<section class="settings-section">
61+
<h3 class="section-title">🔍 Lil-Rag Integration</h3>
62+
<div class="form-group">
63+
<label for="lilrag-url" class="form-label">Lil-Rag Service URL</label>
64+
<input type="url" id="lilrag-url" name="lilrag_url" class="form-input"
65+
value="{{.Config.LilRagURL}}" placeholder="http://localhost:12121">
66+
<p class="form-help">URL of your Lil-Rag service for enhanced semantic search with project isolation</p>
67+
</div>
68+
</section>
69+
8370
<!-- Summarization Settings -->
8471
<section class="settings-section">
8572
<h3 class="section-title">📊 Summarization & Analysis</h3>
@@ -108,6 +95,12 @@ <h3 class="section-title">🏷️ Auto-tagging</h3>
10895
</label>
10996
<p class="form-help">Automatically suggest and apply tags to notes using AI</p>
11097
</div>
98+
<div class="form-group">
99+
<label for="auto-tag-model" class="form-label">Auto-tag Model</label>
100+
<input type="text" id="auto-tag-model" name="auto_tag_model" class="form-input"
101+
value="{{.Config.AutoTagModel}}" placeholder="Leave empty to use summarization model">
102+
<p class="form-help">The model to use for auto-tagging (leave empty to use summarization model)</p>
103+
</div>
111104
<div class="form-group">
112105
<label for="max-auto-tags" class="form-label">Maximum Auto Tags</label>
113106
<input type="number" id="max-auto-tags" name="max_auto_tags" class="form-input"
@@ -127,6 +120,19 @@ <h3 class="section-title">✏️ Editor Configuration</h3>
127120
</div>
128121
</section>
129122

123+
<!-- Web UI Settings -->
124+
<section class="settings-section">
125+
<h3 class="section-title">🎨 Web UI Configuration</h3>
126+
<div class="form-group">
127+
<label for="webui-theme" class="form-label">Default Theme</label>
128+
<select id="webui-theme" name="webui_theme" class="form-input">
129+
<option value="light" {{if eq .Config.WebUITheme "light"}}selected{{end}}>Light</option>
130+
<option value="dark" {{if eq .Config.WebUITheme "dark"}}selected{{end}}>Dark</option>
131+
</select>
132+
<p class="form-help">Default theme for the web interface</p>
133+
</div>
134+
</section>
135+
130136
<!-- Update Settings -->
131137
<section class="settings-section">
132138
<h3 class="section-title">🔄 Update Configuration</h3>
@@ -224,15 +230,15 @@ <h3 class="section-title">🔧 System Configuration</h3>
224230
for (const [key, value] of formData.entries()) {
225231
if (key.startsWith('enable_') || key === 'debug') {
226232
settings[key] = true; // Checkboxes are only included if checked
227-
} else if (key === 'vector_dimensions' || key === 'max_auto_tags') {
233+
} else if (key === 'max_auto_tags') {
228234
settings[key] = parseInt(value, 10);
229235
} else if (value.trim() !== '') {
230236
settings[key] = value.trim();
231237
}
232238
}
233239

234240
// Handle unchecked checkboxes explicitly
235-
const checkboxes = ['enable_vector_search', 'enable_summarization', 'enable_auto_tagging', 'debug'];
241+
const checkboxes = ['enable_summarization', 'enable_auto_tagging', 'debug'];
236242
checkboxes.forEach(checkbox => {
237243
if (!(checkbox in settings)) {
238244
settings[checkbox] = false;
@@ -253,10 +259,6 @@ <h3 class="section-title">🔧 System Configuration</h3>
253259
if (result.success) {
254260
this.showNotification('✅ Settings saved successfully!', 'success');
255261

256-
if (result.data.reindex_needed) {
257-
this.showNotification('⚠️ Vector configuration changed. Run "ml-notes reindex" to update embeddings.', 'warning');
258-
}
259-
260262
// Update form with returned values
261263
this.updateFormWithSettings(result.data.settings);
262264
} else {
@@ -276,17 +278,18 @@ <h3 class="section-title">🔧 System Configuration</h3>
276278
try {
277279
// Reset to default values by sending minimal configuration
278280
const defaultSettings = {
279-
enable_vector_search: true,
280281
enable_summarization: true,
281282
enable_auto_tagging: true,
282283
debug: false,
283284
ollama_endpoint: 'http://localhost:11434',
284-
embedding_model: 'nomic-embed-text',
285-
vector_dimensions: 384,
285+
lilrag_url: 'http://localhost:12121',
286286
summarization_model: 'llama3.2:latest',
287+
auto_tag_model: '',
287288
max_auto_tags: 5,
289+
editor: '',
288290
github_owner: 'streed',
289-
github_repo: 'ml-notes'
291+
github_repo: 'ml-notes',
292+
webui_theme: 'dark'
290293
};
291294

292295
const response = await fetch('/api/v1/settings', {

0 commit comments

Comments
 (0)