Add AI assistant for community posts#29
Open
Worldfickler wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an “AI Forum Assistant” feature to the extension for WorldQuant Support Community posts, including user-configurable OpenAI-compatible LLM settings, cached AI summaries per post, and UI to draft/insert/post AI-generated comments.
Changes:
- Adds LLM configuration fields (enable toggle, base URL, model, API key) to the sidebar settings panel, with a connectivity test on save.
- Introduces a content-script assistant card on Support Community post pages (summary generation, cached summary load, comment drafting/insertion/posting).
- Adds background services for LLM calls and Support Community AI summary/draft/comment-post actions, plus message routing and manifest wiring.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui/sidebar/sidebar.html | Adds sidebar UI inputs for AI/LLM configuration. |
| src/ui/sidebar/modules/settingsPanel.js | Reads/writes LLM config, masks stored API key, and saves settings + tests LLM connectivity. |
| src/content/support/communityAssistant.js | New content script providing the assistant card UI and interactions on Support Community posts. |
| src/content/support/communityAssistant.css | Styles for the assistant card (draggable/resizable/collapsible). |
| src/background/services/supportCommunityService.js | Adds AI summary/draft/comment posting logic + caching in community state. |
| src/background/services/sidebarMessageRouter.js | Routes new sidebar/content messages for LLM config and AI actions. |
| src/background/services/llmService.js | New LLM config persistence, connectivity test, and OpenAI-compatible chat-completions calls. |
| manifest.json | Registers the new content script/CSS and adds localhost HTTP host permissions for local endpoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+51
to
+55
| const apiKeyInput = document.getElementById(ids.llmApiKey); | ||
| hasSavedLlmApiKey = config.hasApiKey === true; | ||
| apiKeyInput.value = hasSavedLlmApiKey ? '********' : ''; | ||
| apiKeyInput.placeholder = hasSavedLlmApiKey ? 'Saved API key' : 'Required unless your endpoint does not need it'; | ||
| } |
Comment on lines
+167
to
+172
| if (llmConfig.enabled) { | ||
| setStatus('Testing AI model connection...'); | ||
| } | ||
| const savedLlmConfig = await sendMessage('WQP_LLM_CONFIG_SAVE', { config: llmConfig }); | ||
| writeLlmConfigToForm(savedLlmConfig || {}); | ||
| setStatus(llmConfig.enabled ? 'Settings saved. AI model connection test passed.' : 'Settings saved. AI is disabled.', 'success'); |
Comment on lines
+76
to
+81
| export async function runLlmJson({ systemPrompt, userPrompt, schemaName = 'result' }) { | ||
| const config = await getLlmConfigRaw(); | ||
| if (!config.enabled) throw new Error('AI is disabled. Please enable AI in the extension side panel.'); | ||
| if (!config.model) throw new Error('AI model is not configured.'); | ||
| return runLlmJsonWithConfig(config, { systemPrompt, userPrompt, schemaName }); | ||
| } |
Comment on lines
+83
to
+88
| export async function runLlmText({ systemPrompt, userPrompt, taskName = 'result' }) { | ||
| const config = await getLlmConfigRaw(); | ||
| if (!config.enabled) throw new Error('AI is disabled. Please enable AI in the extension side panel.'); | ||
| if (!config.model) throw new Error('AI model is not configured.'); | ||
| return runLlmTextWithConfig(config, { systemPrompt, userPrompt, taskName }); | ||
| } |
Comment on lines
+123
to
+127
| const content = data?.choices?.[0]?.message?.content; | ||
| if (typeof content !== 'string' || !content.trim()) { | ||
| throw new Error('LLM connectivity check returned an empty response.'); | ||
| } | ||
| return true; |
Comment on lines
+279
to
+284
| const source = data.source || {}; | ||
| const commentCount = `${source.commentCount || 0}/${source.totalCommentCount || 0}`; | ||
| const cacheTime = formatDateTime(data.cache?.savedAt || source.fetchedAt); | ||
| const statusText = data.cached ? 'Loaded cached summary.' : 'Summary generated and saved.'; | ||
| const markdown = data.summaryMarkdown || ''; | ||
| setCardContent(` |
Comment on lines
+50
to
+54
| function markdownToHtml(value) { | ||
| const lines = String(value || '').replace(/\r\n/g, '\n').split('\n'); | ||
| const blocks = []; | ||
| let paragraph = []; | ||
| let listItems = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Notes