Skip to content

Commit

Permalink
Pull request for app version 1.0.16 (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnguonly authored Aug 17, 2024
1 parent 5ef2b7c commit d8ace57
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
12 changes: 12 additions & 0 deletions __tests__/contentConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,16 @@ describe("getContentConfig", () => {
const config = getContentConfig(url, contentConfig);
expect(config?.chunkSize).toEqual(503);
});

test("should match subdomain", () => {
const url = new URL("https://sub.domain.com");
const config = getContentConfig(url, contentConfig);
expect(config?.chunkSize).toEqual(501);
});

test("should match sub subdomain", () => {
const url = new URL("https://sub.sub.domain.com");
const config = getContentConfig(url, contentConfig);
expect(config?.chunkSize).toEqual(501);
});
});
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.15",
"version": "1.0.16",
"manifest_version": 3,
"name": "Lumos",
"description": "An LLM co-pilot for browsing the web, powered by local LLMs. Your prompts never leave the browser.",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lumos",
"version": "1.0.15",
"version": "1.0.16",
"private": true,
"dependencies": {
"@chatscope/chat-ui-kit-react": "^1.10.1",
Expand Down
27 changes: 25 additions & 2 deletions src/components/ChatBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { ChangeEvent, useEffect, useRef, useState } from "react";
import {
ChangeEvent,
ClipboardEvent,
useEffect,
useRef,
useState,
} from "react";

import {
Avatar,
Expand Down Expand Up @@ -440,7 +446,9 @@ const ChatBar: React.FC = () => {
case "c":
// copy last message
if (messages.length === 0) return;
navigator.clipboard.writeText(messages[messages.length - 1].message);
navigator.clipboard.writeText(
messages[messages.length - 1].message.trim(),
);
setShowSnackbar(true);
setSnackbarMessage("Copied!");
break;
Expand Down Expand Up @@ -474,6 +482,20 @@ const ChatBar: React.FC = () => {
}
};

/**
* This function is needed to prevent HTML elements (e.g. background color)
* from being copied to the clipboard. Only plain text should be copied to
* the clipboard.
*/
const handleMessageOnCopy = (event: ClipboardEvent<HTMLDivElement>) => {
event.preventDefault();

const selectedText = window.getSelection()?.toString() || "";
if (selectedText !== "") {
navigator.clipboard.writeText(selectedText);
}
};

const appendNonUserMessage = (
currentMessages: LumosMessage[],
sender: string,
Expand Down Expand Up @@ -685,6 +707,7 @@ const ChatBar: React.FC = () => {
}}
type="custom"
style={messageStyle}
onCopy={handleMessageOnCopy}
>
<Avatar
src={
Expand Down
4 changes: 3 additions & 1 deletion src/contentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export const getContentConfig = (
selectors: string[];
selectorsAll: string[];
} => {
const searchPath = `${url.hostname}${url.pathname}`;
const domainParts = url.hostname.split(".");
const topLevelDomain = `${domainParts[domainParts.length - 2]}.${domainParts[domainParts.length - 1]}`;
const searchPath = `${topLevelDomain}${url.pathname}`;

// Order keys (paths) of contentConfig in reverse order and check if any
// key is a substring of searchPath. This will find the longest matching
Expand Down

0 comments on commit d8ace57

Please sign in to comment.