Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const getPreset = (settings: LoomSettings) =>
export type SearchResultState = "result" | "ancestor" | "none" | null;

export interface Node {
author: string | null;
text: string;
parentId: string | null;
collapsed: boolean;
Expand Down
7 changes: 6 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default class LoomPlugin extends Plugin {
): [string, Node] {
const id = uuidv4();
const node: Node = {
author: "N/A",
text,
parentId,
collapsed: false,
Expand All @@ -197,6 +198,7 @@ export default class LoomPlugin extends Plugin {

initializeNoteState(file: TFile) {
const [rootId, root] = this.newNode(this.editor.getValue(), null);
root.author = "genesis";
this.state[file.path] = {
current: rootId,
hoisted: [] as string[],
Expand Down Expand Up @@ -1324,6 +1326,8 @@ export default class LoomPlugin extends Plugin {

// console.log("rawCompletions", rawCompletions);

var preset = getPreset(this.settings);

// escape and clean up the completions
const completions = rawCompletions.map((completion: string) => {
if (!completion) completion = ""; // empty completions are null, apparently
Expand All @@ -1334,7 +1338,7 @@ export default class LoomPlugin extends Plugin {
// otherwise, deduplicate adjacent spaces between the prompt and completion
if (
["azure-chat", "openai-chat"].includes(
getPreset(this.settings).provider
preset.provider
)
) {
if (!trailingSpace) completion = " " + completion;
Expand All @@ -1348,6 +1352,7 @@ export default class LoomPlugin extends Plugin {
let ids = [];
for (let completion of completions) {
const [id, node] = this.newNode(completion, rootNode, true);
node.author = preset.name;
state.nodes[id] = node;
ids.push(id);
}
Expand Down