nuItem.setAttribute("data-conv-id", item.id);
      menuItem.addEventListener("command", this.#onRecentChatMenuitemClick);

      chatsHeader.insertAdjacentElement("afterend", menuItem);
    }
  }

  async #onRecentChatMenuitemClick(event) {
    const convId = event.target.getAttribute("data-conv-id");
    const conversation = await AIWindow.chatStore.findConversationById(convId);

    if (!conversation) {
      return;
    }

    newBrowserTabUrl += `#convId/${convId}`;

    const win = event.target.ownerGlobal;
    let newBrowserTabUrl = win.BROWSER_NEW_TAB_URL;
    const site = conversation.getMostRecentPageVisited();
    if (site) {
      newBrowserTabUrl += `#convId/${convId}/site/${site}`;
    }

    let where = lazy.BrowserUtils.whereToOpenLink(event);
    if (where === "current") {
      where = "tab";
    }

    lazy.URILoadingHelper.openTrustedLinkIn(win, newBrowserTabUrl, where);
  }
}
PK