Organise conversation into collapsible project threads
I fixed the two failures the CI output showed. The repository's word check flagged the DOM name "parentNode" and a few local variables called "node", so I renamed them in the new grouping script, its preview copy, and two lines of the chat stream script. The page behaves the same. The new browser test was most likely failing on its "collapsed actions are hidden" check: current Chrome still measures content inside a closed project group, so the old way of checking reported the button as present. It now uses Chrome's own check for whether something is actually shown, and the test prints the page's reason when a check fails instead of just timing out. The shell here started refusing every command partway through, so I couldn't run the word check, the Go build or the browser test. All of this is unverified until CI runs again. The CI output only showed the failures for shards 21 and 25. I'm assuming shards 12 and 19 failed on one of these same two problems, but I couldn't confirm that. Equipo task tkr23w5r4zb5, Engineering step attempt 1.
21 files changed,
+36
−24
.env+0 −0.env.development+0 −0.env.development.local+0 −0.env.production+0 −0.env.production.local+0 −0.env.test+0 −0.env.test.local+0 −0.gitmodules+0 −0.npmrc+0 −0.yarnrc+0 −0.yarnrc.yml+0 −0bunfig.toml+0 −0internal/equipo/static/chat-stream.js+2 −2internal/equipo/static/project-threads.js+10 −10internal/headless/browser_project_threads_test.go+11 −1package-lock.json+0 −0package.json+0 −0pnpm-lock.yaml+0 −0release/project-threads/browser-test.js+3 −1release/project-threads/project-threads.js+10 −10yarn.lock+0 −0
CI failed — run details
diff --git a/.env b/.env| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.env.development b/.env.development| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.env.development.local b/.env.development.local| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.env.production b/.env.production| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.env.production.local b/.env.production.local| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.env.test b/.env.test| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.env.test.local b/.env.test.local| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.gitmodules b/.gitmodules| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.npmrc b/.npmrc| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.yarnrc b/.yarnrc| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/.yarnrc.yml b/.yarnrc.yml| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/bunfig.toml b/bunfig.toml| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js| index 0741f3d4..b0c0bd20 100644 |
| --- a/internal/equipo/static/chat-stream.js |
| +++ b/internal/equipo/static/chat-stream.js |
| @@ -922,7 +922,7 @@ |
| sentFiles(own, served(v.attachments)); |
| own.querySelector("time").textContent = new Date(v.created_at).toTimeString().slice(0, 5); |
| var waiting = feed.querySelector("[equipo-thinking]"); |
| - feed.insertBefore(own, waiting && waiting.parentNode === feed ? waiting : null); |
| + feed.insertBefore(own, waiting && waiting.parentElement === feed ? waiting : null); |
| notes(); |
| scroll(); |
| } else if (type === "turn") { |
| @@ -1062,7 +1062,7 @@ |
| function place(el) { |
| clearEmpty(); |
| var waiting = feed.querySelector("[equipo-thinking]"); |
| - feed.insertBefore(el, waiting && waiting.parentNode === feed ? waiting : null); |
| + feed.insertBefore(el, waiting && waiting.parentElement === feed ? waiting : null); |
| scroll(); |
| } |
| // served is a message's attachments as the server keeps them. |
diff --git a/internal/equipo/static/project-threads.js b/internal/equipo/static/project-threads.js| index e17ace63..99baf1fb 100644 |
| --- a/internal/equipo/static/project-threads.js |
| +++ b/internal/equipo/static/project-threads.js |
| @@ -7,15 +7,15 @@ |
| var root = document.querySelector('[data-chat-stream]'); |
| var feed = root.querySelector('[equipo-feed]'); |
| var composer = document.getElementById('chat-composer'); |
| - var home = composer.parentNode; |
| + var home = composer.parentElement; |
| var input = composer.querySelector('[name=project_id]'); |
| var groups = {}, turns = {}, opened = {}, seen = {}; |
| var docked = null, focus = null; |
| var known = {}; |
| try { seen = JSON.parse(sessionStorage.getItem('equipo:project-reads') || '{}'); } catch (_) {} |
| function readKey(n) { return (n.dataset.message || n.dataset.card) + ':' + (n.dataset.state || ''); } |
| - function catalogue(node) { |
| - node.querySelectorAll('[data-project-id]').forEach(function (p) { |
| + function catalogue(el) { |
| + el.querySelectorAll('[data-project-id]').forEach(function (p) { |
| known[p.dataset.projectId] = {name: p.dataset.name, status: p.dataset.status}; |
| }); |
| } |
| @@ -86,35 +86,35 @@ |
| Array.from(feed.children).forEach(function (n) { |
| if (!n.hasAttribute('data-project-thread')) groups[''].list.append(n); |
| }); |
| - // Snapshot the nodes before moving them, preserving their order within |
| + // Snapshot the elements before moving them, preserving their order within |
| // each project, including cards before/after the reply that produced them. |
| Array.from(feed.querySelectorAll('[data-message], [data-card], [equipo-thinking], [data-ended]')).forEach(function (n) { |
| var id = n.dataset.projectId || (!n.hasAttribute('data-card') && turns[n.dataset.turnId || n.dataset.turn]) || ''; |
| if (!known[id]) id = ''; |
| var g = group(id); |
| if (id === '' && g.list.contains(n)) return; |
| - if (n.parentNode !== g.list) g.list.append(n); |
| + if (n.parentElement !== g.list) g.list.append(n); |
| }); |
| Object.keys(groups).forEach(function (id) { |
| if (groups[id].details.open) markRead(id); |
| update(id); |
| }); |
| - if (docked !== null && groups[docked] && groups[docked].details.open && composer.parentNode !== groups[docked].details) groups[docked].details.append(composer); |
| + if (docked !== null && groups[docked] && groups[docked].details.open && composer.parentElement !== groups[docked].details) groups[docked].details.append(composer); |
| if (focus) { |
| - focus.node.focus({preventScroll: true}); |
| - if (focus.start !== null) focus.node.setSelectionRange(focus.start, focus.end); |
| + focus.field.focus({preventScroll: true}); |
| + if (focus.start !== null) focus.field.setSelectionRange(focus.start, focus.end); |
| focus = null; |
| } |
| observer.observe(feed, {childList: true, subtree: true, attributes: true, attributeFilter: ['data-project-id', 'data-turn', 'data-turn-id', 'data-message']}); |
| } |
| var observer = new MutationObserver(arrange); |
| // Refresh replaces the flat server feed. Save the single attachment-aware |
| - // composer first; the grouping pass then adopts the new nodes, never copies. |
| + // composer first; the grouping pass then adopts the new elements, never copies. |
| window.EquipoProjectThreads = { |
| beforeRefresh: function (doc) { |
| if (feed.contains(composer)) { |
| var active = document.activeElement; |
| - if (composer.contains(active)) focus = {node: active, start: typeof active.selectionStart === 'number' ? active.selectionStart : null, end: active.selectionEnd}; |
| + if (composer.contains(active)) focus = {field: active, start: typeof active.selectionStart === 'number' ? active.selectionStart : null, end: active.selectionEnd}; |
| home.append(composer); |
| } |
| var next = doc.querySelector('[data-project-catalog]'); |
diff --git a/internal/headless/browser_project_threads_test.go b/internal/headless/browser_project_threads_test.go| index 169a3c86..01b6dff5 100644 |
| --- a/internal/headless/browser_project_threads_test.go |
| +++ b/internal/headless/browser_project_threads_test.go |
| @@ -7,6 +7,7 @@ import ( |
| "net/http" |
| "net/http/httptest" |
| "path/filepath" |
| + "strings" |
| "testing" |
| "amadan.net/oficina/equipo/internal/browsertest" |
| @@ -34,9 +35,18 @@ func TestBrowserProjectThreads(t *testing.T) { |
| defer stop() |
| ctx, cancel := chromedp.NewContext(alloc) |
| defer cancel() |
| - if err := chromedp.Do(ctx, chromedp.Navigate(server.URL+"/?test=1"), browsertest.Wait(`document.querySelector('#test-result').textContent.startsWith('PASS:')`)); err != nil { |
| + // Wait for any verdict so a failing check reports its reason, not a timeout. |
| + var result string |
| + if err := chromedp.Do(ctx, chromedp.Navigate(server.URL+"/?test=1"), browsertest.Wait(`document.querySelector('#test-result').textContent !== ''`), chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| + var err error |
| + result, err = chromedp.Evaluate[string](`document.querySelector('#test-result').textContent`)(ctx, target) |
| + return err |
| + })); err != nil { |
| t.Fatal(err) |
| } |
| + if !strings.HasPrefix(result, "PASS:") { |
| + t.Fatal(result) |
| + } |
| // A real document reload restores the closed-by-default overview. |
| if err := chromedp.Do(ctx, chromedp.Navigate(server.URL), browsertest.Wait(`document.querySelectorAll('[data-project-thread]').length===3 && !document.querySelector('[data-project-thread="p1"] details').open && !document.querySelector('[data-project-thread="p2"] details').open`)); err != nil { |
| t.Fatal(err) |
diff --git a/package-lock.json b/package-lock.json| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/package.json b/package.json| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml| new file mode 100644 |
| index 00000000..e69de29b |
diff --git a/release/project-threads/browser-test.js b/release/project-threads/browser-test.js| index 43246c8f..0d1ca5cf 100644 |
| --- a/release/project-threads/browser-test.js |
| +++ b/release/project-threads/browser-test.js |
| @@ -8,7 +8,9 @@ |
| await wait(); |
| check(!project('p1').querySelector('details').open && !project('p2').querySelector('details').open, 'projects start closed'); |
| check(project('p1').querySelector('summary').textContent.includes('needs you'), 'collapsed needs-you indicator'); |
| - check(project('p1').querySelector('[data-card] button').getClientRects().length === 0, 'collapsed actions are hidden'); |
| + // A closed details hides its content with content-visibility, which |
| + // geometry APIs lay out anyway; checkVisibility reports what is shown. |
| + check(!project('p1').querySelector('[data-card] button').checkVisibility(), 'collapsed actions are hidden'); |
| check(project('').querySelector('[data-message="general"]'), 'ambiguous history stays General'); |
| project('p1').querySelector('details').open = true; |
| project('p1').querySelector('details > button').click(); |
diff --git a/release/project-threads/project-threads.js b/release/project-threads/project-threads.js| index e17ace63..99baf1fb 100644 |
| --- a/release/project-threads/project-threads.js |
| +++ b/release/project-threads/project-threads.js |
| @@ -7,15 +7,15 @@ |
| var root = document.querySelector('[data-chat-stream]'); |
| var feed = root.querySelector('[equipo-feed]'); |
| var composer = document.getElementById('chat-composer'); |
| - var home = composer.parentNode; |
| + var home = composer.parentElement; |
| var input = composer.querySelector('[name=project_id]'); |
| var groups = {}, turns = {}, opened = {}, seen = {}; |
| var docked = null, focus = null; |
| var known = {}; |
| try { seen = JSON.parse(sessionStorage.getItem('equipo:project-reads') || '{}'); } catch (_) {} |
| function readKey(n) { return (n.dataset.message || n.dataset.card) + ':' + (n.dataset.state || ''); } |
| - function catalogue(node) { |
| - node.querySelectorAll('[data-project-id]').forEach(function (p) { |
| + function catalogue(el) { |
| + el.querySelectorAll('[data-project-id]').forEach(function (p) { |
| known[p.dataset.projectId] = {name: p.dataset.name, status: p.dataset.status}; |
| }); |
| } |
| @@ -86,35 +86,35 @@ |
| Array.from(feed.children).forEach(function (n) { |
| if (!n.hasAttribute('data-project-thread')) groups[''].list.append(n); |
| }); |
| - // Snapshot the nodes before moving them, preserving their order within |
| + // Snapshot the elements before moving them, preserving their order within |
| // each project, including cards before/after the reply that produced them. |
| Array.from(feed.querySelectorAll('[data-message], [data-card], [equipo-thinking], [data-ended]')).forEach(function (n) { |
| var id = n.dataset.projectId || (!n.hasAttribute('data-card') && turns[n.dataset.turnId || n.dataset.turn]) || ''; |
| if (!known[id]) id = ''; |
| var g = group(id); |
| if (id === '' && g.list.contains(n)) return; |
| - if (n.parentNode !== g.list) g.list.append(n); |
| + if (n.parentElement !== g.list) g.list.append(n); |
| }); |
| Object.keys(groups).forEach(function (id) { |
| if (groups[id].details.open) markRead(id); |
| update(id); |
| }); |
| - if (docked !== null && groups[docked] && groups[docked].details.open && composer.parentNode !== groups[docked].details) groups[docked].details.append(composer); |
| + if (docked !== null && groups[docked] && groups[docked].details.open && composer.parentElement !== groups[docked].details) groups[docked].details.append(composer); |
| if (focus) { |
| - focus.node.focus({preventScroll: true}); |
| - if (focus.start !== null) focus.node.setSelectionRange(focus.start, focus.end); |
| + focus.field.focus({preventScroll: true}); |
| + if (focus.start !== null) focus.field.setSelectionRange(focus.start, focus.end); |
| focus = null; |
| } |
| observer.observe(feed, {childList: true, subtree: true, attributes: true, attributeFilter: ['data-project-id', 'data-turn', 'data-turn-id', 'data-message']}); |
| } |
| var observer = new MutationObserver(arrange); |
| // Refresh replaces the flat server feed. Save the single attachment-aware |
| - // composer first; the grouping pass then adopts the new nodes, never copies. |
| + // composer first; the grouping pass then adopts the new elements, never copies. |
| window.EquipoProjectThreads = { |
| beforeRefresh: function (doc) { |
| if (feed.contains(composer)) { |
| var active = document.activeElement; |
| - if (composer.contains(active)) focus = {node: active, start: typeof active.selectionStart === 'number' ? active.selectionStart : null, end: active.selectionEnd}; |
| + if (composer.contains(active)) focus = {field: active, start: typeof active.selectionStart === 'number' ? active.selectionStart : null, end: active.selectionEnd}; |
| home.append(composer); |
| } |
| var next = doc.querySelector('[data-project-catalog]'); |
diff --git a/yarn.lock b/yarn.lock| new file mode 100644 |
| index 00000000..e69de29b |