@asteby/metacore-runtime-react 50.2.0 → 52.0.0

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 (58) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +26 -0
  3. package/dist/activity-diff.d.ts +5 -0
  4. package/dist/activity-diff.d.ts.map +1 -1
  5. package/dist/activity-timeline.d.ts.map +1 -1
  6. package/dist/activity-timeline.js +10 -3
  7. package/dist/audit-info.d.ts.map +1 -1
  8. package/dist/audit-info.js +17 -3
  9. package/dist/barcode-scanner.js +4 -4
  10. package/dist/dialogs/dynamic-record.d.ts +3 -1
  11. package/dist/dialogs/dynamic-record.d.ts.map +1 -1
  12. package/dist/dialogs/dynamic-record.js +19 -6
  13. package/dist/dynamic-columns.d.ts +6 -0
  14. package/dist/dynamic-columns.d.ts.map +1 -1
  15. package/dist/dynamic-columns.js +41 -7
  16. package/dist/dynamic-date-field.js +1 -1
  17. package/dist/dynamic-form.js +2 -2
  18. package/dist/dynamic-kanban.js +6 -5
  19. package/dist/dynamic-table.d.ts.map +1 -1
  20. package/dist/dynamic-table.js +6 -4
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +2 -1
  24. package/dist/org-runtime-context.d.ts +65 -0
  25. package/dist/org-runtime-context.d.ts.map +1 -1
  26. package/dist/org-runtime-context.js +24 -0
  27. package/dist/org-runtime-provider.d.ts +25 -1
  28. package/dist/org-runtime-provider.d.ts.map +1 -1
  29. package/dist/org-runtime-provider.js +3 -3
  30. package/dist/provenance.d.ts +216 -0
  31. package/dist/provenance.d.ts.map +1 -0
  32. package/dist/provenance.js +386 -0
  33. package/dist/record-history.d.ts.map +1 -1
  34. package/dist/record-history.js +6 -2
  35. package/dist/sidebar-layout-manager.js +2 -2
  36. package/dist/widgets/widget-card.d.ts +7 -2
  37. package/dist/widgets/widget-card.d.ts.map +1 -1
  38. package/dist/widgets/widget-card.js +6 -3
  39. package/package.json +3 -3
  40. package/src/__tests__/org-runtime-number-locale-system-actor.test.tsx +80 -0
  41. package/src/__tests__/provenance.test.tsx +209 -0
  42. package/src/activity-diff.tsx +5 -0
  43. package/src/activity-timeline.tsx +16 -2
  44. package/src/audit-info.tsx +20 -3
  45. package/src/barcode-scanner.tsx +4 -4
  46. package/src/dialogs/dynamic-record.tsx +26 -5
  47. package/src/dynamic-columns.tsx +68 -6
  48. package/src/dynamic-date-field.tsx +1 -1
  49. package/src/dynamic-form.tsx +2 -2
  50. package/src/dynamic-kanban.tsx +6 -5
  51. package/src/dynamic-table.tsx +6 -4
  52. package/src/index.ts +2 -0
  53. package/src/org-runtime-context.ts +92 -0
  54. package/src/org-runtime-provider.tsx +50 -3
  55. package/src/provenance.tsx +585 -0
  56. package/src/record-history.tsx +17 -4
  57. package/src/sidebar-layout-manager.tsx +2 -2
  58. package/src/widgets/widget-card.tsx +26 -3
@@ -0,0 +1,209 @@
1
+ // @vitest-environment happy-dom
2
+ // Provenance badges: human, agent (Gobi), system/integration with origin and
3
+ // "person with agent" with the authorizer, the proposal and the date.
4
+ import { afterEach, describe, expect, it, vi } from 'vitest'
5
+ import { cleanup, render, screen } from '@testing-library/react'
6
+ import type { ReactNode } from 'react'
7
+
8
+ let language = 'es'
9
+ vi.mock('react-i18next', () => {
10
+ const t = (k: string, o?: Record<string, string>) =>
11
+ (o?.defaultValue ?? k).replace(/\{\{(\w+)\}\}/g, (_: string, v: string) => o?.[v] ?? '')
12
+ return { useTranslation: () => ({ t, i18n: { language } }) }
13
+ })
14
+
15
+ import { OrgRuntimeProvider } from '../org-runtime-provider'
16
+ import {
17
+ AuthorshipCell,
18
+ classifyProvenance,
19
+ hasSpecialAuthorship,
20
+ isSystemCreated,
21
+ notificationProvenance,
22
+ parseProvenance,
23
+ ProvenanceActorChip,
24
+ ProvenanceBadge,
25
+ readProvenance,
26
+ type ProvenanceData,
27
+ } from '../provenance'
28
+ import { AuditInfo } from '../audit-info'
29
+
30
+ afterEach(() => {
31
+ cleanup()
32
+ language = 'es'
33
+ })
34
+
35
+ const gobi = { name: 'Gobi', avatarUrl: '/images/gobi.svg' }
36
+ const wrap = (ui: ReactNode, extra: Record<string, unknown> = {}) =>
37
+ render(
38
+ <OrgRuntimeProvider agentActor={gobi} timeZone="America/Mexico_City" {...extra}>
39
+ {ui}
40
+ </OrgRuntimeProvider>,
41
+ )
42
+
43
+ const assisted: ProvenanceData = {
44
+ actor_kind: 'agent',
45
+ actor_name: 'Gobi',
46
+ mode: 'assisted',
47
+ authorized_by: 'u-1',
48
+ authorized_by_name: 'Ana Pérez',
49
+ authorized_at: '2026-10-12T16:30:00Z',
50
+ via: 'chat',
51
+ origin: 'Borrador aprobado en el chat',
52
+ summary: 'Propuso crear la acción «Recorrido en Tecomán»',
53
+ }
54
+
55
+ describe('provenance model', () => {
56
+ it('classifies the four presentations', () => {
57
+ expect(classifyProvenance({ actor_kind: 'human', mode: 'manual' })).toBe('human')
58
+ expect(classifyProvenance(assisted)).toBe('assisted')
59
+ expect(classifyProvenance({ actor_kind: 'agent', mode: 'automated', on_behalf_of: 'u-1' })).toBe('agent')
60
+ expect(classifyProvenance({ actor_kind: 'agent', mode: 'automated', proposed: true })).toBe('agent')
61
+ expect(classifyProvenance({ actor_kind: 'system', mode: 'automated' })).toBe('system')
62
+ expect(classifyProvenance({ actor_kind: 'integration', mode: 'automated' })).toBe('system')
63
+ })
64
+
65
+ it('reads provenance from created_by, the row or JSON strings', () => {
66
+ expect(readProvenance({ created_by: { name: 'Ana', provenance: assisted } })?.mode).toBe('assisted')
67
+ expect(readProvenance({ provenance: JSON.stringify(assisted) })?.actor_kind).toBe('agent')
68
+ expect(readProvenance({ provenance: { actor_kind: 'robot' } })).toBeUndefined()
69
+ expect(parseProvenance('{bad')).toBeUndefined()
70
+ expect(notificationProvenance({ metadata: JSON.stringify({ provenance: { actor_kind: 'agent' } }) })?.actor_kind).toBe('agent')
71
+ })
72
+
73
+ it('legacy system rows: null, nil and the kernel actor', () => {
74
+ expect(isSystemCreated({ created_by_id: null })).toBe(true)
75
+ expect(isSystemCreated({ created_by_id: '00000000-0000-0000-0000-000000000001' })).toBe(true)
76
+ expect(isSystemCreated({ created_by_id: 'abc', created_by: { name: 'Ana' } })).toBe(false)
77
+ expect(hasSpecialAuthorship({ created_by_id: 'abc', created_by: { name: 'Ana' } })).toBe(false)
78
+ expect(hasSpecialAuthorship({ created_by: { name: 'Ana', provenance: assisted } })).toBe(true)
79
+ })
80
+ })
81
+
82
+ describe('<ProvenanceBadge>', () => {
83
+ it('person with agent: label, overlay avatar and accessible description', () => {
84
+ const { container } = wrap(<ProvenanceBadge provenance={assisted} />)
85
+ expect(screen.getByText('Ana Pérez con Gobi')).toBeTruthy()
86
+ expect(screen.getByText('Borrador aprobado en el chat')).toBeTruthy()
87
+ const trigger = container.querySelector('[data-provenance="assisted"]') as HTMLElement
88
+ expect(trigger.tabIndex).toBe(0)
89
+ const desc = document.getElementById(trigger.getAttribute('aria-describedby') as string)
90
+ expect(desc?.textContent).toContain('Autorizó: Ana Pérez')
91
+ expect(desc?.textContent).toContain('Gobi propuso: Propuso crear la acción')
92
+ expect(desc?.textContent).toMatch(/12 oct 2026/)
93
+ expect(container.querySelector('[data-provenance-overlay] img[src="/images/gobi.svg"]')).toBeTruthy()
94
+ })
95
+
96
+ it('agent alone uses the app agent and its origin; pending proposals say so', () => {
97
+ const { rerender } = wrap(<ProvenanceBadge provenance={{ actor_kind: 'agent', mode: 'automated', origin: 'Briefing automático' }} />)
98
+ expect(screen.getByText('Gobi')).toBeTruthy()
99
+ expect(screen.getByText('Briefing automático')).toBeTruthy()
100
+ rerender(
101
+ <OrgRuntimeProvider agentActor={gobi}>
102
+ <ProvenanceBadge provenance={{ actor_kind: 'agent', mode: 'automated', proposed: true, via: 'chat' }} />
103
+ </OrgRuntimeProvider>,
104
+ )
105
+ expect(screen.getByText('Propuesta pendiente')).toBeTruthy()
106
+ })
107
+
108
+ it('system and integration show their origin, never the agent', () => {
109
+ const { container } = wrap(
110
+ <>
111
+ <ProvenanceBadge provenance={{ actor_kind: 'system', mode: 'automated', via: 'seed' }} />
112
+ <ProvenanceBadge provenance={{ actor_kind: 'integration', actor_name: 'gobiernos-intel', mode: 'automated', origin: 'Plano de datos' }} />
113
+ </>,
114
+ )
115
+ expect(screen.getByText('Sistema')).toBeTruthy()
116
+ expect(screen.getByText('Datos iniciales')).toBeTruthy()
117
+ expect(screen.getByText('gobiernos-intel')).toBeTruthy()
118
+ expect(screen.getByText('Plano de datos')).toBeTruthy()
119
+ expect(container.querySelectorAll('[data-provenance="system"]').length).toBe(2)
120
+ expect(screen.queryByText('Gobi')).toBeNull()
121
+ })
122
+
123
+ it('human alone', () => {
124
+ wrap(<ProvenanceBadge provenance={{ actor_kind: 'human', mode: 'manual', actor_person_name: 'Luis Gómez' }} />)
125
+ expect(screen.getByText('Luis Gómez')).toBeTruthy()
126
+ })
127
+
128
+ it('English copy', () => {
129
+ language = 'en'
130
+ wrap(<ProvenanceBadge provenance={assisted} />)
131
+ expect(screen.getByText('Ana Pérez with Gobi')).toBeTruthy()
132
+ })
133
+
134
+ it('without agentActor falls back to the stored agent name', () => {
135
+ render(<ProvenanceBadge provenance={{ ...assisted, actor_name: 'Llantonio' }} />)
136
+ expect(screen.getByText('Ana Pérez con Llantonio')).toBeTruthy()
137
+ })
138
+ })
139
+
140
+ describe('<AuthorshipCell>', () => {
141
+ it('legacy system row gets the host origin', () => {
142
+ const origin = vi.fn(() => 'Importación de investigación pública')
143
+ wrap(<AuthorshipCell row={{ id: 'r', created_by_id: null }} model="findings" />, { provenanceOrigin: origin, systemActor: { name: 'Sistema' } })
144
+ expect(origin).toHaveBeenCalledWith('findings', { id: 'r', created_by_id: null })
145
+ expect(screen.getByText('Importación de investigación pública')).toBeTruthy()
146
+ })
147
+
148
+ it('stored provenance wins over the legacy rule', () => {
149
+ wrap(<AuthorshipCell row={{ created_by_id: 'u-1', created_by: { name: 'Ana Pérez', provenance: assisted } }} />)
150
+ expect(screen.getByText('Ana Pérez con Gobi')).toBeTruthy()
151
+ })
152
+
153
+ it('a plain person renders the person', () => {
154
+ wrap(<AuthorshipCell row={{ created_by_id: 'u-2', created_by: { name: 'Luis' } }} variant="inline" />)
155
+ expect(screen.getByText('Luis')).toBeTruthy()
156
+ })
157
+ })
158
+
159
+ describe('history and audit', () => {
160
+ it('ProvenanceActorChip names the actor with the full sentence for screen readers', () => {
161
+ wrap(<ProvenanceActorChip provenance={assisted} />)
162
+ expect(screen.getByText('Ana Pérez con Gobi')).toBeTruthy()
163
+ expect(screen.getByText(/Autorizó: Ana Pérez/)).toBeTruthy()
164
+ })
165
+
166
+ it('AuditInfo "Creado por" uses the provenance label', () => {
167
+ wrap(
168
+ <AuditInfo
169
+ defaultOpen
170
+ record={{ created_at: '2026-10-12T16:30:00Z', created_by_id: 'u-1', created_by: { name: 'Ana Pérez', provenance: assisted } }}
171
+ audit={{ created_at: 'created_at', created_by: 'created_by_id' }}
172
+ />,
173
+ )
174
+ expect(screen.getByText('Creado por Ana Pérez con Gobi')).toBeTruthy()
175
+ })
176
+ })
177
+
178
+ describe('dynamic table created_by column', () => {
179
+ it('renders the provenance badge by default', async () => {
180
+ const { defaultGetDynamicColumns } = await import('../dynamic-columns')
181
+ const cols = defaultGetDynamicColumns(
182
+ {
183
+ title: 'Acciones',
184
+ endpoint: '/data/actions',
185
+ columns: [{ key: 'created_by.avatar', label: 'Creado por', type: 'avatar', tooltip: 'created_by.name' }],
186
+ actions: [],
187
+ perPageOptions: [10],
188
+ defaultPerPage: 10,
189
+ searchPlaceholder: '',
190
+ enableCRUDActions: false,
191
+ hasActions: false,
192
+ } as never,
193
+ () => {},
194
+ (k: string, o?: { defaultValue?: string }) => o?.defaultValue ?? k,
195
+ 'es',
196
+ new Map(),
197
+ )
198
+ const col = cols.find((c) => (c as { accessorKey?: string }).accessorKey === 'created_by.avatar' || c.id === 'created_by.avatar')
199
+ expect(col).toBeTruthy()
200
+ const original = { id: 'r1', created_by_id: 'u-1', created_by: { name: 'Ana Pérez', provenance: assisted } }
201
+ const cell = (col!.cell as (ctx: unknown) => ReactNode)({
202
+ row: { original, getValue: () => undefined },
203
+ getValue: () => undefined,
204
+ column: { id: 'created_by.avatar' },
205
+ })
206
+ wrap(<>{cell}</>)
207
+ expect(screen.getByText('Ana Pérez con Gobi')).toBeTruthy()
208
+ })
209
+ })
@@ -35,6 +35,11 @@ export interface ActivityEvent {
35
35
  correlation_id?: string | null
36
36
  actor_id?: string | null
37
37
  actor_label?: string | null
38
+ /**
39
+ * Provenance of the change (kernel `provenance`, JSON string or object):
40
+ * person, agent, system or integration, and the mode. Optional.
41
+ */
42
+ provenance?: unknown
38
43
  /** Storage path of the actor's avatar image, when the backend resolves one. */
39
44
  actor_avatar?: string | null
40
45
  addon_key: string
@@ -14,6 +14,8 @@
14
14
  */
15
15
 
16
16
  import * as React from 'react'
17
+ import { useSystemActor } from './org-runtime-context'
18
+ import { parseProvenance, ProvenanceAvatar, useResolvedAuthorship } from './provenance'
17
19
  import { formatDistanceToNow } from 'date-fns'
18
20
  import { es, enUS } from 'date-fns/locale'
19
21
  import type { Locale } from 'date-fns'
@@ -201,7 +203,12 @@ const GroupCard: React.FC<GroupCardProps> = ({
201
203
  }) => {
202
204
  const { root, events, changedFieldCount } = group
203
205
  const isMulti = events.length > 1
204
- const actor = root.actor_label || root.actor_id || 'Sistema'
206
+ const systemName = useSystemActor()?.name || 'Sistema'
207
+ const authorship = useResolvedAuthorship({
208
+ provenance: parseProvenance(root.provenance),
209
+ person: root.actor_label ? { name: root.actor_label } : undefined,
210
+ })
211
+ const actor = authorship?.label || root.actor_label || root.actor_id || systemName
205
212
  const dotColor = actionDotColor(root.action)
206
213
 
207
214
  const timeAgo = (() => {
@@ -245,11 +252,18 @@ const GroupCard: React.FC<GroupCardProps> = ({
245
252
  type="button"
246
253
  className="w-full flex items-start gap-3 px-4 py-3 text-left hover:bg-muted/30 transition-colors"
247
254
  >
255
+ {authorship ? (
256
+ <span className="mt-0.5 shrink-0" title={authorship.description}>
257
+ <ProvenanceAvatar authorship={authorship} size="sm" />
258
+ <span className="sr-only">{authorship.description}</span>
259
+ </span>
260
+ ) : (
248
261
  <Avatar className="h-7 w-7 rounded-full shrink-0 mt-0.5">
249
262
  <AvatarFallback className="text-[9px] font-bold bg-primary/10 text-primary">
250
263
  {getInitials(actor)}
251
264
  </AvatarFallback>
252
265
  </Avatar>
266
+ )}
253
267
 
254
268
  <div className="flex-1 min-w-0">
255
269
  {/* Summary line */}
@@ -294,7 +308,7 @@ const GroupCard: React.FC<GroupCardProps> = ({
294
308
  <div className="border-t border-border/40 divide-y divide-border/30">
295
309
  {events.map((ev, idx) => {
296
310
  const cols = resolveColumns(ev.model)
297
- const evActor = ev.actor_label || ev.actor_id || 'Sistema'
311
+ const evActor = ev.actor_label || ev.actor_id || systemName
298
312
  return (
299
313
  <div key={ev.id} className="px-4 py-3 space-y-2">
300
314
  {/* Show sub-actor + model when group has multiple events */}
@@ -24,7 +24,8 @@ import { cn } from '@asteby/metacore-ui/lib'
24
24
  import { formatDateCell } from './dynamic-columns'
25
25
  import { objectLabel } from './dynamic-relation-helpers'
26
26
  import { isNilUuid } from './nil-uuid'
27
- import { useTimeZone } from './org-runtime-context'
27
+ import { useSystemActor, useTimeZone } from './org-runtime-context'
28
+ import { readProvenance, useResolvedAuthorship } from './provenance'
28
29
  import type { AuditMeta } from './types'
29
30
 
30
31
  /** The kernel's actor for unattended work (schedules, webhooks, connectors). */
@@ -129,6 +130,8 @@ export interface AuditInfoProps {
129
130
  interface Line {
130
131
  key: string
131
132
  text: string
133
+ /** Full provenance sentence (who authorized, what the agent proposed). */
134
+ detail?: string
132
135
  absolute: string
133
136
  title?: string
134
137
  relative: string
@@ -145,7 +148,10 @@ export function AuditInfo({
145
148
  }: AuditInfoProps) {
146
149
  const { t, i18n } = useTranslation()
147
150
  const ctxTz = useTimeZone()
151
+ const systemActor = useSystemActor()
148
152
  const [open, setOpen] = React.useState(defaultOpen)
153
+ // Stored creation provenance (person with agent, agent, system, integration).
154
+ const authorship = useResolvedAuthorship({ provenance: readProvenance(record ?? undefined) })
149
155
 
150
156
  const meta = readAuditMeta(audit)
151
157
  if (!meta || !record) return null
@@ -166,9 +172,19 @@ export function AuditInfo({
166
172
  ): Line | null => {
167
173
  const f = atCol ? formatDateCell(record[atCol], undefined, dfLocale, tz) : null
168
174
  if (!f) return null
169
- const actor = resolveAuditActor(record, byCol, { resolveActor, systemLabel: tt('system') })
175
+ const actor = resolveAuditActor(record, byCol, { resolveActor, systemLabel: systemActor?.name || tt('system') })
170
176
  const date = new Date(record[atCol as string] as string)
171
177
  const relative = formatDistanceToNow(date, { addSuffix: true, locale: dfLocale })
178
+ if (key === 'created' && authorship) {
179
+ return {
180
+ key,
181
+ text: tt(whoKey, { who: authorship.label }),
182
+ detail: authorship.description,
183
+ absolute: f.display,
184
+ title: f.title,
185
+ relative,
186
+ }
187
+ }
172
188
  return {
173
189
  key,
174
190
  text: actor ? tt(whoKey, { who: actor.name }) : tt(whenKey),
@@ -206,7 +222,8 @@ export function AuditInfo({
206
222
  <ul className="mt-2 space-y-1 pl-6">
207
223
  {lines.map(l => (
208
224
  <li key={l.key} data-audit-line={l.key}>
209
- <span>{l.text}</span>
225
+ <span title={l.detail}>{l.text}</span>
226
+ {l.detail ? <span className="sr-only"> ({l.detail})</span> : null}
210
227
  {' · '}
211
228
  <time title={l.title}>{l.absolute}</time>
212
229
  <span className="opacity-70"> ({l.relative})</span>
@@ -175,7 +175,7 @@ export function BarcodeScanner({
175
175
  continuous = true,
176
176
  beepOnScan = true,
177
177
  title = 'Escanear código',
178
- hint = 'Apuntá al código de barras',
178
+ hint = 'Apunta al código de barras',
179
179
  position = 'absolute',
180
180
  feedback = null,
181
181
  }: BarcodeScannerProps) {
@@ -220,7 +220,7 @@ export function BarcodeScanner({
220
220
  const Ctor = getDetectorCtor()
221
221
  if (!navigator.mediaDevices?.getUserMedia || !Ctor) {
222
222
  setError(
223
- 'Tu navegador no soporta escaneo por cámara. Usá un lector físico (escribe en el campo) o escribí el código a mano.',
223
+ 'Tu navegador no soporta escaneo por cámara. Usa un lector físico (escribe en el campo) o escribe el código a mano.',
224
224
  )
225
225
  return
226
226
  }
@@ -281,7 +281,7 @@ export function BarcodeScanner({
281
281
  setError(
282
282
  name === 'NotAllowedError'
283
283
  ? 'Permiso de cámara denegado. Habilitalo en el navegador para escanear.'
284
- : 'No se pudo abrir la cámara. Usá un lector físico o escribí el código a mano.',
284
+ : 'No se pudo abrir la cámara. Usa un lector físico o escribe el código a mano.',
285
285
  )
286
286
  }
287
287
  })()
@@ -384,7 +384,7 @@ export function BarcodeScanner({
384
384
  {!ready
385
385
  ? 'Abriendo cámara…'
386
386
  : torchAvailable
387
- ? `${hint} · tocá la linterna si está oscuro`
387
+ ? `${hint} · toca la linterna si está oscuro`
388
388
  : hint}
389
389
  </p>
390
390
  </>
@@ -88,7 +88,8 @@ import { CollectionCell, type ItemField } from '../collection-cell'
88
88
  import type { ActionFieldDef, RelationMeta } from '../types'
89
89
  import { ImageUrlContext, identityImageUrl, type GetImageUrl } from '../image-url-context'
90
90
  import { getFieldWidget, useFieldWidgetRegistryVersion } from '../field-widget-registry'
91
- import { TimeZoneContext, CurrencyContext } from '../org-runtime-context'
91
+ import { TimeZoneContext, CurrencyContext, useNumberLocale, useSystemActor } from '../org-runtime-context'
92
+ import { AuthorshipCell, hasSpecialAuthorship, readProvenance } from '../provenance'
92
93
 
93
94
  // Re-export the resolver type so `index.ts`'s
94
95
  // `export type { … GetImageUrl } from './dialogs/dynamic-record'` keeps working.
@@ -1694,10 +1695,13 @@ export function ViewValue({
1694
1695
  getImageUrl: getImageUrlProp,
1695
1696
  timeZone: timeZoneProp,
1696
1697
  currency: currencyProp,
1698
+ model,
1697
1699
  }: {
1698
1700
  field: FieldDef
1699
1701
  value: any
1700
1702
  record: any
1703
+ /** Model key; lets the host origin resolver name legacy system rows. */
1704
+ model?: string
1701
1705
  /** Optional override; when omitted falls back to the nearest provider/identity. */
1702
1706
  getImageUrl?: GetImageUrl
1703
1707
  /** Optional override; when omitted falls back to the nearest provider. */
@@ -1706,6 +1710,8 @@ export function ViewValue({
1706
1710
  currency?: string
1707
1711
  }) {
1708
1712
  const { t, i18n } = useTranslation()
1713
+ const numberLocale = useNumberLocale(i18n.language)
1714
+ const systemActor = useSystemActor()
1709
1715
  const ctxImageUrl = useContext(ImageUrlContext)
1710
1716
  const ctxTimeZone = useContext(TimeZoneContext)
1711
1717
  const ctxCurrency = useContext(CurrencyContext)
@@ -1729,6 +1735,20 @@ export function ViewValue({
1729
1735
  field.key === 'created_by' ||
1730
1736
  field.key === 'created_by_id'
1731
1737
  ) {
1738
+ const isCreatedByField =
1739
+ field.key === 'created_by' ||
1740
+ field.key === 'created_by_id' ||
1741
+ (typeof field.key === 'string' && field.key.startsWith('created_by.')) ||
1742
+ renderAs === 'creator'
1743
+ // Provenance: person with the agent, the agent alone, the system or an
1744
+ // integration with its origin (kernel `provenance`).
1745
+ if (isCreatedByField && (hasSpecialAuthorship(record) || readProvenance(record))) {
1746
+ return (
1747
+ <div className="py-1">
1748
+ <AuthorshipCell row={record} model={model} variant="inline" />
1749
+ </div>
1750
+ )
1751
+ }
1732
1752
  const user = createdBySibling(rawValue, record)
1733
1753
  if (user) {
1734
1754
  return (
@@ -1748,7 +1768,7 @@ export function ViewValue({
1748
1768
  (typeof field.key === 'string' && field.key.startsWith('created_by.')) ||
1749
1769
  renderAs === 'creator'
1750
1770
  if (isCreatedBy) {
1751
- return <p className="text-sm py-1">Sistema</p>
1771
+ return <p className="text-sm py-1">{systemActor?.name || t('common.system', { defaultValue: 'Sistema' })}</p>
1752
1772
  }
1753
1773
  return <p className="text-sm py-1 text-muted-foreground">—</p>
1754
1774
  }
@@ -1897,7 +1917,7 @@ export function ViewValue({
1897
1917
  const num = typeof value === 'number' ? value : Number(value)
1898
1918
  if (!isNaN(num)) {
1899
1919
  const resolvedCurrency = field.styleConfig?.currency || currency || 'USD'
1900
- const localeTag = i18n.language || 'es'
1920
+ const localeTag = numberLocale || 'es'
1901
1921
  const formatted = new Intl.NumberFormat(localeTag, {
1902
1922
  style: 'currency',
1903
1923
  currency: resolvedCurrency,
@@ -1988,7 +2008,7 @@ export function ViewValue({
1988
2008
  <StructuredViewValue
1989
2009
  value={value}
1990
2010
  field={field}
1991
- locale={i18n.language}
2011
+ locale={numberLocale}
1992
2012
  t={t}
1993
2013
  />
1994
2014
  )
@@ -2221,6 +2241,7 @@ export function EditField({ field, value, onChange, record, invalid, error }: {
2221
2241
  : undefined
2222
2242
 
2223
2243
  const { t, i18n } = useTranslation()
2244
+ const numberLocale = useNumberLocale(i18n.language)
2224
2245
  const editFieldImageUrl = useContext(ImageUrlContext)
2225
2246
  const dialogModel = useContext(RecordDialogModelContext)
2226
2247
 
@@ -2252,7 +2273,7 @@ export function EditField({ field, value, onChange, record, invalid, error }: {
2252
2273
  value={value}
2253
2274
  itemFields={fieldItemFields(field)}
2254
2275
  variant="inline"
2255
- locale={i18n.language}
2276
+ locale={numberLocale}
2256
2277
  t={t}
2257
2278
  getImageUrl={editFieldImageUrl}
2258
2279
  />
@@ -38,6 +38,8 @@ import {
38
38
  relationChipStyles,
39
39
  } from '@asteby/metacore-ui/lib'
40
40
  import { Progress } from './dialogs/_primitives'
41
+ import { useSystemActor } from './org-runtime-context'
42
+ import { AuthorshipCell, hasSpecialAuthorship } from './provenance'
41
43
  import { humanizeToken, translateMetadataLabel } from './dynamic-columns-helpers'
42
44
  import { objectLabel } from './dynamic-relation-helpers'
43
45
  import {
@@ -604,19 +606,33 @@ export function resolveMissingActorLabel(
604
606
  namePath: string | undefined,
605
607
  t?: (key: string, options?: { defaultValue?: string }) => string,
606
608
  ): string {
609
+ if (isSystemActorColumn(renderAs, colKey, namePath)) {
610
+ return t ? t('common.system', { defaultValue: 'Sistema' }) : 'Sistema'
611
+ }
612
+ return 'N/A'
613
+ }
614
+
615
+ /**
616
+ * True when an EMPTY actor in this cell means "the system did it": `creator`
617
+ * cells and `created_by.*` columns. Exported so hosts and renderers share the
618
+ * rule with resolveMissingActorLabel.
619
+ */
620
+ export function isSystemActorColumn(
621
+ renderAs: string | undefined,
622
+ colKey: string | undefined,
623
+ namePath: string | undefined,
624
+ ): boolean {
607
625
  const path = namePath || ''
608
626
  const key = colKey || ''
609
- const isCreatedByColumn =
627
+ return (
628
+ renderAs === 'creator' ||
610
629
  key === 'created_by' ||
611
630
  key === 'created_by_id' ||
612
631
  key.startsWith('created_by.') ||
613
632
  path === 'created_by' ||
614
633
  path === 'created_by.name' ||
615
634
  path.startsWith('created_by.')
616
- if (renderAs === 'creator' || isCreatedByColumn) {
617
- return t ? t('common.system', { defaultValue: 'Sistema' }) : 'Sistema'
618
- }
619
- return 'N/A'
635
+ )
620
636
  }
621
637
 
622
638
  /**
@@ -866,6 +882,27 @@ const AvatarCell: React.FC<{
866
882
  </div>
867
883
  )
868
884
 
885
+ /**
886
+ * Avatar cell for the system actor: the OrgRuntimeProvider `systemActor`
887
+ * name/avatar when set, else the localized fallback label with initials.
888
+ */
889
+ const identityUrl = (p: string) => p
890
+ const SystemActorCell: React.FC<{
891
+ fallbackName: string
892
+ desc?: string
893
+ getImageUrl: (path: string) => string
894
+ }> = ({ fallbackName, desc, getImageUrl }) => {
895
+ const actor = useSystemActor()
896
+ return (
897
+ <AvatarCell
898
+ name={actor?.name || fallbackName}
899
+ desc={desc}
900
+ avatarSrc={actor?.avatarUrl}
901
+ getImageUrl={actor?.avatarUrl ? identityUrl : getImageUrl}
902
+ />
903
+ )
904
+ }
905
+
869
906
  /**
870
907
  * Builds the canonical column factory used by `<DynamicTable>` when the host
871
908
  * does not supply its own. Pass `{ getImageUrl, apiBaseUrl }` to wire avatar
@@ -934,7 +971,12 @@ export function makeDefaultGetDynamicColumns(
934
971
  currency?: string,
935
972
  rowActionPredicate?: RowActionPredicate,
936
973
  ): ColumnDef<any>[] {
937
- const dateLocale = currentLanguage === 'en' ? enUS : es
974
+ // Model key for the provenance origin resolver: last endpoint segment
975
+ // ("/data/findings" → "findings").
976
+ const model = (metadata.endpoint || '').split('?')[0].split('/').filter(Boolean).pop()
977
+ // currentLanguage may be a regional number locale (es-MX, en-US) when
978
+ // the host sets OrgRuntimeProvider numberLocales; dates key off its base.
979
+ const dateLocale = currentLanguage?.toLowerCase().startsWith('en') ? enUS : es
938
980
  const columns: ColumnDef<any>[] = [
939
981
  {
940
982
  id: 'select',
@@ -1186,6 +1228,26 @@ export function makeDefaultGetDynamicColumns(
1186
1228
  resolveMissingActorLabel(renderAs, col.key, namePath, t)
1187
1229
  const desc = getNestedValue(row.original, col.description || '')
1188
1230
 
1231
+ // Provenance (kernel `provenance`): a person with
1232
+ // the agent, the agent alone, or the system /
1233
+ // an integration with its origin.
1234
+ if (
1235
+ isSystemActorColumn(renderAs, col.key, namePath) &&
1236
+ hasSpecialAuthorship(row.original as Record<string, unknown>)
1237
+ ) {
1238
+ return <AuthorshipCell row={row.original as Record<string, unknown>} model={model} />
1239
+ }
1240
+
1241
+ if (!resolvedName && isSystemActorColumn(renderAs, col.key, namePath)) {
1242
+ return (
1243
+ <SystemActorCell
1244
+ fallbackName={String(name)}
1245
+ desc={desc ? String(desc) : undefined}
1246
+ getImageUrl={getImageUrl}
1247
+ />
1248
+ )
1249
+ }
1250
+
1189
1251
  const avatarSrc = resolveAvatarSrc(col, row.original, value, apiBaseUrl)
1190
1252
 
1191
1253
  return (
@@ -71,7 +71,7 @@ export function DynamicDateField({ field, value, onChange, invalid }: DynamicDat
71
71
  >
72
72
  <CalendarIcon className="mr-2 size-4 shrink-0 opacity-50" />
73
73
  <span className="truncate">
74
- {selected ? label(selected) : (field.placeholder || 'Elegí una fecha')}
74
+ {selected ? label(selected) : (field.placeholder || 'Elige una fecha')}
75
75
  </span>
76
76
  </Button>
77
77
  </PopoverTrigger>
@@ -528,7 +528,7 @@ function FieldRenderer({
528
528
  * Input de texto/número con opción de ESCANEO por cámara para "llenar rápido".
529
529
  * Cuando el campo declara `scan` (alias `scannable`) y el navegador soporta
530
530
  * `BarcodeDetector`, agrega un botón de cámara: el código escaneado se escribe
531
- * en el input y el escáner SE QUEDA ABIERTO (continuo) por si querés corregir o
531
+ * en el input y el escáner SE QUEDA ABIERTO (continuo) por si quieres corregir o
532
532
  * escanear otro — lo cerrás con la X. Sin el flag o sin soporte, es un Input
533
533
  * normal (retrocompat total).
534
534
  */
@@ -544,7 +544,7 @@ function ScannableInput({
544
544
  // `isCameraScanSupported()`: en un navegador sin `BarcodeDetector` el botón
545
545
  // seguía sin verse en escritorio aunque el campo lo pidiera, y el usuario no
546
546
  // entendía por qué el POS sí lo mostraba y el form no. El BarcodeScanner ya
547
- // degrada con un mensaje ("usá un lector físico / escribí a mano") cuando no
547
+ // degrada con un mensaje ("usa un lector físico / escribe a mano") cuando no
548
548
  // hay soporte, así que mostrar el botón es seguro y consistente.
549
549
  const scanEnabled = !!(field.scan ?? field.scannable)
550
550
  const input = (
@@ -37,7 +37,7 @@ import {
37
37
  useSyncExternalStore,
38
38
  } from 'react'
39
39
  import { useTranslation } from 'react-i18next'
40
- import { useTimeZone, useCurrency } from './org-runtime-context'
40
+ import { useTimeZone, useCurrency, useNumberLocale } from './org-runtime-context'
41
41
  import {
42
42
  QueryClient,
43
43
  QueryClientContext,
@@ -950,6 +950,7 @@ function DynamicKanbanBoard({
950
950
  groupBy: groupByProp,
951
951
  }: DynamicKanbanProps) {
952
952
  const { t, i18n } = useTranslation()
953
+ const numberLocale = useNumberLocale(i18n.language)
953
954
  // The org's timezone/currency: an explicit prop wins, else the app-wide
954
955
  // OrgRuntimeProvider (without it, money fell back to USD).
955
956
  const orgTimeZone = useTimeZone()
@@ -2096,7 +2097,7 @@ function DynamicKanbanBoard({
2096
2097
  col,
2097
2098
  (laneSums[col.key] ?? 0) + (delta?.sums[col.key] ?? 0),
2098
2099
  currency,
2099
- i18n.language,
2100
+ numberLocale,
2100
2101
  ),
2101
2102
  }))
2102
2103
  : []
@@ -2160,7 +2161,7 @@ function DynamicKanbanBoard({
2160
2161
  actions={rowActions}
2161
2162
  stageField={lifecycleStageField(metadata)}
2162
2163
  rowActionPredicate={rowActionPredicate}
2163
- locale={i18n.language}
2164
+ locale={numberLocale}
2164
2165
  timeZone={timeZone}
2165
2166
  currency={currency}
2166
2167
  onClick={onCardClick}
@@ -2194,7 +2195,7 @@ function DynamicKanbanBoard({
2194
2195
  actions={rowActions}
2195
2196
  stageField={lifecycleStageField(metadata)}
2196
2197
  rowActionPredicate={rowActionPredicate}
2197
- locale={i18n.language}
2198
+ locale={numberLocale}
2198
2199
  timeZone={timeZone}
2199
2200
  currency={currency}
2200
2201
  onClick={onCardClick}
@@ -2404,7 +2405,7 @@ function DynamicKanbanBoard({
2404
2405
  titleCol={titleCol}
2405
2406
  fieldCols={fieldCols}
2406
2407
  showAllFields={explicitCard}
2407
- locale={i18n.language}
2408
+ locale={numberLocale}
2408
2409
  timeZone={timeZone}
2409
2410
  currency={currency}
2410
2411
  blocked={overBlocked}