Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
139a7e0
better keyboard nav for popup
andyed Apr 19, 2025
d7b5b2d
removing dupe functions from network js, making the manfiest fully v2…
andyed May 22, 2025
31b1d6e
doc synch
andyed May 25, 2025
515bb81
sessions view stub
andyed May 25, 2025
76ddc43
Create eslint.config.js
andyed May 25, 2025
9f4ab55
v1 sessions
andyed May 25, 2025
d9018a1
working session view
andyed May 25, 2025
df76495
Improved sessions view
andyed Aug 17, 2025
e92d430
Better sessions layout
andyed Aug 17, 2025
87d9bcf
Pixel sweat for sessions
andyed Aug 17, 2025
ae3360c
ignore
andyed Aug 17, 2025
2be53f1
Iteration on nano summaries
andyed Aug 17, 2025
aa5ce23
Updated gemini nano summarization usage
andyed Aug 17, 2025
bb5747c
The Chrome Summarizer API has input size limits (~12KB), and your pag…
andyed Aug 17, 2025
b008a9e
Backup summary WIP
andyed Aug 17, 2025
1eedd9d
more granular sessions view
andyed Aug 17, 2025
962831a
hero image capture and background.js fixes
andyed Aug 18, 2025
27f45e6
adding hero images extracted as the user browses
andyed Aug 18, 2025
d129f66
removing diagnostic overlay button
andyed Aug 18, 2025
86b8096
vibing audio reactivity
andyed Aug 21, 2025
0630dad
sessions.html view!
andyed Aug 23, 2025
f578380
Integrated graph
andyed Aug 24, 2025
289b5f1
graph view polish
andyed Aug 24, 2025
a636bb0
paritally connected sessions graph
andyed Aug 24, 2025
9b95f20
graph and tracking improvments
andyed Aug 24, 2025
d54b384
sessions view upgrades and data layer dwell time accuracy
andyed Aug 25, 2025
e893066
big push on persistence
andyed Aug 25, 2025
ae98460
functional persistence debug
andyed Aug 25, 2025
fec1d23
More debug fixes
andyed Aug 25, 2025
6349fea
doc updates, summarizer still buggy
andyed Aug 27, 2025
42ad559
Still chasing summaries
andyed Aug 27, 2025
6154a46
adding audio play awareness
andyed Aug 28, 2025
df829b2
Addding starred view
andyed Oct 23, 2025
8007440
Addding starred view fixes
andyed Oct 23, 2025
3ecfe04
fix: restore graph rendering and interactivity after refactor
andyed Nov 7, 2025
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
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ src/.DS_Store
.DS_Store
src/.DS_Store
.DS_Store
.DS_Store
.DS_Store
src/newtab/state.js.bak
81 changes: 81 additions & 0 deletions DEBUGGING_NOTES_BOOKMARK_FALLBACK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Letter to Future Self: Bookmark Fallback Issues

## What I Broke (Again)

The user reverted my changes because I broke the bookmark fallback functionality. Here's what happened:

### The Original Working System
- The extension had a working bookmark fallback system
- When few tabs were open, it would show real bookmarks instead of Chrome URLs
- This was working correctly before my "fixes"

### What I Did Wrong

1. **Assumed the problem was in `init.js`** when it might have been elsewhere
2. **Replaced a working system** without fully understanding the existing flow
3. **Made the function async** which could have broken the call chain
4. **Didn't test incrementally** - made too many changes at once

### The Real Issues I Should Have Investigated

Looking at the user's screenshot, they saw:
- Multiple "getting started" tiles with `chrome://newtab/` URLs
- This suggests the filtering wasn't working, NOT that bookmarks weren't being fetched

The real problems were likely:
1. **Data source confusion**: Multiple initialization systems competing
2. **Filtering not working**: Chrome URLs getting through despite filters
3. **Background vs Frontend mismatch**: Different data sources returning different results

### What I Should Have Done Instead

1. **Check the console logs first** - see what data was actually being fetched
2. **Test the existing bookmark system** - verify if `ensureMinimumCellsLightweight` was even being called
3. **Fix the data source competition** - ensure only one system is fetching data
4. **Trace the data flow** - from Chrome API → filtering → bookmark fallback → display

### Key Lessons

1. **Don't assume the problem location** - the Chrome URLs could have come from:
- Background script returning wrong data
- Frontend filtering not working
- Multiple data sources competing
- Cache/persistence issues

2. **The working bookmark system was probably fine** - I should have focused on why Chrome URLs were getting through the filters

3. **Test incrementally** - make one small change, test, then proceed

### For Next Time

1. **Add debugging first** - see what data is actually flowing through
2. **Fix the data source competition** - ensure single source of truth
3. **Verify filtering works** - test with console logs
4. **Only then** look at bookmark fallback if it's actually broken

### The Correct Approach Should Be

1. Fix message handler issues (✅ this was correct)
2. Fix competing initialization (✅ this was correct)
3. **Debug what data is actually being fetched** (❌ I skipped this)
4. **Verify filtering works** (❌ I assumed it was broken)
5. **Only then fix bookmark fallback if needed** (❌ I jumped straight here)

## Root Cause Analysis

The user said "you fixed this before" - meaning the bookmark system WAS working previously. My changes introduced a regression by:

1. **Overcomplicating the solution** - the bookmark fallback probably worked fine
2. **Not addressing the real issue** - Chrome URLs getting through filters
3. **Making too many changes at once** - couldn't isolate what actually broke

## Next Steps (For Future Me)

1. **Revert gracefully** - let user revert, don't fight it
2. **Start with minimal debugging** - just add console logs to see data flow
3. **Fix the actual filtering issue** - why are Chrome URLs appearing?
4. **Test each change individually** - don't batch multiple fixes

The user is frustrated because I keep breaking working functionality while trying to "fix" things that weren't actually broken.

**Remember: Sometimes the problem is not where you think it is.**
263 changes: 263 additions & 0 deletions GRAPH_REFACTOR_FIXES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
# Graph Refactor Fixes Applied

## Summary

Fixed **14 critical issues** preventing graphs from rendering and functioning after the modular refactor:
1. Type mismatches between D3 selections and DOM elements
2. Missing required function parameters
3. Missing utility functions
4. Missing imports causing ReferenceErrors
5. Lost simulation references breaking features
6. Async/sync mismatch preventing favicon display
7. Missing node interactions (click, drag, tooltips)
8. Insufficient error logging

All graphs now render correctly with favicons and full interactivity in both the main graph view and session modals.

---

## Issues Fixed

### 1. Highlighting Functions - Type Mismatch
**Problem**: The highlighting functions in `graph-renderer.js` expected D3 selections but were receiving DOM elements.

**Fix**: Updated both functions to handle both DOM elements and D3 selections:
```javascript
export function highlightGraphNodeForUrl(svgElement, url) {
// Convert DOM element to D3 selection if needed
const svg = svgElement.tagName ? d3.select(svgElement) : svgElement;
// ... rest of function
}
```

### 2. Missing Session Parameter in graph.js
**Problem**: The `createForceGraph()` call in `graph.js` was missing the required `session` parameter.

**Fix**: Added a synthetic session object for the main graph view:
```javascript
const graphSession = { id: 'main-graph' };
createForceGraph(document.getElementById('graph'), nodes, links, graphSession, currentViewMode);
```

### 3. Missing extractSearchTerm Function
**Problem**: `sessions_modal.js` was calling `extractSearchTerm()` but the function didn't exist.

**Fix**: Added the function to extract search queries from common search engines (Google, Bing, DuckDuckGo, Yahoo, Baidu).

### 4. Return Value Inconsistency
**Problem**: `createForceGraph()` was returning a D3 selection instead of a DOM element.

**Fix**: Changed the return statement to return the DOM node:
```javascript
return svg.node();
```

### 5. Missing getFaviconUrl Import
**Problem**: `graph-renderer.js` was using `getFaviconUrl()` but never imported it, causing a ReferenceError.

**Fix**: Added the missing import:
```javascript
import { getFaviconUrl } from './utility.js';
```

### 6. Simulation Reference Lost
**Problem**: After refactoring, the `simulation` variable in `graph.js` was never assigned because the simulation was created inside `createForceGraph()`. This broke the position-saving functionality.

**Fix**: Modified `createForceGraph()` to return both the SVG and simulation:
```javascript
return {
svg: svg.node(),
simulation: simulation
};
```

Then updated `graph.js` to capture these values:
```javascript
const graphResult = createForceGraph(...);
if (graphResult) {
simulation = graphResult.simulation;
svg = graphResult.svg;
}
```

### 7. Missing Summary Function Imports
**Problem**: `sessions_modal.js` was calling `getCachedSummary()` and `createTruncatedSummary()` but never imported them, causing ReferenceError.

**Fix**: Added the missing imports:
```javascript
import { getCachedSummary, createTruncatedSummary } from './readout.js';
```

### 8. Async Favicon Function in Synchronous Context
**Problem**: `getFaviconUrl()` is async but was being called synchronously in D3's attribute setter, causing favicons not to display.

**Fix**: Created a synchronous helper function for graph rendering:
```javascript
function getFaviconUrlSync(url) {
try {
const urlObj = new URL(url);
const domain = urlObj.hostname;
return `https://www.google.com/s2/favicons?domain=${domain}&sz=32`;
} catch (e) {
return '';
}
}
```

### 9. Missing Node Interactions
**Problem**: Graph nodes had no interactions - couldn't click, drag, or see tooltips.

**Fix**: Added comprehensive node interactions:
- **Drag**: Drag nodes to reposition them (they stay fixed after dragging)
- **Click**: Single-click opens the URL in a new tab
- **Double-click**: Unfixes a node's position, allowing it to move freely again
- **Hover**: Shows tooltip with page title, URL, visit count, and domain
- **Cursor**: Changes to pointer on hover

```javascript
const drag = d3.drag()
.on('start', (event, d) => { /* Fix position */ })
.on('drag', (event, d) => { /* Update position */ })
.on('end', (event, d) => { /* Keep fixed */ });

node.call(drag)
.on('click', (event, d) => { chrome.tabs.create({ url: d.url }); })
.on('dblclick', (event, d) => { /* Unfix position */ })
.on('mouseover', function(event, d) => { /* Show tooltip */ })
.on('mouseout', function(event, d) => { /* Hide tooltip */ });
```

### 10. Tooltip Display Issue
**Problem**: Tooltip wasn't showing in graph.html because the code used `display: block/none` but the CSS used `opacity: 0/1`.

**Fix**: Changed tooltip show/hide to use opacity instead of display:
```javascript
// Show
tooltip.style('opacity', '1')

// Hide
tooltip.style('opacity', '0')
```

### 11. Session List Scrolling Not Working
**Problem**: Click-to-scroll feature wasn't finding page items due to URL escaping issues in the querySelector.

**Fix**: Changed from CSS.escape to exact attribute matching:
```javascript
const allPageItems = document.querySelectorAll('.session-page-item[data-url]');
for (const item of allPageItems) {
if (item.getAttribute('data-url') === d.url) {
pageItem = item;
break;
}
}
```

### 12. Better Error Logging
**Problem**: Hard to debug what was failing in graph creation.

**Fix**: Added detailed logging:
- Parameter validation with specific details
- Graph creation progress logging
- Dimension logging
- Session data processing logging

### 13. Tooltip Font Size Too Small on Large Screens
**Problem**: Tooltip text was hard to read on large/high-resolution displays.

**Fix**: Added responsive font sizing with media queries:
```css
@media (min-width: 1920px) {
.tooltip { font-size: 14px; padding: 12px; max-width: 400px; }
}
@media (min-width: 2560px) {
.tooltip { font-size: 16px; padding: 14px; max-width: 500px; }
}
```

### 14. Session Modal Graph Not Scaling to Panel Height
**Problem**: Graph in session modals had fixed height of 270px, not utilizing available vertical space.

**Fix**: Changed to flex-based height:
```css
.session-graph-svg {
width: 100%;
height: 100%;
flex-grow: 1;
min-height: 400px;
}
```

## Testing Steps

1. Open the extension in Chrome
2. Navigate to the Graph view (`graph.html`)
3. Check the console for:
- "Creating force graph:" message with node/link counts
- "Graph dimensions:" message
- Any error messages about missing parameters

4. Navigate to the Sessions view (`sessions.html`)
5. Click on a session with 8+ pages to open the modal
6. Verify:
- Graph renders in the modal
- Hovering over pages in the list highlights corresponding nodes
- No console errors

## Potential Remaining Issues

If graphs still don't render, check:

1. **D3 Library Loading**: Verify `d3.min.js` is loaded before the modules
2. **Container Dimensions**: Check if containers have width/height (0 dimensions = no render)
3. **Empty Data**: Verify nodes and links arrays are not empty
4. **CSS Issues**: Check if graph containers are visible (not `display: none`)

## Files Modified

1. **`/src/newtab/graph-renderer.js`**
- Added `getFaviconUrl` import
- Fixed highlighting functions to handle both DOM elements and D3 selections
- Changed return value to object with `svg` and `simulation`
- Added synchronous `getFaviconUrlSync()` for graph rendering
- Added node interactions: drag, click, double-click, hover with tooltips
- Added comprehensive error logging

2. **`/src/newtab/graph.js`**
- Added session parameter to `createForceGraph` call
- Captured and stored simulation and svg references from return value
- Fixed position-saving functionality

3. **`/src/newtab/sessions_modal.js`**
- Added missing `extractSearchTerm` function
- Added imports for `getCachedSummary` and `createTruncatedSummary`
- Added debug logging to `processSessionDataForGraph`

4. **`/src/newtab/graph_styles.css`**
- Added `.node-hover` class styles for JavaScript-applied hover states

## What Was Fixed

The refactor moved all graph rendering logic into `graph-renderer.js`, but several integration issues prevented graphs from rendering:

1. **Type mismatches** between D3 selections and DOM elements
2. **Missing imports** that caused ReferenceErrors
3. **Lost references** to simulation objects needed for features like position saving
4. **Missing utility functions** that were being called but didn't exist
5. **Incorrect function signatures** with missing required parameters

All these issues have been resolved. The graphs should now render correctly in both:
- The main graph view (`graph.html`)
- Session detail modals in the sessions view (`sessions.html`)

## Console Output to Expect

When graphs render successfully, you should see:
```
Processing session data for graph: { sessionId: "...", pageCount: 15 }
Processed graph data: { nodeCount: 15, linkCount: 14 }
Creating force graph: { sessionId: "...", nodeCount: 15, linkCount: 14, viewMode: "time" }
Graph dimensions: { width: 800, height: 500 }
```

If there are errors, you'll see detailed information about which parameters are missing.
20 changes: 20 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// eslint.config.js
export default [
{
languageOptions: {
ecmaVersion: 2022, // or a more recent version if you use newer syntax
sourceType: "module", // common for modern JS
globals: {
chrome: "readonly", // for Chrome extension APIs
console: "readonly",
// Add other globals if needed (e.g., for specific libraries)
}
},
rules: {
"semi": ["error", "always"],
"quotes": ["error", "double"],
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], // Warn on unused vars, ignore if prefixed with _
// Add or customize rules as needed
}
}
];
Loading