mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 07:03:25 +00:00
Fix new session button and improve navigation message styling
- Add ?new=true query param to prevent auto-loading latest session - Style navigation message as clickable badge with background - Add cursor-pointer, truncate, and max-width for proper text overflow - Click navigation message to open page in new tab - Show URL on hover
This commit is contained in:
parent
c9be21ebad
commit
2d68594711
2 changed files with 19 additions and 10 deletions
|
|
@ -28,13 +28,21 @@ declare module "@mariozechner/pi-web-ui" {
|
||||||
const navigationRenderer: MessageRenderer<NavigationMessage> = {
|
const navigationRenderer: MessageRenderer<NavigationMessage> = {
|
||||||
render: (nav) => {
|
render: (nav) => {
|
||||||
return html`
|
return html`
|
||||||
<div class="flex items-center gap-2 px-4 py-2 text-sm text-muted-foreground">
|
<div class="mx-4">
|
||||||
${
|
<button
|
||||||
nav.favicon
|
class="inline-flex items-center gap-2 px-2 py-1 text-sm text-muted-foreground bg-secondary border border-border rounded-lg hover:bg-secondary/80 transition-colors max-w-full cursor-pointer"
|
||||||
? html`<img src="${nav.favicon}" alt="" class="w-4 h-4 flex-shrink-0" />`
|
@click=${() => {
|
||||||
: html`<div class="w-4 h-4 flex-shrink-0 bg-muted rounded"></div>`
|
chrome.tabs.create({ url: nav.url });
|
||||||
}
|
}}
|
||||||
<span class="truncate">${nav.title}</span>
|
title="Click to open: ${nav.url}"
|
||||||
|
>
|
||||||
|
${
|
||||||
|
nav.favicon
|
||||||
|
? html`<img src="${nav.favicon}" alt="" class="w-4 h-4 flex-shrink-0" />`
|
||||||
|
: html`<div class="w-4 h-4 flex-shrink-0 bg-muted rounded"></div>`
|
||||||
|
}
|
||||||
|
<span class="truncate">${nav.title}</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ const loadSession = (sessionId: string) => {
|
||||||
|
|
||||||
const newSession = () => {
|
const newSession = () => {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.search = "";
|
url.search = "?new=true";
|
||||||
window.location.href = url.toString();
|
window.location.href = url.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -340,9 +340,10 @@ async function initApp() {
|
||||||
// Check for session in URL
|
// Check for session in URL
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
let sessionIdFromUrl = urlParams.get("session");
|
let sessionIdFromUrl = urlParams.get("session");
|
||||||
|
const isNewSession = urlParams.get("new") === "true";
|
||||||
|
|
||||||
// If no session in URL, try to load the most recent session
|
// If no session in URL and not explicitly creating new, try to load the most recent session
|
||||||
if (!sessionIdFromUrl && storage.sessions) {
|
if (!sessionIdFromUrl && !isNewSession && storage.sessions) {
|
||||||
const latestSessionId = await storage.sessions.getLatestSessionId();
|
const latestSessionId = await storage.sessions.getLatestSessionId();
|
||||||
if (latestSessionId) {
|
if (latestSessionId) {
|
||||||
sessionIdFromUrl = latestSessionId;
|
sessionIdFromUrl = latestSessionId;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue