mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-06 13:36:53 +00:00
refactor(ui): simplify memory import error rendering (#161568)
Call the existing UI error formatter directly and share the identical plan/apply alert template. Preserve fallback text, redaction, alert order, accessibility roles, and all lifecycle behavior. Net production LOC: -9; tests unchanged. Both cycle checks returned zero; 25 focused tests, targeted lint, formatting, and independent review passed. Hosted CI on the pinned head is the merge gate.
This commit is contained in:
parent
7894445e4e
commit
f1f0157815
2 changed files with 8 additions and 17 deletions
|
|
@ -37,10 +37,6 @@ type PendingMemoryImport = {
|
|||
attempted: boolean;
|
||||
};
|
||||
|
||||
function toErrorMessage(error: unknown): string {
|
||||
return formatUiError(error, "request failed");
|
||||
}
|
||||
|
||||
export class MemoryImportPage extends OpenClawLightDomElement {
|
||||
@consume({ context: applicationContext, subscribe: true })
|
||||
private context!: ApplicationContext;
|
||||
|
|
@ -186,7 +182,9 @@ export class MemoryImportPage extends OpenClawLightDomElement {
|
|||
}
|
||||
|
||||
private get error(): string | null {
|
||||
return this.planTask.status === TaskStatus.ERROR ? toErrorMessage(this.planTask.error) : null;
|
||||
return this.planTask.status === TaskStatus.ERROR
|
||||
? formatUiError(this.planTask.error, "request failed")
|
||||
: null;
|
||||
}
|
||||
|
||||
private get canAdmin(): boolean {
|
||||
|
|
@ -318,7 +316,7 @@ export class MemoryImportPage extends OpenClawLightDomElement {
|
|||
await this.refresh();
|
||||
} catch (error) {
|
||||
if (applyEpoch === this.applyEpoch) {
|
||||
this.applyError = toErrorMessage(error);
|
||||
this.applyError = formatUiError(error, "request failed");
|
||||
}
|
||||
} finally {
|
||||
if (applyEpoch === this.applyEpoch) {
|
||||
|
|
@ -447,7 +445,7 @@ export class MemoryImportPage extends OpenClawLightDomElement {
|
|||
}
|
||||
} catch (error) {
|
||||
if (isCurrent()) {
|
||||
this.backfillError = toErrorMessage(error);
|
||||
this.backfillError = formatUiError(error, "request failed");
|
||||
}
|
||||
} finally {
|
||||
if (isCurrent()) {
|
||||
|
|
|
|||
|
|
@ -660,16 +660,9 @@ export function renderMemoryImport(props: MemoryImportViewProps) {
|
|||
<div class="memory-import" data-test-id="memory-import-page">
|
||||
${renderSettingsPage(html`
|
||||
${renderIntroSection(props)} ${renderBackfillSection(props)}
|
||||
${
|
||||
props.error
|
||||
? html`<div class="callout danger" role="alert">${props.error}</div>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
props.applyError
|
||||
? html`<div class="callout danger" role="alert">${props.applyError}</div>`
|
||||
: nothing
|
||||
}
|
||||
${[props.error, props.applyError].map((error) =>
|
||||
error ? html`<div class="callout danger" role="alert">${error}</div>` : nothing,
|
||||
)}
|
||||
${
|
||||
props.loading && !props.plan
|
||||
? html`<div class="settings-group memory-import__loading" aria-busy="true">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue