feat: implement shared dispatch error signal

Introduce a shared `dispatchError` signal in the command dispatcher
to unify error reporting across different components. This allows
`CommandLinkManager` to surface errors through the `JournalInput`
UI, ensuring that errors from `:cmd[]` directive clicks are visible
to the user.
This commit is contained in:
2026-07-12 14:38:06 +08:00
parent ffbfa65716
commit 86abf34c10
3 changed files with 53 additions and 27 deletions
+8 -3
View File
@@ -1,14 +1,15 @@
/**
* CommandLinkManager — mounts as a child of <Article> and intercepts
* clicks on :cmd[] directive spans to dispatch them via the shared
* command dispatcher.
* command dispatcher. Errors are surfaced through the shared
* dispatchError signal, shown by JournalInput above the textarea.
*/
import { Component, onCleanup } from "solid-js";
import { useArticleDom } from "./Article";
import { useJournalStream } from "./stores/journalStream";
import { useJournalCompletions } from "./journal/completions";
import { dispatchCommand } from "./journal/command-dispatcher";
import { dispatchCommand, setDispatchError } from "./journal/command-dispatcher";
export const CommandLinkManager: Component = () => {
const contentDom = useArticleDom();
@@ -26,7 +27,7 @@ export const CommandLinkManager: Component = () => {
e.stopPropagation();
e.stopImmediatePropagation();
void dispatchCommand({
dispatchCommand({
role: stream.myRole as "gm" | "player" | "observer",
myName: stream.myName,
command,
@@ -34,6 +35,10 @@ export const CommandLinkManager: Component = () => {
statValues: stream.stats,
statDefs: comp.data.stats,
statTemplates: comp.data.statTemplates,
}).then((result) => {
if (!result.ok) {
setDispatchError(result.error);
}
});
};