Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
e2b9b37
settings for context and page groups
sid597 Aug 8, 2025
da54c72
node settings
sid597 Aug 9, 2025
f83a007
address review
sid597 Aug 10, 2025
ee58296
fix node creation if it does not exist
sid597 Aug 10, 2025
87f38d3
remove unused, refactor
sid597 Aug 10, 2025
5a6bfdd
address coderabbit review
sid597 Aug 10, 2025
9815656
unify spelling, handle fallback
sid597 Aug 11, 2025
b50cd2e
first working but not good solution
sid597 Aug 14, 2025
b8fce33
working better code need to self review, use --full instead of --large
sid597 Aug 14, 2025
622de13
seems good, will find after review what i missed
sid597 Aug 16, 2025
f7143d1
fix highlighting, fix button highlight
sid597 Aug 16, 2025
37aa7e0
sync
sid597 Aug 17, 2025
4f2807b
address coderabbit code
sid597 Aug 17, 2025
3e430c9
address lint errors
sid597 Aug 19, 2025
0425eee
use async instead of backend
sid597 Aug 19, 2025
5622c64
address review
sid597 Aug 21, 2025
2a177c5
Merge branch 'main' into eng-733-glue-ui-components-to-data-extractio…
sid597 Aug 21, 2025
5ce74d5
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Aug 21, 2025
590848c
address review
sid597 Aug 21, 2025
e3f7352
bug fixes
sid597 Aug 22, 2025
0f2938f
bug fixes
sid597 Aug 22, 2025
36fc757
Merge branch 'eng-733-glue-ui-components-to-data-extraction-and-datab…
sid597 Aug 22, 2025
4422b0a
unused import
sid597 Aug 22, 2025
ec8109d
Add an input type for platform accounts
maparent Aug 23, 2025
bdb0180
Add an input type for platform accounts
maparent Aug 23, 2025
474dccc
Merge branch 'main' into eng-733-glue-ui-components-to-data-extractio…
sid597 Aug 23, 2025
aa573c8
Merge branch 'eng-764-bulk-account-uploading' of https://github.com/D…
sid597 Aug 23, 2025
c6a806d
Merge branch 'eng-764-bulk-account-uploading' into eng-733-glue-ui-co…
sid597 Aug 23, 2025
18a0d92
Add an input type for platform accounts
maparent Aug 23, 2025
cba3232
Merge branch 'eng-764-bulk-account-uploading' of https://github.com/D…
sid597 Aug 23, 2025
4b7cf9b
Merge branch 'eng-764-bulk-account-uploading' into eng-733-glue-ui-co…
sid597 Aug 23, 2025
a0ea409
bulk upsert accounts, use database function imports
sid597 Aug 24, 2025
6efd37c
Merge branch 'main' into eng-733-glue-ui-components-to-data-extractio…
sid597 Aug 24, 2025
29e8151
add comment for future
sid597 Aug 24, 2025
a11142a
use better import method
sid597 Aug 24, 2025
814149b
Merge branch 'eng-733-glue-ui-components-to-data-extraction-and-datab…
sid597 Aug 24, 2025
92f28d6
commonjs-to-esm
sid597 Aug 24, 2025
d8837f0
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Aug 24, 2025
3e0ae6f
fix merge errors, fix tree config setting extraction, test functional…
sid597 Aug 24, 2025
0f56967
add progress toaster, use space existence condition for on load sync
sid597 Aug 24, 2025
99c1ae5
defaultvalue
sid597 Aug 24, 2025
d045b21
address review, leaving out update embeddings from here
sid597 Aug 28, 2025
209da92
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Aug 28, 2025
89e4b3b
Merge branch 'main' into eng-732-left-side-panel-for-suggestive-mode
sid597 Aug 28, 2025
6406595
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Aug 29, 2025
3e142de
update embeddings
sid597 Aug 29, 2025
9c6dc0e
Merge branch 'eng-709-settings-panel-for-suggestive-mode' into eng-73…
sid597 Aug 29, 2025
3905290
Merge branch 'main' into eng-732-left-side-panel-for-suggestive-mode
sid597 Aug 29, 2025
ffa0122
seperate
sid597 Aug 30, 2025
a0e191a
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Aug 31, 2025
e1b6a58
Merge branch 'eng-709-settings-panel-for-suggestive-mode' into eng-73…
sid597 Aug 31, 2025
70de753
remove initialisation from wrong place
sid597 Aug 31, 2025
e9fc56a
panel manager
sid597 Aug 31, 2025
ac9636a
individual suggestive panel body
sid597 Aug 31, 2025
9a4294e
individual suggestive panel body
sid597 Aug 31, 2025
7947ae9
right data extraction
sid597 Aug 31, 2025
835a398
remove unused
sid597 Aug 31, 2025
824d117
observer to carry over different pages
sid597 Aug 31, 2025
48d9a86
set all pages
sid597 Aug 31, 2025
569df7a
ENG-818: Declare dbDotEnv as mjs explicitly
maparent Sep 1, 2025
d6ff391
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Sep 1, 2025
f65a5c1
Merge branch 'eng-818-make-dbdotenv-explicitly-a-module' into eng-709…
sid597 Sep 1, 2025
b130596
Merge branch 'main' into eng-732-left-side-panel-for-suggestive-mode
sid597 Sep 7, 2025
37cb5a2
address review partially
sid597 Sep 8, 2025
58d119b
Merge branch 'main' into eng-709-settings-panel-for-suggestive-mode
sid597 Sep 8, 2025
319ea90
Merge branch 'eng-709-settings-panel-for-suggestive-mode' into eng-73…
sid597 Sep 8, 2025
246226c
address reviews
sid597 Sep 8, 2025
9c955c5
Merge branch 'main' into eng-732-left-side-panel-for-suggestive-mode
sid597 Sep 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
panel manager
  • Loading branch information
sid597 committed Aug 31, 2025
commit e9fc56a37eb2b50fbd9bb8733c77a2c994de6f07
51 changes: 51 additions & 0 deletions apps/roam/src/components/PanelManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ type PanelState = {
onloadArgs: OnloadArgs;
};

const panelSubscribers = new Map<string, Set<(isOpen: boolean) => void>>();

const notifySubscribers = (tag: string, isOpen: boolean) => {
const subscribers = panelSubscribers.get(tag);
if (subscribers) {
subscribers.forEach((callback) => callback(isOpen));
}
};

export const subscribeToPanelState = (
tag: string,
callback: (isOpen: boolean) => void,
) => {
if (!panelSubscribers.has(tag)) {
panelSubscribers.set(tag, new Set());
}
panelSubscribers.get(tag)!.add(callback);

callback(openPanels.has(tag));

return () => {
const subscribers = panelSubscribers.get(tag);
if (subscribers) {
subscribers.delete(callback);
if (subscribers.size === 0) {
panelSubscribers.delete(tag);
}
}
};
};

const getSpacingClass = (element: HTMLElement): string | null => {
for (const className of Array.from(element.classList)) {
if (className.startsWith(SPACING_PREFIX)) return className;
Expand Down Expand Up @@ -401,6 +432,21 @@ export const panelManager = {
return;
}
}
const grabFromReferencedPages = onloadArgs.extensionAPI.settings.get(
"context-grab-from-referenced-pages",
);
const shouldGrabFromReferencedPages =
grabFromReferencedPages === null
? true
: Boolean(grabFromReferencedPages);

const grabParentChildContext = onloadArgs.extensionAPI.settings.get(
"context-grab-parent-child-context",
);
const shouldGrabParentChildContext =
grabParentChildContext === null
? true
: Boolean(grabParentChildContext);

const panelElement = document.createElement("div");
panelElement.id = `discourse-panel-${tag.replace(/[^a-zA-Z0-9]/g, "-")}`;
Expand All @@ -417,13 +463,16 @@ export const panelManager = {

openPanels.set(tag, { blockUid, element: panelElement, onloadArgs });
updateOverlayToggleButtons(tag, true);
notifySubscribers(tag, true);

ReactDOM.render(
<ExtensionApiContextProvider {...onloadArgs}>
<DiscourseSuggestionsPanel
tag={tag}
blockUid={blockUid}
onClose={() => panelManager.removePanel(tag)}
shouldGrabFromReferencedPages={shouldGrabFromReferencedPages}
shouldGrabParentChildContext={shouldGrabParentChildContext}
/>
</ExtensionApiContextProvider>,
panelElement,
Expand All @@ -444,6 +493,7 @@ export const panelManager = {
openPanels.delete(tag);
updateOverlayToggleButtons(tag, false);
clearBlockHighlight(blockUid);
notifySubscribers(tag, false);

if (openPanels.size === 0) {
cleanupPanelInfrastructure();
Expand All @@ -462,6 +512,7 @@ export const panelManager = {
entries.forEach(([t, state]) => {
updateOverlayToggleButtons(t, false);
clearBlockHighlight(state.blockUid);
notifySubscribers(t, false);
});
} catch (error) {
console.error("Failed to close all panels:", error);
Expand Down
14 changes: 8 additions & 6 deletions apps/roam/src/components/SuggestiveModeOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Button, Tooltip } from "@blueprintjs/core";
import React, { useCallback, useMemo, useState } from "react";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import ReactDOM from "react-dom";
import useInViewport from "react-in-viewport/dist/es/lib/useInViewport";
import { OnloadArgs } from "roamjs-components/types/native";
import { getBlockUidFromTarget } from "roamjs-components/dom";
import { panelManager } from "./PanelManager";
import { panelManager, subscribeToPanelState } from "./PanelManager";
import ExtensionApiContextProvider from "roamjs-components/components/ExtensionApiContext";

const SuggestiveModeOverlay = ({
Expand All @@ -21,6 +21,10 @@ const SuggestiveModeOverlay = ({
const [isPanelOpen, setIsPanelOpen] = useState(() =>
panelManager.isOpen(tag),
);
useEffect(() => {
const unsubscribe = subscribeToPanelState(tag, setIsPanelOpen);
return unsubscribe;
}, [tag]);

const toggleHighlight = useCallback(
(on: boolean) => {
Expand All @@ -46,13 +50,12 @@ const SuggestiveModeOverlay = ({
e.preventDefault();
toggleHighlight(false);
panelManager.toggle({ tag, blockUid, onloadArgs });
setIsPanelOpen(panelManager.isOpen(tag));
},
[tag, blockUid, onloadArgs, toggleHighlight],
);

return (
<div className="suggestive-mode-overlay flex max-w-3xl items-center gap-1.5">
<div className="suggestive-mode-overlay flex max-w-3xl">
<Tooltip
content={
isPanelOpen ? "Close suggestions panel" : "Open suggestions panel"
Expand All @@ -62,15 +65,14 @@ const SuggestiveModeOverlay = ({
<Button
data-dg-role="panel-toggle"
data-dg-tag={tag}
data-dg-panel-open={isPanelOpen ? "true" : "false"}
data-dg-block-uid={blockUid}
icon={isPanelOpen ? "panel-table" : "panel-stats"}
minimal
small
intent={isPanelOpen ? "primary" : "none"}
onClick={handleTogglePanel}
onMouseEnter={() => toggleHighlight(true)}
onMouseLeave={() => toggleHighlight(false)}
{...{ "data-dg-block-uid": blockUid }}
/>
</Tooltip>
</div>
Expand Down