Skip to content
Merged
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
46 changes: 46 additions & 0 deletions src/automators/onFileModifyAutomatorManager.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {afterEach, beforeEach, describe, expect, it} from "vitest";
import {Notice} from "../../tests/obsidian-stub";
import {log} from "../logger/logManager";
import {GuiLogger} from "../logger/guiLogger";
import {OnFileModifyAutomatorManager} from "./onFileModifyAutomatorManager";
import {OnModifyAutomatorType} from "./onFileModifyAutomators/onModifyAutomatorType";
import type {IOnFileModifyAutomator} from "./onFileModifyAutomators/IOnFileModifyAutomator";

const resetLoggers = () => {
(log.constructor as unknown as {loggers: unknown[]}).loggers = [];
Notice.messages = [];
};

const automator = (type: OnModifyAutomatorType) => ({type, onFileModify: async () => {}}) as unknown as IOnFileModifyAutomator;

describe("OnFileModifyAutomatorManager.attach", () => {
beforeEach(() => {
resetLoggers();
log.register(new GuiLogger({} as never));
});
afterEach(resetLoggers);

it("treats attaching an already attached automator as a no-op, without a notice", () => {
const manager = new OnFileModifyAutomatorManager({app: {}} as never);

manager.attach(automator(OnModifyAutomatorType.ProgressProperties));
manager.attach(automator(OnModifyAutomatorType.KanbanHelper));
manager.attach(automator(OnModifyAutomatorType.ProgressProperties));

expect(Notice.messages).toEqual([]);
});
});

describe("log.logWarning", () => {
beforeEach(() => {
resetLoggers();
log.register(new GuiLogger({} as never));
});
afterEach(resetLoggers);

it("reports warnings at warning level", () => {
log.logWarning("file Board not found.");

expect(Notice.messages).toEqual(["MetaEdit: (WARNING) file Board not found."]);
});
});
8 changes: 3 additions & 5 deletions src/automators/onFileModifyAutomatorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ export class OnFileModifyAutomatorManager implements IAutomatorManager {
}

attach(automator: IOnFileModifyAutomator): IAutomatorManager {
const isExist = this.automators.some(tAuto => tAuto.type === automator.type);
if (isExist) {
log.logWarning(`a ${automator.type} automator is already attached.`);
return this;
}
// toggleAutomators() reconciles every automator with the settings, so the
// one that is already on gets attached again whenever another is toggled.
if (this.automators.some(tAuto => tAuto.type === automator.type)) return this;

this.automators.push(automator);
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/logger/logManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LogManager {
}

logWarning(message: string) {
LogManager.loggers.forEach(logger => logger.logError(message));
LogManager.loggers.forEach(logger => logger.logWarning(message));
}

logMessage(message: string) {
Expand Down
14 changes: 14 additions & 0 deletions tests/obsidian-stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ export function createTFile(path: string): obsidian.TFile {
return new TFile(path) as unknown as obsidian.TFile;
}

export function debounce<T extends unknown[]>(cb: (...args: T) => unknown, timeout = 0) {
let timer: ReturnType<typeof setTimeout> | undefined;
const debounced = (...args: T) => {
clearTimeout(timer);
timer = setTimeout(() => cb(...args), timeout);
return debounced;
};
debounced.cancel = () => {
clearTimeout(timer);
return debounced;
};
return debounced;
}

export class Notice {
static messages: string[] = [];

Expand Down
2 changes: 1 addition & 1 deletion website/src/content/docs/cookbook/kanban-status-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Drag a card, wait a few seconds, and the table regroups. The same property also

| Symptom | Cause and fix |
| --- | --- |
| Notice: `MetaEdit: (ERROR) 'status' not found in "Website relaunch" (Kanban board 'Projects').` | The linked note lacks the property. The helper updates properties but never creates them - add `status` to the note first (step 2). |
| Notice: `MetaEdit: (WARNING) 'status' not found in "Website relaunch" (Kanban board 'Projects').` | The linked note lacks the property. The helper updates properties but never creates them - add `status` to the note first (step 2). |
| Nothing happens after a drag | Wait for the 5-second debounce; it resets while the board keeps changing. The helper only reacts to modifications made through Obsidian. |
| One specific card never syncs | Only the leading link of a top-level card line counts (`- [ ] [[Note]] ...`). Trailing links such as Kanban date links, links in the card text, and indented sub-items are ignored. A card sitting above the first lane heading has no lane and is skipped. If several notes share the card's bare name and Obsidian cannot resolve the link, the helper skips it rather than guess. |
| Board stopped syncing after you renamed it | Boards are matched by file basename, and the stored row keeps the old name. Remove the row and re-add the renamed board. If the board file is gone, its "Possible values" cell shows `FILE NOT FOUND`. |
Expand Down
4 changes: 2 additions & 2 deletions website/src/content/docs/guides/kanban-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ The helper shares its trigger pipeline with Progress Properties: modify event on
When a card's note lacks the configured property, MetaEdit shows a notice for that card:

```text
MetaEdit: (ERROR) 'status' not found in "Dune review" (Kanban board 'Editorial calendar').
MetaEdit: (WARNING) 'status' not found in "Dune review" (Kanban board 'Editorial calendar').
```

This is a warning - nothing is broken - but it appears with the `MetaEdit: (ERROR)` prefix anyway; that is a known quirk of how MetaEdit surfaces warnings. Fix it by adding the property to the note. See the [notices reference](/reference/notices/) for every message MetaEdit can show.
This is a warning - nothing is broken. Fix it by adding the property to the note. See the [notices reference](/reference/notices/) for every message MetaEdit can show.

## Caveats

Expand Down
4 changes: 0 additions & 4 deletions website/src/content/docs/help/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ Yes. Everywhere MetaEdit matches names - Auto Properties, "Edit Meta menu" hidde

In your vault at `.obsidian/plugins/metaedit/data.json`. Settings sync with the vault if you sync that folder. The [settings reference](/reference/settings/) documents every field.

## Why does a warning say "(ERROR)"?

A known logging quirk: MetaEdit's warnings are routed through the error channel, so warning notices read `MetaEdit: (ERROR) ...`. Judge the message by its text, not the label - a warning like the Kanban helper's "property not found" notice does not mean data was lost. See the [notices reference](/reference/notices/).

## Where did the body-tag delete and transform actions go?

Removed in 1.9.0. Body tags have no `key:` line, so those two actions could not target the right text safely. Renaming a tag and editing the last segment of a nested tag remain, and frontmatter `tags` editing is unaffected. See [what's new in 1.9.0](/getting-started/whats-new/) and [edit tags](/guides/edit-tags/).
6 changes: 1 addition & 5 deletions website/src/content/docs/help/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ See [Progress Properties](/guides/progress-properties/) and the [Kanban Board He
- **Heading-less cards have no lane.** A card above the first heading is skipped because there is no lane name to write.
- **Ambiguous basenames are refused.** If several notes share the linked basename and Obsidian's cache cannot resolve which one is meant, the helper skips that card rather than write to the wrong note.
- **A renamed board file breaks the configuration.** Boards are matched by file basename and the stored name does not follow a rename; the settings row then shows "FILE NOT FOUND" in its "Possible values" column. Re-add the board under its new name.
- **The linked note must already have the property.** If it is missing you get a notice per affected card: `MetaEdit: (ERROR) '<property>' not found in "<note>" (Kanban board '<board>').`
- **The linked note must already have the property.** If it is missing you get a notice per affected card: `MetaEdit: (WARNING) '<property>' not found in "<note>" (Kanban board '<board>').`

**Fix:** structure cards as `- [ ] [[Note]]` under a heading, keep board file names stable, and add the configured property to each linked note. Details in the [Kanban Board Helper guide](/guides/kanban-helper/).

Expand Down Expand Up @@ -117,10 +117,6 @@ Several MetaEdit messages go to the console only:
- **macOS:** press `Cmd+Option+I`, then open the Console tab.
- **Mobile:** there is no built-in console. On Android you can attach Chrome's remote debugger via `chrome://inspect` with USB debugging enabled; iOS does not expose one.

:::note[Warnings are labeled "(ERROR)"]
Due to a logging quirk, MetaEdit warnings surface prefixed `MetaEdit: (ERROR) ...`. The label does not mean data was lost - read the message itself. See the [FAQ](/help/faq/#why-does-a-warning-say-error) and the [notices reference](/reference/notices/).
:::

## File a good issue

If your problem is not covered here, open an issue on [GitHub](https://github.com/chhoumann/MetaEdit/issues) and include:
Expand Down
10 changes: 5 additions & 5 deletions website/src/content/docs/reference/notices.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ sidebar:

This page lists every user-visible notice MetaEdit can show, with the exact text (placeholders in `{braces}`), the situation that triggers it, and what to do. Use your browser's find-in-page to jump to the message you saw. For symptoms without a notice, start at [troubleshooting](/help/troubleshooting/).

:::note[The "MetaEdit: (ERROR)" prefix on warnings]
Messages routed through MetaEdit's warning channel are displayed with the prefix `MetaEdit: (ERROR)` - in the notice popup and in the developer console. That is a logging quirk (warnings fan out to the error channel), not a crash. The Kanban Board Helper's "not found" message below is the most common example.
:::note[The "(WARNING)" and "(ERROR)" prefixes]
Notices from MetaEdit's logger start with `MetaEdit: (WARNING)` or `MetaEdit: (ERROR)`. A warning means MetaEdit skipped something it could not do, such as updating a property the note does not have. No data is lost. Older versions labeled warnings `(ERROR)` too.
:::

## Editing properties
Expand Down Expand Up @@ -81,12 +81,12 @@ See [Auto Properties](/guides/auto-properties/).

## Progress Properties and Kanban Board Helper

See [Progress Properties](/guides/progress-properties/) and the [Kanban Board Helper](/guides/kanban-helper/). These carry the `MetaEdit: (ERROR)` prefix described above.
See [Progress Properties](/guides/progress-properties/) and the [Kanban Board Helper](/guides/kanban-helper/). These carry the prefixes described above.

| Notice | When it appears | What to do |
| --- | --- | --- |
| `MetaEdit: (ERROR) '{property}' not found in "{note}" (Kanban board '{board}').` | A card changed lanes, but the linked note does not contain the configured property. The helper only updates existing properties - it never creates them. | Add the property to the note (any value), then move the card again. |
| `MetaEdit: (ERROR) file {board} not found.` | A configured board file no longer exists - the settings panel also shows `FILE NOT FOUND` in its "Possible values" column. Boards are matched by file basename, so renaming the board file breaks the row. | Remove the row and re-add the board under its new name. |
| `MetaEdit: (WARNING) '{property}' not found in "{note}" (Kanban board '{board}').` | A card changed lanes, but the linked note does not contain the configured property. The helper only updates existing properties - it never creates them. | Add the property to the note (any value), then move the card again. |
| `MetaEdit: (WARNING) file {board} not found.` | A configured board file no longer exists - the settings panel also shows `FILE NOT FOUND` in its "Possible values" column. Boards are matched by file basename, so renaming the board file breaks the row. | Remove the row and re-add the board under its new name. |
| `MetaEdit: (ERROR) {message}` | A Progress Properties update failed while writing task counts. | Check the note's frontmatter parses (Obsidian shows invalid frontmatter in the editor), then modify the note again to re-trigger the count. |

## Reserved property names
Expand Down
Loading