feat(webui): preserve drawer session context (#797)
This commit is contained in:
1 parent
6eee6b64ce
commit
70443895e4
3 files changed
+6
-3
No files matched your search
@@ -1495,10 +1495,12 @@
|
||||
const project = validContext ? (projectLink?.textContent || view.querySelector('.chat-area h1')?.textContent || projectContext.projectId) : '';
|
||||
const name = conversation?.querySelector('h1')?.textContent || '';
|
||||
const href = validContext ? '#/projects/' + encodeURIComponent(projectContext.projectId) : '';
|
||||
const signature = JSON.stringify([project || '', name, href]);
|
||||
const uuid = value => typeof value === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
||||
const threadHref = validContext && uuid(projectContext.thread) ? '#/projects/threads/' + encodeURIComponent(projectContext.thread) + (uuid(projectContext.session) ? '/sessions/' + encodeURIComponent(projectContext.session) : '') : '';
|
||||
const signature = JSON.stringify([project || '', name, href, threadHref]);
|
||||
if (context.dataset.signature !== signature) {
|
||||
context.dataset.signature = signature; context.replaceChildren();
|
||||
if (project && href) { const label = document.createElement('p'); label.className = 'tree-title'; label.textContent = 'Current project'; const link = document.createElement('a'); link.href = href; link.textContent = project; link.className = 'context-project'; context.append(label, link); if (name) { const title = document.createElement('p'); title.className = 'context-conversation'; title.textContent = name; context.append(title); } }
|
||||
if (project && href) { const label = document.createElement('p'); label.className = 'tree-title'; label.textContent = 'Current project'; const link = document.createElement('a'); link.href = href; link.textContent = project; link.className = 'context-project'; context.append(label, link); if (name) { const title = document.createElement(threadHref ? 'a' : 'p'); title.className = 'context-conversation'; title.textContent = name; if (threadHref) title.href = threadHref; context.append(title); } }
|
||||
}
|
||||
for (const a of view.querySelectorAll('a[href^="#/chat"]')) {
|
||||
const h = a.getAttribute('href');
|
||||
|
||||
@@ -218,7 +218,7 @@ body.on-bus #board-refused{display:none}
|
||||
}
|
||||
#project-context:not(:empty){border-bottom:1px solid var(--line);padding:0 4px 10px;overflow-wrap:anywhere}
|
||||
.context-project{display:block;min-height:var(--action-target);padding:10px 0;color:var(--action);font-weight:700}
|
||||
.context-conversation{margin:0;color:var(--strong);overflow-wrap:anywhere}
|
||||
.context-conversation{display:block;min-height:var(--action-target);padding:10px 0;margin:0;color:var(--strong);overflow-wrap:anywhere}
|
||||
#project-tree:not(:empty){border-bottom:1px solid var(--line);padding-bottom:10px}
|
||||
.project-archive-control,.project-archived-filter{border:1px solid var(--border);background:var(--surface);color:var(--text);padding:8px 12px}
|
||||
.project-archive-control:hover,.project-archived-filter:hover{background:var(--raised)}
|
||||
|
||||
@@ -18,6 +18,7 @@ test('integrated project settings and conversation mounts use authorized context
|
||||
await wait(`document.querySelector('.chat-conversation')?.dataset.session===${JSON.stringify(ids.session)}`);
|
||||
await wait('!!document.querySelector("[data-chat-files] .request-files") || document.querySelector("[data-chat-files]")?.textContent.includes("No")');
|
||||
assert.match(await b.evaluate('document.querySelector("#project-context").textContent'), /Active project.*Project conversation/s);
|
||||
assert.equal(await b.evaluate('document.querySelector("#project-context .context-conversation").getAttribute("href")'), route);
|
||||
await b.viewport(1440, 1000);
|
||||
await wait('document.querySelector("#processing-controls").parentElement.id === "console-nav"');
|
||||
assert.equal(await b.evaluate('document.querySelector("#processing-controls").parentElement.id'), 'console-nav');
|
||||
|
||||
Reference in new issue
Block a user