Luca448 commited on
Commit
e24bad7
·
1 Parent(s): 93265a5

Savestate: Fix research-canvas-overlay cleanup in catch block

Browse files
.superpowers/sdd/progress.md CHANGED
@@ -2,3 +2,4 @@
2
 
3
  Task 1: complete (commits b9d251b..def9924, review clean)
4
  Task 2: complete (commits def9924..5d50418, review overridden - logging is sufficient)
 
 
2
 
3
  Task 1: complete (commits b9d251b..def9924, review clean)
4
  Task 2: complete (commits def9924..5d50418, review overridden - logging is sufficient)
5
+ Task 3: complete (commits 5d50418..53b6a96, review clean)
.superpowers/sdd/task-3-report.md CHANGED
@@ -52,3 +52,6 @@ precache 23 entries (3566.22 KiB)
52
 
53
  **Issues or concerns after fixes:**
54
  - None. Build succeeded cleanly and all requested logic is implemented.
 
 
 
 
52
 
53
  **Issues or concerns after fixes:**
54
  - None. Build succeeded cleanly and all requested logic is implemented.
55
+
56
+ ### Fixer Update 2
57
+ - Restored `runDeepResearch` signature to `async runDeepResearch(topic, updateUIStatus, targetModel, maxTimeMinutes = 3, onGraphEvent = () => {})` and refactored the method body to correctly use parameters, preventing TypeError crash.
.superpowers/sdd/task-4-brief.md CHANGED
@@ -1,48 +1,57 @@
1
- ### Task 4: Rewrite Iterative Deep Research Pipeline
 
 
 
 
 
2
 
3
  **Files:**
4
- - Modify: `src/ai/research-agent.js`
5
 
6
  **Interfaces:**
7
- - Modifies: `async runDeepResearch(topic, updateUIStatus, targetModel)`
8
-
9
- - [ ] **Step 1: Rewrite runDeepResearch to use DDG + Jina Iterative**
10
 
 
 
11
  ```javascript
12
- // In src/ai/research-agent.js inside runDeepResearch
13
- // Replace the entire old Tavily logic with this structure:
14
-
15
- // 1. Planning (same as before but limit to 4 queries to save time)
16
- let queries = []; // (gemini call to get 4 queries)
17
- // ...
18
-
19
- // 2. Multi-Source Retrieval
20
- let allSearchHits = [];
21
- for (let i = 0; i < queries.length; i++) {
22
- if (updateUIStatus) updateUIStatus(`Recherchiere: "${queries[i]}" (${i+1}/${queries.length})...`, 1);
23
- const hits = await this.searchDDG(queries[i], 4);
24
- allSearchHits = allSearchHits.concat(hits);
25
- }
26
-
27
- // Deduplicate links
28
- const uniqueLinks = [...new Set(allSearchHits.map(h => h.link))];
29
-
30
- if (updateUIStatus) updateUIStatus(`Lade ${uniqueLinks.length} Webseiten herunter...`, 2);
31
 
32
- // 3. Parallel Scraping
33
- const scrapedDocs = await this.scrapeMultiple(uniqueLinks.slice(0, 15), 5); // Scrape top 15 max
34
 
35
- // 4. Gap analysis (optional, can do 1 more query if needed, or skip to save latency)
36
- // ...
 
 
 
 
 
 
 
 
 
37
 
38
- // 5. Synthesis
39
- const contextStr = scrapedDocs.map((s, i) => `[Quelle ${i+1}] (${s.url}):\n${s.markdown.substring(0, 8000)}`).join('\n\n');
40
- // ... generate Full Report using the same reportPrompt as before, but with new context
 
 
 
 
 
 
 
 
41
  ```
 
42
 
43
- - [ ] **Step 2: Commit**
 
 
44
 
 
45
  ```bash
46
- git add src/ai/research-agent.js
47
- git commit -m "refactor: overhaul deep research pipeline"
48
  ```
 
1
+ ### Task 4: Integrate Canvas into Chat View & Toggle
2
+
3
+ **Global Constraints:**
4
+ - Live Update Beweis: Bei jeder UI-Änderung in der index.html MUSS zwingend die Versionsnummer im `<div id="live-version-badge">` hochgezählt werden.
5
+ - Auto-Savestates: Immer am Ende eines Tasks oder nachdem eine Änderung am Code erfolgreich implementiert und verifiziert wurde, MUSST du automatisch per Git einen Commit erstellen (`git add .` und `git commit -m "Savestate: [Kurzbeschreibung]"`).
6
+ - Kostenlose APIs: Kein Tavily, nur DuckDuckGo (via Cheerio Parsen) und Jina Reader (`r.jina.ai`).
7
 
8
  **Files:**
9
+ - Modify: `src/views/chat/chat-view.js`
10
 
11
  **Interfaces:**
12
+ - Consumes: `initCanvas`, `addNode`, `addEdge` from `../../ai/research-canvas.js`, and `runDeepResearch` from `researchAgent`.
 
 
13
 
14
+ - [ ] **Step 1: Add Canvas Container to DOM**
15
+ In `src/views/chat/chat-view.js`, inside the `render()` method, add a canvas container overlay that starts hidden. Place it somewhere appropriate in the layout, e.g. covering the chat messages.
16
  ```javascript
17
+ <div id="research-canvas-overlay" style="display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 50; background: rgba(0,0,0,0.5);"></div>
18
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ - [ ] **Step 2: Add Toggle Checkbox**
21
+ In the input area of `chat-view.js`, add a "Detective Board" toggle checkbox to enable this visual mode.
22
 
23
+ - [ ] **Step 3: Wire up the Logic**
24
+ When `runDeepResearch` is triggered and the toggle is enabled:
25
+ ```javascript
26
+ import { initCanvas, addNode, addEdge } from '../../ai/research-canvas.js';
27
+ // show overlay
28
+ const overlay = document.getElementById('research-canvas-overlay');
29
+ if (overlay) {
30
+ overlay.style.display = 'block';
31
+ initCanvas(overlay);
32
+ addNode('root', 'Research Topic', 'root');
33
+ }
34
 
35
+ // NOTE: The signature is runDeepResearch(topic, updateUIStatus, targetModel, maxTimeMinutes, onGraphEvent)
36
+ // Example assuming you have 'query', 'onProgress', 'model', 'time':
37
+ await researchAgent.runDeepResearch(query, (prog) => {
38
+ // update text progress
39
+ }, model, time, (evt) => {
40
+ if (evt.type === 'node') addNode(evt.id, evt.label, evt.group);
41
+ if (evt.type === 'edge') addEdge(evt.from, evt.to);
42
+ });
43
+
44
+ // hide overlay on finish
45
+ if (overlay) overlay.style.display = 'none';
46
  ```
47
+ Ensure you adapt this to the actual existing call in `chat-view.js` for Deep Research.
48
 
49
+ - [ ] **Step 4: Run build to verify**
50
+ Run: `npm run build`
51
+ Expected: PASS
52
 
53
+ - [ ] **Step 5: Commit**
54
  ```bash
55
+ git add src/views/chat/chat-view.js
56
+ git commit -m "Savestate: Integrate Canvas into Chat View"
57
  ```
.superpowers/sdd/task-4-report.md CHANGED
@@ -1,20 +1,27 @@
1
- # Task 4 Report: Rewrite Iterative Deep Research Pipeline
2
 
3
- **Changes Made:**
4
- 1. **`src/ai/research-agent.js`**:
5
- - Refactored `runDeepResearch` to use `searchDDG` and `scrapeMultiple`.
6
- - Updated the initial planning prompt to limit generation to 4 queries.
7
- - Removed Tavily-based search logic and replaced it with DuckDuckGo (DDG) web search.
8
- - Replaced old parallel follow-up structure with a deduplicated Jina scraping step (max 15 docs).
9
- - Ensured the `reportPrompt` logic, including the Bing Image prompts and Plotly charts, remained fully intact.
10
- - Mapped the scraped results correctly into the final context block for Gemini.
11
- 2. **`index.html`**:
12
- - Bumped the Live-Update-Badge from `BUILD 1.8.143` to `BUILD 1.8.144` to prove the UI update.
13
 
14
- **Status:**
15
- - Successfully completed according to specifications. Code committed as a Savestate.
16
 
17
- **Fix Subagent Updates:**
18
- - Restored the `try...catch` block around the `searchDDG` API call inside `src/ai/research-agent.js` to ensure that a single failing DDG query doesn't crash the entire multi-source retrieval loop. A warning is logged on failure.
19
- - Bumped `index.html` Live-Update-Badge to `BUILD 1.8.145`.
20
- - Verified JS syntax and committed code as a Savestate.
 
 
 
 
 
 
 
 
 
 
1
+ # Task 4 Report: Integrate Canvas into Chat View & Toggle
2
 
3
+ ## What was implemented
4
+ 1. Added the `#research-canvas-overlay` to the DOM in `src/views/chat/chat-view.js` inside the `render()` method, just above the `#chat-messages` container.
5
+ 2. Added the "Detective Board" toggle checkbox in `src/app.js` right under the "Vertiefte Recherche" toggle in the plus menu.
6
+ 3. Updated `src/app.js` so the Detective Board toggle is shown/hidden whenever the Deep Research toggle state changes.
7
+ 4. Updated `src/ai/router.js` to accept `options.onGraphEvent` and pass it to `researchAgent.runDeepResearch`.
8
+ 5. Wired up the actual `isDetectiveBoard` toggle read and passing of `onGraphEvent` in `src/views/chat/chat-view.js` inside `handleChatSubmit`.
9
+ 6. Incremented the Live Update Beweis version number in `index.html` from `1.8.153` to `1.8.154`.
10
+ 7. Ran `npm run build` to verify the code compiles without errors.
 
 
11
 
12
+ ## Test Results
13
+ `npm run build` ran successfully and completed with `✓ built in 2.94s`. No errors.
14
 
15
+ ## Files changed
16
+ - `src/app.js` (Added toggle and logic)
17
+ - `src/views/chat/chat-view.js` (Added canvas container, imported canvas setup, wired up toggle logic)
18
+ - `src/ai/router.js` (Passed `onGraphEvent` to `runDeepResearch`)
19
+ - `index.html` (Bumped Live Version Badge)
20
+
21
+ ## Self-Review Findings
22
+ - **Completeness:** The specs were implemented. The canvas overlay is in place, the toggle is created, and the events from Deep Research will now trigger `addNode` and `addEdge`.
23
+ - **Quality:** Code changes fit naturally with the existing codebase patterns.
24
+ - **Discipline:** No over-engineering.
25
+
26
+ ## Concerns
27
+ None.
src/views/chat/chat-view.js CHANGED
@@ -4982,7 +4982,10 @@ body { margin: 0; padding: 0; background: #000; overflow: hidden; display: flex;
4982
 
4983
  } catch (e) {
4984
  await this.hideTypingIndicator();
4985
- if (isDeepResearch) deepResearchLoader.hide();
 
 
 
4986
 
4987
  if (e.name === 'AbortError') {
4988
  this.appendMessageElement('assistant', '**Anfrage wurde abgebrochen.**', false, true, text);
 
4982
 
4983
  } catch (e) {
4984
  await this.hideTypingIndicator();
4985
+ if (isDeepResearch) {
4986
+ deepResearchLoader.hide();
4987
+ if (isDetectiveBoard && overlay) overlay.style.display = 'none';
4988
+ }
4989
 
4990
  if (e.name === 'AbortError') {
4991
  this.appendMessageElement('assistant', '**Anfrage wurde abgebrochen.**', false, true, text);