Skip to content

Commit 5818b83

Browse files
chatbox offset display + chatbox header select css fix
1 parent 8a4aff6 commit 5818b83

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scribe-pal",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "ScribePal is an intelligent browser extension that leverages AI to empower your web experience.",
55
"author": "Code Forge Temple",
66
"type": "module",

src/tab/components/ChatBox/ChatBox.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ const ROLE = {
4545
ASSISTANT: "assistant"
4646
} as const;
4747

48-
type ChatBoxProps = ChatBoxIds & { onRemove: () => void };
48+
type ChatBoxProps = ChatBoxIds & {
49+
onRemove: () => void;
50+
coordsOffset: number;
51+
};
4952

50-
export const ChatBox = withShadowStyles(({tabId, chatBoxId, onRemove}: ChatBoxProps) => {
53+
export const ChatBox = withShadowStyles(({tabId, chatBoxId, onRemove, coordsOffset}: ChatBoxProps) => {
5154
const boxRef = useRef<HTMLDivElement>(null);
5255
const [isVisible, setIsVisible] = useState(false);
53-
const [position, setPosition, handleDrag] = useDraggablePosition({tabId, chatBoxId}, {left: "calc(100% - 600px)", top: "210px"});
56+
const [position, setPosition, handleDrag] = useDraggablePosition(
57+
{tabId, chatBoxId},
58+
{
59+
left: `calc(100% - 600px - ${30 * coordsOffset}px)`,
60+
top: `calc(210px + ${30 * coordsOffset}px)`
61+
});
5462
const [message, setMessage] = usePersistentState<string>("chatBoxMessage", "", {tabId, chatBoxId});
5563
const {chatLog, setChatLog} = useChatLog({tabId, chatBoxId});
5664
const [selectedModel, setSelectedModel] = usePersistentState<string>("chatBoxSelectedModel", "", {tabId, chatBoxId});

src/tab/components/ChatBox/components/ChatHeader/ChatHeader.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
cursor: pointer;
1919
padding: 0 5px 0 5px;
2020
width: auto;
21+
max-width: 150px;
22+
overflow: hidden;
23+
text-overflow: ellipsis;
24+
white-space: nowrap;
2125

2226
option {
2327
color: black;

src/tab/features/chat/actions/showChat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {ChatBox} from "../../../components/ChatBox";
1111
import {ShadowContext}from "../../../contexts/ShadowContext";
1212
import {App} from "../../../components/App";
1313

14-
export function showChat (tabId: number, chatBoxId: string): void {
14+
export function showChat (tabId: number, chatBoxId: string, coordsOffset: number): void {
1515

1616
const host = document.createElement("div");
1717
const shadow = host.attachShadow({mode: "closed"});
@@ -36,7 +36,7 @@ export function showChat (tabId: number, chatBoxId: string): void {
3636
root.render(
3737
<ShadowContext.Provider value={shadow}>
3838
<App>
39-
<ChatBox chatBoxId={chatBoxId} tabId={tabId} onRemove={handleRemove} />
39+
<ChatBox chatBoxId={chatBoxId} tabId={tabId} onRemove={handleRemove} coordsOffset={coordsOffset} />
4040
</App>
4141
</ShadowContext.Provider>
4242
);

src/tab/serviceWorker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,33 +208,33 @@ const actionShowChat = async () => {
208208

209209
if (!tabId) return;
210210

211-
if (await isScriptInjected(tabId)) {
212-
await showChat(tabId, chatBoxId);
213-
} else {
211+
if (!(await isScriptInjected(tabId))) {
214212
await polyfillScriptingExecuteScript({
215213
target: {tabId},
216214
files: ["injectedScript.js"],
217215
});
218-
219-
await showChat(tabId, chatBoxId);
220216
}
217+
218+
await showChat(tabId, chatBoxId);
221219
}
222220

223221
const showChat = async (tabId: number, chatBoxId: string) => {
224222
const chatIsShown = await isChatShown(tabId, chatBoxId);
223+
const tabStorage = await getTabStorage(tabId);
224+
const chatBoxesCount = Object.keys(tabStorage.chatBoxes).length;
225225

226226
if (!chatIsShown) {
227227
await polyfillScriptingExecuteScript({
228228
target: {tabId},
229-
func: (extensionName: string, tabId: number, chatBoxId: string) => {
229+
func: (extensionName: string, tabId: number, chatBoxId: string, chatBoxesCount: number) => {
230230
const extensionNamespace = (window as any)[extensionName];
231231

232-
extensionNamespace.showChat(tabId, chatBoxId);
232+
extensionNamespace.showChat(tabId, chatBoxId, chatBoxesCount);
233233

234234
extensionNamespace.shownChatBoxes[chatBoxId] = true;
235235

236236
},
237-
args: [EXTENSION_NAME, tabId, chatBoxId],
237+
args: [EXTENSION_NAME, tabId, chatBoxId, chatBoxesCount],
238238
});
239239
}
240240
}

0 commit comments

Comments
 (0)