pi-weave 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/web/client/dist/app.js +3 -3
- package/src/web/client/note/Note.tsx +2 -1
- package/src/web/client/note/note.model.ts +2 -1
- package/src/web/client/shell/Columns.tsx +2 -0
- package/src/web/client/shell/Shell.tsx +1 -0
- package/src/web/client/state.ts +2 -1
- package/src/web/client/workspace.ts +4 -3
|
@@ -83,6 +83,7 @@ const PREVIEW_Y = "weave-preview-y";
|
|
|
83
83
|
|
|
84
84
|
export interface NoteProps {
|
|
85
85
|
note: NotePayload | null;
|
|
86
|
+
loadFailed: boolean;
|
|
86
87
|
graph: GraphPayload | null;
|
|
87
88
|
selectedId: string | null;
|
|
88
89
|
onSelect: (id: string) => void;
|
|
@@ -167,7 +168,7 @@ function Header({
|
|
|
167
168
|
export function Note(props: NoteProps) {
|
|
168
169
|
const note = props.note?.note ?? null;
|
|
169
170
|
const artifactPath = selectedArtifactPath(props.graph, props.selectedId);
|
|
170
|
-
const empty = noteEmptyMessage(props.selectedId, note);
|
|
171
|
+
const empty = noteEmptyMessage(props.selectedId, note, props.loadFailed);
|
|
171
172
|
|
|
172
173
|
// Both hook calls sit before the empty-return so the hook order cannot
|
|
173
174
|
// depend on whether a note is loaded. The memoization is cheap insurance:
|
|
@@ -1151,9 +1151,10 @@ export function reducePreview(state: PreviewState, event: PreviewEvent): Preview
|
|
|
1151
1151
|
* message for all of them is how a user concludes the app is broken when they
|
|
1152
1152
|
* click a module and the reading pane does not change.
|
|
1153
1153
|
*/
|
|
1154
|
-
export function noteEmptyMessage(selectedId: string | null, note: ViewNote | null): string | null {
|
|
1154
|
+
export function noteEmptyMessage(selectedId: string | null, note: ViewNote | null, failed = false): string | null {
|
|
1155
1155
|
if (note !== null) return null;
|
|
1156
1156
|
if (selectedId === null) return "Nothing open — search with ⌘K, or walk the tree with j and k.";
|
|
1157
|
+
if (failed) return "Couldn’t load this note — retrying…";
|
|
1157
1158
|
if (selectedId.startsWith(NOTE_PREFIX)) return "Loading…";
|
|
1158
1159
|
// A module, a file, a package, the git state: real nodes with no prose
|
|
1159
1160
|
// behind them. The context rail beside this column is where their
|
|
@@ -26,6 +26,7 @@ export interface ColumnsProps {
|
|
|
26
26
|
/** The §1.3 context bus, as the columns see it. */
|
|
27
27
|
graph: GraphPayload | null;
|
|
28
28
|
note: NotePayload | null;
|
|
29
|
+
noteFailed: boolean;
|
|
29
30
|
selectedId: string | null;
|
|
30
31
|
recentIds: ReadonlySet<string>;
|
|
31
32
|
/**
|
|
@@ -88,6 +89,7 @@ function Column({ id, props }: { id: ColumnId; props: ColumnsProps }) {
|
|
|
88
89
|
{id === "note" ? (
|
|
89
90
|
<Note
|
|
90
91
|
note={props.note}
|
|
92
|
+
loadFailed={props.noteFailed}
|
|
91
93
|
graph={props.graph}
|
|
92
94
|
selectedId={props.selectedId}
|
|
93
95
|
onSelect={props.onSelect}
|
|
@@ -232,6 +232,7 @@ export function Shell(props: ShellProps) {
|
|
|
232
232
|
bootFailed={workspaceState.graphFailed}
|
|
233
233
|
graph={workspaceState.graph}
|
|
234
234
|
note={workspaceState.note}
|
|
235
|
+
noteFailed={workspaceState.noteFailed}
|
|
235
236
|
selectedId={workspaceState.selectedId}
|
|
236
237
|
recentIds={workspaceState.recentIds}
|
|
237
238
|
onSelect={select}
|
package/src/web/client/state.ts
CHANGED
|
@@ -11,10 +11,11 @@ export interface WorkspaceState {
|
|
|
11
11
|
graph: GraphPayload | null;
|
|
12
12
|
graphFailed: boolean;
|
|
13
13
|
note: NotePayload | null;
|
|
14
|
+
noteFailed: boolean;
|
|
14
15
|
recentIds: ReadonlySet<string>;
|
|
15
16
|
selectedId: string | null;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function initialWorkspaceState(): WorkspaceState {
|
|
19
|
-
return { graph: null, graphFailed: false, note: null, recentIds: new Set(), selectedId: null };
|
|
20
|
+
return { graph: null, graphFailed: false, note: null, noteFailed: false, recentIds: new Set(), selectedId: null };
|
|
20
21
|
}
|
|
@@ -54,11 +54,12 @@ export function startWorkspace(opts: WorkspaceOptions): WorkspaceHandle {
|
|
|
54
54
|
const loadNote = async (): Promise<void> => {
|
|
55
55
|
const slug = noteSlug(state.selectedId);
|
|
56
56
|
if (slug === null) {
|
|
57
|
-
update({ note: null });
|
|
57
|
+
update({ note: null, noteFailed: false });
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
const result = await fetchNote(opts.fetch, slug);
|
|
61
|
-
if (result.ok) update({ note: result.data });
|
|
61
|
+
if (result.ok) update({ note: result.data, noteFailed: false });
|
|
62
|
+
else update({ note: null, noteFailed: true });
|
|
62
63
|
};
|
|
63
64
|
const loadGraph = async (): Promise<ApiResult<unknown>> => {
|
|
64
65
|
const previous = state.graph;
|
|
@@ -86,7 +87,7 @@ export function startWorkspace(opts: WorkspaceOptions): WorkspaceHandle {
|
|
|
86
87
|
polling = true;
|
|
87
88
|
try {
|
|
88
89
|
const result = await loadGraph();
|
|
89
|
-
if (
|
|
90
|
+
if (noteSlug(state.selectedId) !== null && (state.note === null || (result.ok && !result.cached))) await loadNote();
|
|
90
91
|
} finally {
|
|
91
92
|
polling = false;
|
|
92
93
|
}
|