@nocobase/app-skills 0.1.0-beta.59 → 0.1.0-beta.60

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.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/skills/nocobase-app-development/SKILL.md +4 -0
  3. package/skills/nocobase-app-development/assets/business-examples/onboarding/tests/client/onboarding.test.tsx +26 -3
  4. package/skills/nocobase-app-development/assets/business-examples/onboarding/tests/server/onboarding.test.ts +13 -1
  5. package/skills/nocobase-app-development/assets/business-examples/procurement/tests/server/procurement.test.ts +15 -1
  6. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/detail.tsx +66 -55
  7. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/index.tsx +11 -29
  8. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/locales.ts +0 -2
  9. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/relation-picker.tsx +68 -18
  10. package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/shared.tsx +32 -12
  11. package/skills/nocobase-app-development/assets/customer-contacts-example/tests/client/customer-contacts.test.tsx +155 -2
  12. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/detail.tsx +103 -0
  13. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/index.tsx +7 -2
  14. package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/locales.ts +5 -0
  15. package/skills/nocobase-app-development/assets/list-edit-example/tests/client/skill-projects.test.tsx +88 -0
  16. package/skills/nocobase-app-development/references/frontend/frontend-dev.md +2 -0
  17. package/skills/nocobase-app-development/references/frontend/references/child-routes.md +13 -14
  18. package/skills/nocobase-app-development/references/frontend/references/example/copy.md +0 -4
  19. package/skills/nocobase-app-development/references/frontend/references/example/create-page.md +12 -8
  20. package/skills/nocobase-app-development/references/frontend/references/example/detail-page-tabs.md +13 -11
  21. package/skills/nocobase-app-development/references/frontend/references/example/list-page.md +1 -1
  22. package/skills/nocobase-app-development/references/frontend/references/example/project-dashboard.md +21 -21
  23. package/skills/nocobase-app-development/references/frontend/references/example/project-summary.md +8 -27
  24. package/skills/nocobase-app-development/references/frontend/references/example/server-table.md +1 -1
  25. package/skills/nocobase-app-development/references/frontend/references/executable-list-edit.md +35 -3
  26. package/skills/nocobase-app-development/references/frontend/references/list-feedback.md +27 -22
  27. package/skills/nocobase-app-development/references/frontend/references/navigation.md +99 -0
  28. package/skills/nocobase-app-development/references/frontend/references/overlay.md +31 -0
  29. package/skills/nocobase-app-development/references/frontend/references/page-freshness.md +23 -0
  30. package/skills/nocobase-app-development/references/frontend/references/page.md +32 -28
  31. package/skills/nocobase-app-development/references/frontend/references/styling.md +8 -8
  32. package/skills/nocobase-app-development/references/frontend/references/table.md +1 -1
  33. package/skills/nocobase-app-development/references/frontend/references/ui-library.md +43 -7
  34. package/skills/nocobase-app-development/references/frontend/ui-guidelines.md +13 -9
  35. package/skills/nocobase-app-development/references/pending-feedback.md +132 -0
  36. package/skills/nocobase-app-plugin-development/references/client-child-routes.md +2 -0
  37. package/skills/nocobase-app-upgrade/references/list-feedback-upgrade.md +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/app-skills",
3
- "version": "0.1.0-beta.59",
3
+ "version": "0.1.0-beta.60",
4
4
  "description": "Agent Skills for developing applications and plugins, upgrading and deploying NocoBase applications.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -87,6 +87,10 @@ Install, update and customize plugins, and remove a direct NocoBase package, as
87
87
 
88
88
  Business role assignments must be visible and editable through administration. Default to explicit users; do not assign application roles to every authenticated identity or broaden the inherited member role merely to enable a feature. Follow [permission assignment safety](references/authorization.md#visible-and-manageable-assignments) and run the template's initialized-assignment guard before delivery.
89
89
 
90
+ ## Waiting feedback
91
+
92
+ For page/panel waits and native submit buttons, follow [pending feedback](references/pending-feedback.md). Use installed Loading/PendingButton and the shared timing hook; retain submission and list-state owners.
93
+
90
94
  ## Choose sample data or a demo system
91
95
 
92
96
  A request to add example customers, orders or tasks normally means sample data in the existing application. Use `sample: true` seeds or `sampleDataToken`; see [sample data and demo systems](references/migrations.md#sample-data-and-demo-systems). Keep required initialization data in ordinary seeds. Do not infer an isolated demo deployment from the words "demo data" alone.
@@ -3,6 +3,9 @@ import userEvent from '@testing-library/user-event';
3
3
  import { expect, it } from 'vitest';
4
4
  import { Route, Routes, Navigate } from 'react-router';
5
5
  import { randomUUID } from 'node:crypto';
6
+ import type { ReactElement } from 'react';
7
+ import type { AppClientRegisteredRoute } from '@nocobase/app-client/plugins';
8
+ import { RouteTreeProvider } from '../../client/routing/route-context.js';
6
9
  import OnboardingPage from '../../client/pages/onboarding/index.js';
7
10
  import OnboardingWizard from '../../client/pages/onboarding/wizard.js';
8
11
  import { renderAuthenticatedClient } from '../helpers/authenticated-client.js';
@@ -13,6 +16,26 @@ import {
13
16
  type OnboardingInput,
14
17
  type OnboardingDetail,
15
18
  } from '../../shared/onboarding.js';
19
+ const routes: AppClientRegisteredRoute[] = [
20
+ {
21
+ id: 'onboarding',
22
+ name: 'onboarding',
23
+ path: '/onboarding',
24
+ packageName: '@nocobase/app-template-examples',
25
+ source: 'application',
26
+ authz: 'skip',
27
+ componentLoader: async () => ({ default: OnboardingPage }),
28
+ },
29
+ ];
30
+ // The isolated page tree still supplies the registered list used by the safe return link.
31
+ const renderOnboardingClient = (
32
+ ui: ReactElement,
33
+ options: Parameters<typeof renderAuthenticatedClient>[1] = {},
34
+ ) =>
35
+ renderAuthenticatedClient(
36
+ <RouteTreeProvider routes={routes}>{ui}</RouteTreeProvider>,
37
+ options,
38
+ );
16
39
  const write = (input: unknown, method = 'POST') => ({
17
40
  method,
18
41
  headers: {
@@ -73,7 +96,7 @@ it('derives the first incomplete step with shared conditional and cross-step val
73
96
  });
74
97
  it('retains input while changing steps, validates conditions and recovers a private draft from the real API', async () => {
75
98
  const writes: string[] = [];
76
- await renderAuthenticatedClient(
99
+ await renderOnboardingClient(
77
100
  <Routes>
78
101
  <Route path='/onboarding' element={<OnboardingPage />}>
79
102
  <Route path='new' element={<OnboardingWizard />} />
@@ -250,7 +273,7 @@ it('retains input while changing steps, validates conditions and recovers a priv
250
273
  ).not.toBeInTheDocument();
251
274
  });
252
275
  it('keeps unsaved child-page input until leaving is confirmed', async () => {
253
- await renderAuthenticatedClient(
276
+ await renderOnboardingClient(
254
277
  <Routes>
255
278
  <Route path='/onboarding' element={<OnboardingPage />}>
256
279
  <Route path='new' element={<OnboardingWizard />} />
@@ -300,7 +323,7 @@ it('locks save and submit through refresh and replays an uncertain submission wi
300
323
  );
301
324
  }
302
325
  try {
303
- const view = await renderAuthenticatedClient(<RequestRoutes />, {
326
+ const view = await renderOnboardingClient(<RequestRoutes />, {
304
327
  route: '/start',
305
328
  async prepare(app, session) {
306
329
  await app.connection.repository('onboardingDepartments').createOne({
@@ -20,7 +20,6 @@ import {
20
20
  } from '../../shared/onboarding.js';
21
21
  import { resetOnboarding } from '../../server/providers/onboarding-reset.js';
22
22
  const test = createAppTest({
23
- scope: 'test',
24
23
  createServer: createStandaloneServer,
25
24
  connections: ['main', 'analytics'],
26
25
  config: {
@@ -31,6 +30,19 @@ const test = createAppTest({
31
30
  emailAndPassword: { disableSignUp: false },
32
31
  },
33
32
  },
33
+ }).extend<{ resetData: void }>({
34
+ resetData: [
35
+ async ({ testApp }, use) => {
36
+ // Identities are unique per case; reset records and reference data before each one.
37
+ await resetOnboarding(testApp.connection, false);
38
+ await testApp.connection.query
39
+ .deleteFrom('onboardingDepartments')
40
+ .allowAllRows()
41
+ .execute();
42
+ await use(undefined);
43
+ },
44
+ { auto: true },
45
+ ],
34
46
  });
35
47
  const write = (
36
48
  input: unknown,
@@ -11,7 +11,6 @@ import type { ProcurementDetail } from '../../shared/procurement.js';
11
11
  import { resetProcurement } from '../../server/providers/procurement-reset.js';
12
12
 
13
13
  const test = createAppTest({
14
- scope: 'test',
15
14
  createServer: createStandaloneServer,
16
15
  connections: ['main', 'analytics'],
17
16
  config: {
@@ -22,6 +21,21 @@ const test = createAppTest({
22
21
  emailAndPassword: { disableSignUp: false },
23
22
  },
24
23
  },
24
+ }).extend<{ resetData: void }>({
25
+ resetData: [
26
+ async ({ testApp }, use) => {
27
+ // Keep the installed application, but start each case with empty business data.
28
+ await resetProcurement(testApp.connection, false);
29
+ for (const table of ['procurementMaterials', 'procurementSuppliers']) {
30
+ await testApp.connection.query
31
+ .deleteFrom(table)
32
+ .allowAllRows()
33
+ .execute();
34
+ }
35
+ await use(undefined);
36
+ },
37
+ { auto: true },
38
+ ],
25
39
  });
26
40
  const write = (
27
41
  input: unknown,
@@ -1,4 +1,8 @@
1
- import { useApiClient, useToaster } from '@nocobase/app-client';
1
+ import {
2
+ resolveListState,
3
+ useApiClient,
4
+ useToaster,
5
+ } from '@nocobase/app-client';
2
6
  import { useTranslation } from '@nocobase/i18n/client';
3
7
  import { useEffect, useRef, useState } from 'react';
4
8
  import {
@@ -9,13 +13,14 @@ import {
9
13
  useParams,
10
14
  } from 'react-router';
11
15
  import type { ColumnDef } from '@tanstack/react-table';
12
- import { MoreHorizontal, RefreshCw } from 'lucide-react';
16
+ import { MoreHorizontal } from 'lucide-react';
13
17
  import { RouteChildPage } from '#components/route-child-page';
14
18
  import { BackButton } from '#components/back-button';
15
19
  import { PageContainer } from '#components/page-container';
16
20
  import { PageHeader } from '#components/page-header';
17
21
  import { LongText } from '#components/long-text';
18
22
  import { DataTable } from '#components/data-table';
23
+ import { RefreshIndicator } from '#components/loading';
19
24
  import { RecordLink } from '#components/record-link';
20
25
  import { StatusBadge } from '#components/status-badge';
21
26
  import { Button } from '#components/ui/button';
@@ -83,6 +88,14 @@ export default function CustomerDetailPage() {
83
88
  headingRef.current?.focus();
84
89
  }, [active, request.loading]);
85
90
  const customer = request.data?.data;
91
+ const contactState = resolveListState(
92
+ {
93
+ data: contacts.data,
94
+ error: contacts.error,
95
+ isPending: contacts.loading && !contacts.data,
96
+ },
97
+ contacts.data?.data.length ?? 0,
98
+ );
86
99
  const writable = customer && customer.status !== 'closed';
87
100
  const reload = () => {
88
101
  request.reload();
@@ -206,14 +219,6 @@ export default function CustomerDetailPage() {
206
219
  {t('customerContacts.edit')}
207
220
  </Button>
208
221
  )}
209
- <Button
210
- variant='outline'
211
- disabled={request.loading}
212
- onClick={reload}
213
- >
214
- <RefreshCw />
215
- {t('customerContacts.refresh')}
216
- </Button>
217
222
  </>
218
223
  )
219
224
  }
@@ -224,28 +229,35 @@ export default function CustomerDetailPage() {
224
229
  ) : (
225
230
  customer && (
226
231
  <>
227
- <dl className='grid grid-cols-[8rem_1fr] gap-4 text-sm'>
228
- <dt className='text-muted-foreground'>
229
- {t('customerContacts.status')}
230
- </dt>
231
- <dd>
232
- <StatusBadge>
233
- {t(`customerContacts.${customer.status}`)}
234
- </StatusBadge>
235
- </dd>
236
- <dt className='text-muted-foreground'>
237
- {t('customerContacts.owner')}
238
- </dt>
239
- <dd>
240
- <OwnerName id={customer.ownerId} />
241
- </dd>
242
- <dt className='text-muted-foreground'>
243
- {t('customerContacts.notes')}
244
- </dt>
245
- <dd className='min-w-0 whitespace-pre-wrap break-words'>
246
- <LongText>{customer.notes || '—'}</LongText>
247
- </dd>
248
- </dl>
232
+ {/* The summary and the contacts table refresh independently; each owns its feedback. */}
233
+ <div className='relative'>
234
+ <RefreshIndicator pending={active && request.loading} />
235
+ <dl
236
+ className='grid grid-cols-[8rem_1fr] gap-4 text-sm'
237
+ aria-busy={active && request.loading}
238
+ >
239
+ <dt className='text-muted-foreground'>
240
+ {t('customerContacts.status')}
241
+ </dt>
242
+ <dd>
243
+ <StatusBadge>
244
+ {t(`customerContacts.${customer.status}`)}
245
+ </StatusBadge>
246
+ </dd>
247
+ <dt className='text-muted-foreground'>
248
+ {t('customerContacts.owner')}
249
+ </dt>
250
+ <dd>
251
+ <OwnerName id={customer.ownerId} />
252
+ </dd>
253
+ <dt className='text-muted-foreground'>
254
+ {t('customerContacts.notes')}
255
+ </dt>
256
+ <dd className='min-w-0 whitespace-pre-wrap break-words'>
257
+ <LongText>{customer.notes || '—'}</LongText>
258
+ </dd>
259
+ </dl>
260
+ </div>
249
261
  {!writable && (
250
262
  <p className='text-sm text-muted-foreground'>
251
263
  {t('customerContacts.readOnly')}
@@ -272,29 +284,28 @@ export default function CustomerDetailPage() {
272
284
  </Button>
273
285
  )}
274
286
  </div>
275
- {contacts.error ? (
276
- <ReadFeedback error={contacts.error} retry={contacts.reload} />
277
- ) : (
278
- <DataTable
279
- columns={columns}
280
- data={contacts.data?.data ?? []}
281
- manualPagination
282
- rowCount={contacts.data?.meta.total ?? 0}
283
- paginationState={{ pageIndex: page, pageSize: 10 }}
284
- onPaginationChange={(update) =>
285
- setPage(
286
- (old) =>
287
- (typeof update === 'function'
288
- ? update({ pageIndex: old, pageSize: 10 })
289
- : update
290
- ).pageIndex,
291
- )
292
- }
293
- pageSizeOptions={[10]}
294
- showSelectedCount={false}
295
- loading={contacts.loading}
296
- />
297
- )}
287
+ <DataTable
288
+ columns={columns}
289
+ data={contacts.data?.data ?? []}
290
+ manualPagination
291
+ rowCount={contacts.data?.meta.total ?? 0}
292
+ paginationState={{ pageIndex: page, pageSize: 10 }}
293
+ onPaginationChange={(update) =>
294
+ setPage(
295
+ (old) =>
296
+ (typeof update === 'function'
297
+ ? update({ pageIndex: old, pageSize: 10 })
298
+ : update
299
+ ).pageIndex,
300
+ )
301
+ }
302
+ pageSizeOptions={[10]}
303
+ showSelectedCount={false}
304
+ loading={active && contacts.loading}
305
+ loadingIdentity={contacts.path}
306
+ listState={contactState}
307
+ onRetry={contacts.reload}
308
+ />
298
309
  </>
299
310
  )
300
311
  )}
@@ -1,10 +1,9 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import { useAuthentication } from '@nocobase/app-plugin-authentication/client';
3
3
  import {
4
+ resolveListState,
4
5
  useApiClient,
5
6
  useToaster,
6
- ApiClientError,
7
- type ListState,
8
7
  } from '@nocobase/app-client';
9
8
  import {
10
9
  useCan,
@@ -14,7 +13,6 @@ import { useTranslation } from '@nocobase/i18n/client';
14
13
  import { useEffect, useRef, useState } from 'react';
15
14
  import { Link, Outlet, useLocation } from 'react-router';
16
15
  import type { ColumnDef } from '@tanstack/react-table';
17
- import { RefreshCw } from 'lucide-react';
18
16
  import { DataTable } from '#components/data-table';
19
17
  import { PageContainer } from '#components/page-container';
20
18
  import { PageHeader } from '#components/page-header';
@@ -193,23 +191,15 @@ function CustomerContactsContent() {
193
191
  cell: ({ row }) => <OwnerName id={row.original.ownerId} />,
194
192
  },
195
193
  ];
196
- const state: ListState = request.error
197
- ? request.error instanceof ApiClientError && request.error.status === 403
198
- ? 'forbidden'
199
- : request.error instanceof ApiClientError && request.error.status === 401
200
- ? 'unauthenticated'
201
- : rows.length
202
- ? 'refresh-failed'
203
- : 'failed'
204
- : request.loading
205
- ? rows.length
206
- ? 'ready'
207
- : 'loading'
208
- : rows.length
209
- ? 'ready'
210
- : search || status !== 'all' || owner
211
- ? 'no-results'
212
- : 'empty';
194
+ const state = resolveListState(
195
+ {
196
+ data: currentData,
197
+ error: request.error,
198
+ isPending: request.loading && !currentData,
199
+ },
200
+ rows.length,
201
+ Boolean(search || status !== 'all' || owner),
202
+ );
213
203
  const reload = () => {
214
204
  setSelection({ key: '', ids: [] });
215
205
  request.reload();
@@ -259,15 +249,6 @@ function CustomerContactsContent() {
259
249
  {t('customerContacts.reset')}
260
250
  </Button>
261
251
  )}
262
- <Button
263
- variant='outline'
264
- onClick={reload}
265
- disabled={request.loading}
266
- aria-label={t('customerContacts.refresh')}
267
- >
268
- <RefreshCw className={request.loading ? 'animate-spin' : ''} />
269
- {t('customerContacts.refresh')}
270
- </Button>
271
252
  </>
272
253
  }
273
254
  />
@@ -339,6 +320,7 @@ function CustomerContactsContent() {
339
320
  showSelectedCount={false}
340
321
  listState={state}
341
322
  loading={active && request.loading}
323
+ loadingIdentity={path}
342
324
  onRetry={reload}
343
325
  />
344
326
  <AlertDialog
@@ -1,5 +1,4 @@
1
1
  export const enUS = {
2
- refresh: 'Refresh',
3
2
  signIn: 'Sign in',
4
3
  title: 'Customers and contacts',
5
4
  description:
@@ -77,7 +76,6 @@ export const enUS = {
77
76
  invalid: 'Check the highlighted fields.',
78
77
  };
79
78
  export const zhCN: Record<keyof typeof enUS, string> = {
80
- refresh: '刷新',
81
79
  signIn: '登录',
82
80
  title: '客户与联系人',
83
81
  description: '练习按权限选择关联记录和批量修改当前页客户。',
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useId, useRef, useState, type Ref } from 'react';
2
- import { useApiClient } from '@nocobase/app-client';
2
+ import { useApiClient, usePendingFeedback } from '@nocobase/app-client';
3
3
  import { useTranslation } from '@nocobase/i18n/client';
4
4
  import { useAuthorizationRevision } from '@nocobase/app-plugin-authorization/client';
5
5
  import { useInfiniteQuery } from '@tanstack/react-query';
@@ -16,7 +16,8 @@ import {
16
16
  PopoverContent,
17
17
  PopoverTrigger,
18
18
  } from '#components/ui/popover';
19
- import { Spinner } from '#components/ui/spinner';
19
+ import { Loading } from '#components/loading';
20
+ import { BrandLoadingMark } from '#components/brand-loading-mark';
20
21
  import { ToggleGroup, ToggleGroupItem } from '#components/ui/toggle-group';
21
22
  import { useListData } from '#hooks/use-list-data';
22
23
  import { ReadFeedback } from './shared.js';
@@ -95,9 +96,14 @@ function Picker({
95
96
  isFetchNextPageError,
96
97
  fetchNextPage,
97
98
  } = options;
99
+ // The application keeps previous query data as a placeholder; those options
100
+ // belong to the previous search or filter and must not appear as matches.
101
+ const current = !options.isPlaceholderData;
102
+ // A new search or filter restarts the display delay of its own wait.
103
+ const queryIdentity = JSON.stringify([search, filter ?? null]);
98
104
  const items = [
99
105
  ...new Map(
100
- (options.data?.pages ?? [])
106
+ ((current && options.data?.pages) || [])
101
107
  .flatMap((page) => page.data)
102
108
  .map((option) => [option.id, option]),
103
109
  ).values(),
@@ -212,16 +218,13 @@ function Picker({
212
218
  </ToggleGroup>
213
219
  )}
214
220
  </div>
215
- <div
216
- ref={listRef}
217
- className='min-h-0 flex-1 overflow-y-auto p-1'
218
- aria-live='polite'
219
- aria-busy={options.isFetching}
220
- >
221
- {options.isPending ? (
222
- <div className='flex justify-center py-6'>
223
- <Spinner className='text-muted-foreground' />
224
- </div>
221
+ <div ref={listRef} className='min-h-0 flex-1 overflow-y-auto p-1'>
222
+ {options.isPending || !current ? (
223
+ <Loading
224
+ identity={queryIdentity}
225
+ label={t('customerContacts.loading')}
226
+ className='py-6'
227
+ />
225
228
  ) : options.isError && !isFetchNextPageError ? (
226
229
  <div className='p-1'>
227
230
  <ReadFeedback
@@ -258,11 +261,11 @@ function Picker({
258
261
  />
259
262
  </div>
260
263
  ) : hasNextPage ? (
261
- <div ref={endRef} className='flex justify-center py-2'>
262
- {isFetchingNextPage && (
263
- <Spinner className='size-4 text-muted-foreground' />
264
- )}
265
- </div>
264
+ <NextPagePending
265
+ ref={endRef}
266
+ pending={isFetchingNextPage}
267
+ identity={queryIdentity}
268
+ />
266
269
  ) : null}
267
270
  </div>
268
271
  ) : (
@@ -279,3 +282,50 @@ function Picker({
279
282
  </Popover>
280
283
  );
281
284
  }
285
+
286
+ /**
287
+ * The next page appends below kept options. Its mark follows the shared
288
+ * display delay and a slow page explains itself; the polite status stays
289
+ * mounted outside the busy row so the change is announced, not dropped.
290
+ */
291
+ function NextPagePending({
292
+ pending,
293
+ identity,
294
+ ref,
295
+ }: {
296
+ pending: boolean;
297
+ identity: unknown;
298
+ ref: Ref<HTMLDivElement>;
299
+ }) {
300
+ const { t } = useTranslation();
301
+ const feedback = usePendingFeedback(pending, identity);
302
+ const message = feedback.longWaiting
303
+ ? t('pendingFeedback.longWait')
304
+ : t('customerContacts.loading');
305
+ return (
306
+ <>
307
+ <div
308
+ ref={ref}
309
+ aria-busy={pending}
310
+ className='flex min-h-8 flex-col items-center justify-center gap-1 py-2'
311
+ >
312
+ {feedback.visible ? (
313
+ <>
314
+ <BrandLoadingMark className='size-4 text-muted-foreground' />
315
+ {feedback.longWaiting ? (
316
+ <span
317
+ aria-hidden='true'
318
+ className='text-xs text-muted-foreground'
319
+ >
320
+ {message}
321
+ </span>
322
+ ) : null}
323
+ </>
324
+ ) : null}
325
+ </div>
326
+ <span role='status' aria-live='polite' className='sr-only'>
327
+ {feedback.visible ? message : ''}
328
+ </span>
329
+ </>
330
+ );
331
+ }
@@ -1,6 +1,7 @@
1
- import { ApiClientError } from '@nocobase/app-client';
1
+ import { ApiClientError, usePendingFeedback } from '@nocobase/app-client';
2
2
  import { useTranslation } from '@nocobase/i18n/client';
3
3
  import type { ReactNode } from 'react';
4
+ import { cn } from 'cn';
4
5
  import { Link } from 'react-router';
5
6
  import { Alert, AlertDescription } from '#components/ui/alert';
6
7
  import { Button } from '#components/ui/button';
@@ -21,17 +22,7 @@ export function ReadFeedback({
21
22
  retry: () => void;
22
23
  }) {
23
24
  const { t } = useTranslation();
24
- if (!error)
25
- return (
26
- <div
27
- role='status'
28
- aria-label={t('customerContacts.loading')}
29
- className='flex flex-col gap-4'
30
- >
31
- <Skeleton className='h-8 w-full' />
32
- <Skeleton className='h-8 w-full' />
33
- </div>
34
- );
25
+ if (!error) return <ReadPending />;
35
26
  const status = error instanceof ApiClientError ? error.status : 0;
36
27
  return (
37
28
  <Alert variant='destructive'>
@@ -54,6 +45,35 @@ export function ReadFeedback({
54
45
  </Alert>
55
46
  );
56
47
  }
48
+ /** Skeleton rows keep the read's footprint at once and appear only after the shared display delay. */
49
+ function ReadPending() {
50
+ const { t } = useTranslation();
51
+ const feedback = usePendingFeedback(true);
52
+ const message = feedback.longWaiting
53
+ ? t('pendingFeedback.longWait')
54
+ : t('customerContacts.loading');
55
+ return (
56
+ <>
57
+ <div
58
+ aria-busy='true'
59
+ className={cn('flex flex-col gap-4', !feedback.visible && 'invisible')}
60
+ >
61
+ <Skeleton aria-hidden='true' className='h-8 w-full' />
62
+ <Skeleton aria-hidden='true' className='h-8 w-full' />
63
+ </div>
64
+ {feedback.visible && (
65
+ <span
66
+ role='status'
67
+ aria-live='polite'
68
+ aria-label={message}
69
+ className='sr-only'
70
+ >
71
+ {message}
72
+ </span>
73
+ )}
74
+ </>
75
+ );
76
+ }
57
77
  export function WriteFeedback({ error }: { error?: unknown }) {
58
78
  const { t } = useTranslation();
59
79
  if (!error) return null;