Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] AI/LLM integration #1325

Draft
wants to merge 138 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
e09e15a
start from scratch again
perfectra1n Mar 3, 2025
f2a6f92
hey look, it doesn't crash again
perfectra1n Mar 3, 2025
9f84a84
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 8, 2025
b248a7a
create embedding services
perfectra1n Mar 8, 2025
b97c8dd
set up DB migrations
perfectra1n Mar 8, 2025
1ff5bc6
set up embedding providers here?
perfectra1n Mar 8, 2025
c442943
add additional AI / LLM options and translations
perfectra1n Mar 8, 2025
1361e4d
set up embedding API endpoints
perfectra1n Mar 8, 2025
ea6f9c8
initialize embeddings if option is enabled
perfectra1n Mar 8, 2025
d3013c9
add additional options for ollama embeddings
perfectra1n Mar 8, 2025
553f7dd
fix the Ollama embedding model setting option breaking
perfectra1n Mar 8, 2025
dc439b2
update schema with our new tables
perfectra1n Mar 8, 2025
6ace4d5
nearly able to process embeddings
perfectra1n Mar 8, 2025
0daa9e7
I can create embeddings now?
perfectra1n Mar 8, 2025
0cd1be5
Show embedding generation stats to user
perfectra1n Mar 8, 2025
1ca98e2
update embedding stats every 5s for user
perfectra1n Mar 8, 2025
51c83bb
show fancier stats
perfectra1n Mar 8, 2025
19bf741
fancier embedding process stats
perfectra1n Mar 8, 2025
7e232d1
Create better relationships between notes, sanitize ridiculous spacin…
perfectra1n Mar 8, 2025
733fdcf
update relationship weights
perfectra1n Mar 8, 2025
adaac46
I'm 100% going to have to destroy this commit later
perfectra1n Mar 9, 2025
cf0e924
try a context approach
perfectra1n Mar 10, 2025
ef6ecdc
it errors, but works
perfectra1n Mar 10, 2025
c1585c7
actually shows useful responses now
perfectra1n Mar 10, 2025
75e18e4
Make the sources section fancier
perfectra1n Mar 10, 2025
bd97d97
this is pretty close to opening a new tab?
perfectra1n Mar 10, 2025
08626c7
when a user clicks on a source, don't swap focus
perfectra1n Mar 10, 2025
c386e34
Update the chat panel theme some
perfectra1n Mar 10, 2025
f482b3b
do a better job of extracting context
perfectra1n Mar 10, 2025
9834e77
fix context logic
perfectra1n Mar 10, 2025
ecc183f
almost completely styled codeblocks in response
perfectra1n Mar 10, 2025
d713f38
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 10, 2025
d2dc401
add these options as configurable
perfectra1n Mar 11, 2025
d413e60
update checkbox options in settings and update translations
perfectra1n Mar 11, 2025
ff679b0
move providers to their own folder
perfectra1n Mar 11, 2025
56fc720
undo accidental MAX_ALLOWED_FILE_SIZE_MB change
perfectra1n Mar 11, 2025
4160db9
fancier (but longer waiting time) messages
perfectra1n Mar 11, 2025
0985cec
implement chunking and use becca for some functionality
perfectra1n Mar 11, 2025
71b3b04
break up the huge context_extractor into smaller files
perfectra1n Mar 11, 2025
f47b070
I think this works to handle failed embeddings
perfectra1n Mar 11, 2025
1f661e4
make sure to not retry chunks if they fail or something else
perfectra1n Mar 11, 2025
6ce3f1c
better note names to LLM?
perfectra1n Mar 11, 2025
0d2858c
upgrade chunking
perfectra1n Mar 11, 2025
3f37196
add additional options for users
perfectra1n Mar 11, 2025
730d123
create llm index service
perfectra1n Mar 11, 2025
fc55995
allow users to manually request index to be rebuilt
perfectra1n Mar 11, 2025
72b1426
break up large vector_store into smaller files
perfectra1n Mar 12, 2025
eaa947e
"rebuild index" functionality for users
perfectra1n Mar 12, 2025
fcba151
allow for manual index rebuild, and ONLY rebuild the index
perfectra1n Mar 12, 2025
e5afbc6
better manage chunking errors
perfectra1n Mar 12, 2025
46a6533
update chunking management
perfectra1n Mar 12, 2025
73445d9
move chunking to its own folder
perfectra1n Mar 12, 2025
3fee82e
rename files with the same name
perfectra1n Mar 12, 2025
b6df3a7
allow user to select *where* they want to generate embeddings
perfectra1n Mar 12, 2025
a930b79
synchronize embeddings
perfectra1n Mar 12, 2025
39d265a
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 12, 2025
c914aaa
do a better job of handling failed note embeddings
perfectra1n Mar 12, 2025
ee7b228
correctly style the failed embeddings section
perfectra1n Mar 12, 2025
d4cfc65
yes, now the failed embeddings section at least looks passable
perfectra1n Mar 12, 2025
8d7e5c8
fix the maths for stats
perfectra1n Mar 12, 2025
67766e3
create note_embedding object for becca
perfectra1n Mar 12, 2025
6bb4bbb
specially handle Buffer objects into Base64 and back for Becca
perfectra1n Mar 12, 2025
4796c24
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 12, 2025
f8d4088
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 13, 2025
c556989
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 15, 2025
572a03a
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 16, 2025
697d348
set up more reasonable context window and dimension sizes
perfectra1n Mar 16, 2025
c315b32
wait for DB init even to emit before starting LLM services
perfectra1n Mar 16, 2025
d8c9d3b
move these settings between db migrations
perfectra1n Mar 16, 2025
0081e6f
fix sql error and add missing options
perfectra1n Mar 16, 2025
781a250
fix embeddings w/ cls.init()
perfectra1n Mar 16, 2025
d2072c2
"lock" notes that are having their embeddings created
perfectra1n Mar 16, 2025
ab3c6b6
remove options from migrations files
perfectra1n Mar 16, 2025
cc85b9a
fix autoupdate name inconsistency
perfectra1n Mar 16, 2025
7b643a7
fix(llm): duplicate launch bar config
eliandoran Mar 16, 2025
d716713
refactor(llm): use dedicated widget for llm chat button
eliandoran Mar 16, 2025
5d0be30
feat(llm): show/hide LLM button based on setting
eliandoran Mar 16, 2025
1dafa65
fix(settings/llm): extra separators
eliandoran Mar 16, 2025
2853b8e
feat(options/llm): use tabs for provider configuration
eliandoran Mar 17, 2025
36a6d75
feat(options/llm): group into sections
eliandoran Mar 17, 2025
5a6d271
feat(options/llm): improve checkboxes
eliandoran Mar 17, 2025
e6cb06b
feat(options/llm): use form text style
eliandoran Mar 17, 2025
1efc923
feat(options/llm): use columns and separators
eliandoran Mar 17, 2025
fa99624
feat(options/llm): move stats at the top
eliandoran Mar 17, 2025
0ea7e10
feat(options/llm): improve style of tabs
eliandoran Mar 17, 2025
1844ad7
fix the isEnabled function
perfectra1n Mar 17, 2025
fe1faf7
show user at the top of settings if there are issues
perfectra1n Mar 17, 2025
79514b8
also add the errors to the top of the chat window
perfectra1n Mar 17, 2025
8d8c34c
fancier LLM/AI chat errors
perfectra1n Mar 17, 2025
5aef80f
fix openai endpoints
perfectra1n Mar 17, 2025
6d146c2
try ollama first, always
perfectra1n Mar 17, 2025
d95fd0b
allow specifying openai embedding models too
perfectra1n Mar 17, 2025
4a4eac6
Allow users to specify OpenAI embedding and chat models
perfectra1n Mar 17, 2025
c40c702
add anthropic options as well
perfectra1n Mar 17, 2025
14acd1c
improve LLM response parsing
perfectra1n Mar 17, 2025
7ee6cf6
add additional options and provider sorting
perfectra1n Mar 17, 2025
37f1dcd
add ability to fetch available models from openai
perfectra1n Mar 17, 2025
3268c43
improve embedding precedence
perfectra1n Mar 17, 2025
ebc5107
add missing options
perfectra1n Mar 17, 2025
43cf33c
make the AI settings even fancier to setting precedence
perfectra1n Mar 17, 2025
ac40fff
draggable options for LLM provider too
perfectra1n Mar 17, 2025
5ad730c
openai finally works, respect embedding precedence
perfectra1n Mar 17, 2025
84a8473
adapt or regenerate embeddings - allows users to decide
perfectra1n Mar 17, 2025
558f6a9
add translations
perfectra1n Mar 17, 2025
c372011
add Voyage AI as Embedding provider
perfectra1n Mar 17, 2025
08f7f19
do a better job with similarity searches
perfectra1n Mar 18, 2025
f05fe3f
set up embedding normalization
perfectra1n Mar 18, 2025
8129f8f
oh my goodness, saving these settings finally works
perfectra1n Mar 18, 2025
1a8ce96
stop the log spam
perfectra1n Mar 18, 2025
f6afb1d
set up agentic thinking
perfectra1n Mar 19, 2025
492c05b
clean up silly chat_widget that was in the wrong place
perfectra1n Mar 19, 2025
352204b
add agentic thinking to chat
perfectra1n Mar 19, 2025
db4dd6d
refactor "context" services
perfectra1n Mar 19, 2025
466b749
yeet deprecated function
perfectra1n Mar 19, 2025
d5efcfe
fix chat_service imports
perfectra1n Mar 19, 2025
2348096
get rid of this unused file too
perfectra1n Mar 19, 2025
024b063
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 19, 2025
5b81252
fix translation
perfectra1n Mar 19, 2025
0d4b6a7
update agent tools
perfectra1n Mar 19, 2025
90db570
agent tools do something now
perfectra1n Mar 19, 2025
4ff3c5a
agentic thinking really works now 🗿
perfectra1n Mar 19, 2025
e566692
centralize all prompts
perfectra1n Mar 20, 2025
eb1ef36
move the llm_prompt_constants to its own folder
perfectra1n Mar 20, 2025
273dff2
create a better base system prompt
perfectra1n Mar 20, 2025
9c1ab4f
add to base prompt
perfectra1n Mar 20, 2025
1be70f1
do a better job of building the context
perfectra1n Mar 20, 2025
915c95f
more aggressively filter notes out that don't work for us
perfectra1n Mar 20, 2025
c9728e7
also extract Note relationships and send as context
perfectra1n Mar 20, 2025
34940b5
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 20, 2025
3d70a6c
appropriately show if there are any notes still in the queue
perfectra1n Mar 20, 2025
0707266
reset embedding_queue where objects are "isprocessing"
perfectra1n Mar 20, 2025
b6c0bd3
give tool calling another shot
perfectra1n Mar 21, 2025
83e75f7
fix linter errors
perfectra1n Mar 21, 2025
72a77a3
saving of provider settings works
perfectra1n Mar 21, 2025
0169ab7
fix referencing wrong tables
perfectra1n Mar 21, 2025
bbfe5f8
this is close to how I want the settings to work...
perfectra1n Mar 22, 2025
7146c89
display errors for LLM settings in LLM settings works
perfectra1n Mar 22, 2025
7c5a1f2
Merge branch 'develop' into ai-llm-integration
perfectra1n Mar 24, 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
46 changes: 46 additions & 0 deletions db/migrations/0229__vector_embeddings.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- Add tables for vector embeddings storage and management
-- This migration adds embedding support to the main document.db database

-- Store embeddings for notes
CREATE TABLE IF NOT EXISTS "note_embeddings" (
"embedId" TEXT NOT NULL PRIMARY KEY,
"noteId" TEXT NOT NULL,
"providerId" TEXT NOT NULL,
"modelId" TEXT NOT NULL,
"dimension" INTEGER NOT NULL,
"embedding" BLOB NOT NULL,
"version" INTEGER NOT NULL DEFAULT 1,
"dateCreated" TEXT NOT NULL,
"utcDateCreated" TEXT NOT NULL,
"dateModified" TEXT NOT NULL,
"utcDateModified" TEXT NOT NULL
);

CREATE INDEX "IDX_note_embeddings_noteId" ON "note_embeddings" ("noteId");
CREATE INDEX "IDX_note_embeddings_providerId_modelId" ON "note_embeddings" ("providerId", "modelId");

-- Table to track which notes need embedding updates
CREATE TABLE IF NOT EXISTS "embedding_queue" (
"noteId" TEXT NOT NULL PRIMARY KEY,
"operation" TEXT NOT NULL, -- CREATE, UPDATE, DELETE
"dateQueued" TEXT NOT NULL,
"utcDateQueued" TEXT NOT NULL,
"priority" INTEGER NOT NULL DEFAULT 0,
"attempts" INTEGER NOT NULL DEFAULT 0,
"lastAttempt" TEXT NULL,
"error" TEXT NULL,
"failed" INTEGER NOT NULL DEFAULT 0,
"isProcessing" INTEGER NOT NULL DEFAULT 0
);

-- Table to store embedding provider configurations
CREATE TABLE IF NOT EXISTS "embedding_providers" (
"providerId" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"priority" INTEGER NOT NULL DEFAULT 0,
"config" TEXT NOT NULL, -- JSON config object
"dateCreated" TEXT NOT NULL,
"utcDateCreated" TEXT NOT NULL,
"dateModified" TEXT NOT NULL,
"utcDateModified" TEXT NOT NULL
);
42 changes: 42 additions & 0 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,45 @@ CREATE INDEX IDX_attachments_ownerId_role
CREATE INDEX IDX_notes_blobId on notes (blobId);
CREATE INDEX IDX_revisions_blobId on revisions (blobId);
CREATE INDEX IDX_attachments_blobId on attachments (blobId);

CREATE TABLE IF NOT EXISTS "note_embeddings" (
"embedId" TEXT NOT NULL PRIMARY KEY,
"noteId" TEXT NOT NULL,
"providerId" TEXT NOT NULL,
"modelId" TEXT NOT NULL,
"dimension" INTEGER NOT NULL,
"embedding" BLOB NOT NULL,
"version" INTEGER NOT NULL DEFAULT 1,
"dateCreated" TEXT NOT NULL,
"utcDateCreated" TEXT NOT NULL,
"dateModified" TEXT NOT NULL,
"utcDateModified" TEXT NOT NULL
);

CREATE INDEX "IDX_note_embeddings_noteId" ON "note_embeddings" ("noteId");
CREATE INDEX "IDX_note_embeddings_providerId_modelId" ON "note_embeddings" ("providerId", "modelId");

CREATE TABLE IF NOT EXISTS "embedding_queue" (
"noteId" TEXT NOT NULL PRIMARY KEY,
"operation" TEXT NOT NULL,
"dateQueued" TEXT NOT NULL,
"utcDateQueued" TEXT NOT NULL,
"priority" INTEGER NOT NULL DEFAULT 0,
"attempts" INTEGER NOT NULL DEFAULT 0,
"lastAttempt" TEXT NULL,
"error" TEXT NULL,
"failed" INTEGER NOT NULL DEFAULT 0,
"isProcessing" INTEGER NOT NULL DEFAULT 0
);

CREATE TABLE IF NOT EXISTS "embedding_providers" (
"providerId" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"isEnabled" INTEGER NOT NULL DEFAULT 0,
"priority" INTEGER NOT NULL DEFAULT 0,
"config" TEXT NOT NULL,
"dateCreated" TEXT NOT NULL,
"utcDateCreated" TEXT NOT NULL,
"dateModified" TEXT NOT NULL,
"utcDateModified" TEXT NOT NULL
);
38 changes: 38 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import error_handlers from "./routes/error_handlers.js";
import { startScheduledCleanup } from "./services/erase.js";
import sql_init from "./services/sql_init.js";
import { t } from "i18next";
import eventService from "./services/events.js";
import log from "./services/log.js";

await import("./services/handlers.js");
await import("./becca/becca_loader.js");
Expand All @@ -26,6 +28,42 @@ const scriptDir = dirname(fileURLToPath(import.meta.url));
// Initialize DB
sql_init.initializeDb();

// Listen for database initialization event
eventService.subscribe(eventService.DB_INITIALIZED, async () => {
try {
log.info("Database initialized, setting up LLM features");

// Initialize embedding providers
const { initializeEmbeddings } = await import("./services/llm/embeddings/init.js");
await initializeEmbeddings();

// Initialize the index service for LLM functionality
const { default: indexService } = await import("./services/llm/index_service.js");
await indexService.initialize().catch(e => console.error("Failed to initialize index service:", e));

log.info("LLM features initialized successfully");
} catch (error) {
console.error("Error initializing LLM features:", error);
}
});

// Initialize LLM features only if database is already initialized
if (sql_init.isDbInitialized()) {
try {
// Initialize embedding providers
const { initializeEmbeddings } = await import("./services/llm/embeddings/init.js");
await initializeEmbeddings();

// Initialize the index service for LLM functionality
const { default: indexService } = await import("./services/llm/index_service.js");
await indexService.initialize().catch(e => console.error("Failed to initialize index service:", e));
} catch (error) {
console.error("Error initializing LLM features:", error);
}
} else {
console.log("Database not initialized yet. LLM features will be initialized after setup.");
}

// view engine setup
app.set("views", path.join(scriptDir, "views"));
app.set("view engine", "ejs");
Expand Down
73 changes: 73 additions & 0 deletions src/becca/entities/bnote_embedding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import AbstractBeccaEntity from "./abstract_becca_entity.js";
import dateUtils from "../../services/date_utils.js";
import type { NoteEmbeddingRow } from "./rows.js";

/**
* Entity representing a note's vector embedding for semantic search and AI features
*/
class BNoteEmbedding extends AbstractBeccaEntity<BNoteEmbedding> {
static get entityName() {
return "note_embeddings";
}
static get primaryKeyName() {
return "embedId";
}
static get hashedProperties() {
return ["embedId", "noteId", "providerId", "modelId", "dimension", "version"];
}

embedId!: string;
noteId!: string;
providerId!: string;
modelId!: string;
dimension!: number;
embedding!: Buffer;
version!: number;

constructor(row?: NoteEmbeddingRow) {
super();

if (row) {
this.updateFromRow(row);
}
}

updateFromRow(row: NoteEmbeddingRow): void {
this.embedId = row.embedId;
this.noteId = row.noteId;
this.providerId = row.providerId;
this.modelId = row.modelId;
this.dimension = row.dimension;
this.embedding = row.embedding;
this.version = row.version;
this.dateCreated = row.dateCreated;
this.dateModified = row.dateModified;
this.utcDateCreated = row.utcDateCreated;
this.utcDateModified = row.utcDateModified;
}

beforeSaving() {
super.beforeSaving();

this.dateModified = dateUtils.localNowDateTime();
this.utcDateModified = dateUtils.utcNowDateTime();
}

getPojo(): NoteEmbeddingRow {
return {
embedId: this.embedId,
noteId: this.noteId,
providerId: this.providerId,
modelId: this.modelId,
dimension: this.dimension,
embedding: this.embedding,
version: this.version,
dateCreated: this.dateCreated!,
dateModified: this.dateModified!,
utcDateCreated: this.utcDateCreated,
utcDateModified: this.utcDateModified!
};
}
}

export default BNoteEmbedding;
14 changes: 14 additions & 0 deletions src/becca/entities/rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,17 @@ export interface NoteRow {
utcDateModified: string;
content?: string | Buffer;
}

export interface NoteEmbeddingRow {
embedId: string;
noteId: string;
providerId: string;
modelId: string;
dimension: number;
embedding: Buffer;
version: number;
dateCreated: string;
utcDateCreated: string;
dateModified: string;
utcDateModified: string;
}
2 changes: 2 additions & 0 deletions src/becca/entity_constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import BBlob from "./entities/bblob.js";
import BBranch from "./entities/bbranch.js";
import BEtapiToken from "./entities/betapi_token.js";
import BNote from "./entities/bnote.js";
import BNoteEmbedding from "./entities/bnote_embedding.js";
import BOption from "./entities/boption.js";
import BRecentNote from "./entities/brecent_note.js";
import BRevision from "./entities/brevision.js";
Expand All @@ -19,6 +20,7 @@ const ENTITY_NAME_TO_ENTITY: Record<string, ConstructorData<any> & EntityClass>
branches: BBranch,
etapi_tokens: BEtapiToken,
notes: BNote,
note_embeddings: BNoteEmbedding,
options: BOption,
recent_notes: BRecentNote,
revisions: BRevision
Expand Down
1 change: 1 addition & 0 deletions src/public/app/components/app_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type CommandMappings = {
closeHlt: CommandData;
showLaunchBarSubtree: CommandData;
showRevisions: CommandData;
showLlmChat: CommandData;
showOptions: CommandData & {
section: string;
};
Expand Down
5 changes: 5 additions & 0 deletions src/public/app/components/note_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">

const { note, viewScope } = this;

// For llmChat viewMode, show a custom title
if (viewScope?.viewMode === "llmChat") {
return "Chat with Notes";
}

const isNormalView = (viewScope?.viewMode === "default" || viewScope?.viewMode === "contextual-help");
let title = (isNormalView ? note.title : `${note.title}: ${viewScope?.viewMode}`);

Expand Down
23 changes: 23 additions & 0 deletions src/public/app/components/root_command_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import protectedSessionService from "../services/protected_session.js";
import options from "../services/options.js";
import froca from "../services/froca.js";
import utils from "../services/utils.js";
import LlmChatPanel from "../widgets/llm_chat_panel.js";
import toastService from "../services/toast.js";

export default class RootCommandExecutor extends Component {
private llmChatPanel: any = null;

editReadOnlyNoteCommand() {
const noteContext = appContext.tabManager.getActiveContext();
if (noteContext?.viewScope) {
Expand Down Expand Up @@ -226,4 +230,23 @@ export default class RootCommandExecutor extends Component {
appContext.tabManager.activateNoteContext(tab.ntxId);
}
}

async showLlmChatCommand() {
console.log("showLlmChatCommand triggered");
toastService.showMessage("Opening LLM Chat...");

try {
// We'll use the Note Map approach - open a known note ID that corresponds to the LLM chat panel
await appContext.tabManager.openTabWithNoteWithHoisting("_globalNoteMap", {
activate: true,
viewScope: {
viewMode: "llmChat" // We'll need to handle this custom view mode elsewhere
}
});
}
catch (e) {
console.error("Error opening LLM Chat:", e);
toastService.showError("Failed to open LLM Chat: " + (e as Error).message);
}
}
}
11 changes: 11 additions & 0 deletions src/public/app/desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import options from "./services/options.js";
import type ElectronRemote from "@electron/remote";
import type Electron from "electron";
import "../stylesheets/bootstrap.scss";
import rightPaneTabManager from "./services/right_pane_tab_manager.js";

await appContext.earlyInit();

Expand All @@ -27,6 +28,16 @@ bundleService.getWidgetBundlesByParent().then(async (widgetBundles) => {
});
console.error("Critical error occured", e);
});

// Initialize right pane tab manager after layout is loaded
setTimeout(() => {
const $tabContainer = $("#right-pane-tab-container");
const $contentContainer = $("#right-pane-content-container");

if ($tabContainer.length && $contentContainer.length) {
rightPaneTabManager.init($tabContainer, $contentContainer);
}
}, 1000);
});

glob.setupGlobs();
Expand Down
32 changes: 29 additions & 3 deletions src/public/app/layouts/desktop_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";
import CloseZenButton from "../widgets/close_zen_button.js";
import rightPaneTabManager from "../services/right_pane_tab_manager.js";
import type { AppContext } from "./../components/app_context.js";
import type { WidgetsByParent } from "../services/bundle.js";
import SwitchSplitOrientationButton from "../widgets/floating_buttons/switch_layout_button.js";
Expand All @@ -104,6 +105,16 @@
getRootWidget(appContext: AppContext) {
appContext.noteTreeWidget = new NoteTreeWidget();

// Initialize the right pane tab manager after widget render
setTimeout(() => {
const $tabContainer = $("#right-pane-tab-container");
const $contentContainer = $("#right-pane-content-container");

if ($tabContainer.length && $contentContainer.length) {
rightPaneTabManager.init($tabContainer, $contentContainer);
}
}, 500);

const launcherPaneIsHorizontal = options.get("layoutOrientation") === "horizontal";
const launcherPane = this.#buildLauncherPane(launcherPaneIsHorizontal);
const isElectron = utils.isElectron();
Expand Down Expand Up @@ -243,9 +254,24 @@
)
.child(
new RightPaneContainer()
.child(new TocWidget())
.child(new HighlightsListWidget())
.child(...this.customWidgets.get("right-pane"))
.id("right-pane-container")
.child(
new FlexContainer("row")

Check failure on line 259 in src/public/app/layouts/desktop_layout.ts

View workflow job for this annotation

GitHub Actions / Test development

Argument of type 'FlexContainer<TypedComponent<any>>' is not assignable to parameter of type 'RightPanelWidget'.
.id("right-pane-tab-container")
.css("height", "40px")
.css("padding", "5px 10px")
.css("border-bottom", "1px solid var(--main-border-color)")
.css("background-color", "var(--accented-background-color)")
)
.child(
new FlexContainer("column")

Check failure on line 267 in src/public/app/layouts/desktop_layout.ts

View workflow job for this annotation

GitHub Actions / Test development

Argument of type 'FlexContainer<TypedComponent<any>>' is not assignable to parameter of type 'RightPanelWidget'.
.id("right-pane-content-container")
.css("flex-grow", "1")
.css("overflow", "hidden")
.child(new TocWidget())
.child(new HighlightsListWidget())
.child(...this.customWidgets.get("right-pane"))
)
)
)
)
Expand Down
Loading
Loading