Session: you-are-a-senior-indexed-clarke-subagent-a0801bbf — 2026-04-27

doctolib-doctolib · Claude · branch .invalid · claude-sonnet-4-6 · 2026-04-27 13:22 · 1 msgs · 27 tools · 15 min read · updated 10 days ago

You are doing a frontend architecture review (UpFront patterns) of PR #241005 in the doctolib/doctolib monorepo.

tools: Bash, Read
← doctolib-doctolib Download .md .txt .json
Tool calls
Bash Bash: 23 calls (85.2%) 23 Read Read: 4 calls (14.8%) 4
Token usage920.8K total
Input401
Cache creation83.1K
Cache read834.2K
Output3.1K
Cache hit ratio91%· healthy

Project: doctolib-doctolib · Branch: .invalid · Mode: ` · **Model:**claude-sonnet-4-6`

Stats: 1 user messages, 27 tool calls, tools used: Bash, Read.

Conversation

Turn 1 — User

You are doing a frontend architecture review (UpFront patterns) of PR #241005 in the doctolib/doctolib monorepo.

PR Summary

FHIR-2195: Wires archive/unarchive document status actions into the NHR document list UI.

Files to review

packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts

import { useCallback, useMemo, useState } from 'react'
import type { NhrDocument } from '@doctolib/tpf-national-health-records'
import type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui'
import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient'
import i18n from 'monolith_DEPRECATED/services/i18n'
import { isActive, isArchived } from '../variants/dmp/mappers/dmpDocumentHelpers'
import { toNhrPatientInformation } from '../business/mappers/toNhrPatientInformation'
import { useNationalHealthRecords } from './useNationalHealthRecords'
import { useInvalidateNhrDocuments } from './useInvalidateNhrDocuments'
import type { NhrActionModalConfig } from '../types/nhrDocumentActions'

type ModalState = {
  doc: NhrDocument
  config: NhrActionModalConfig
}

const archiveConfig = (): NhrActionModalConfig => ({
  title: i18n.t('national_health_records.document_metadata_actions.dmp.dialogs.archive.title'),
  body: i18n.t('national_health_records.document_metadata_actions.dmp.dialogs.archive.body'),
  confirmLabel: i18n.t('national_health_records.document_metadata_actions.dmp.dialogs.archive.confirm'),
})

const unarchiveConfig = (): NhrActionModalConfig => ({
  title: i18n.t('national_health_records.document_metadata_actions.dmp.dialogs.unarchive.title'),
  body: i18n.t('national_health_records.document_metadata_actions.dmp.dialogs.unarchive.body'),
  confirmLabel: i18n.t('national_health_records.document_metadata_actions.dmp.dialogs.unarchive.confirm'),
})

export const useNhrDocumentStatusActions = ({ patient }: { patient: Patient }): UseNhrDocumentStatusActionsResult => {
  const nhrOperations = useNationalHealthRecords({ patient })
  const invalidateNhrDocuments = useInvalidateNhrDocuments(patient)

  const [modalState, setModalState] = useState<ModalState | null>(null)
  const [isLoading, setIsLoading] = useState(false)
  const [error, setError] = useState<string | null>(null)

  const openModal = useCallback(
    (doc: NhrDocument, config: NhrActionModalConfig) => {
      setError(null)
      setModalState({ doc, config })
    },
    // setError and setModalState are stable useState setters — no deps needed
    []
  )

  const options: DropdownActionOption[] = useMemo(
    () => [
      {
        key: 'archive',
        label: i18n.t('national_health_records.document_metadata_actions.dmp.options.archive'),
        isAvailable: isActive,
        onClick: (doc) => openModal(doc, archiveConfig()),
      },
      {
        key: 'unarchive',
        label: i18n.t('national_health_records.document_metadata_actions.dmp.options.unarchive'),
        isAvailable: isArchived,
        onClick: (doc) => openModal(doc, unarchiveConfig()),
      },
    ],
    [openModal]
  )

  const handleConfirm = async () => {
    if (!modalState || !nhrOperations || !patient.ins) return
    setIsLoading(true)
    setError(null)
    try {
      await nhrOperations.updateDocumentMetadata({
        patient: toNhrPatientInformation(patient.ins),
        params: { payloads: [{ id: modalState.doc.id, propertyName: 'status' }] },
      })
      setModalState(null)
      await invalidateNhrDocuments()
    } catch {
      setError(i18n.t('national_health_records.document_metadata_actions.dmp.errors.action_failed'))
    } finally {
      setIsLoading(false)
    }
  }

  const handleDismiss = () => {
    if (isLoading) return
    setModalState(null)
    setError(null)
  }

  return { options, modalState, isLoading, error, handleConfirm, handleDismiss }
}

packages/@doctolib/national-health-records/src/components/NhrDocumentActionDialog.tsx

import { Alert } from '@doctolib/design-system/Alert

…(truncated, 3432 more chars)

Turn 1 — Assistant

I'll start by examining the actual files in the repository to complement the provided snippets with full context.

Tools used:

  • Bash: find /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src -type f | sort

Tool results:

→ result (ok): /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/DmpNhrAdapter.test.ts /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/DmpNhrAdapter.ts /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/parseHl7DateToIso.test.ts /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/parseHl7DateToI …(truncated, 4697 more chars)

Tools used:

  • Read: /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/index.ts

Tool results:

→ result (ok): 1 export { useNationalHealthRecords, type UseNhrOperations } from './hooks/useNationalHealthRecords' 2 export { useDmpNhr } from './hooks/useDmpNhr' 3 export { useNhrDocumentListVariant } from './variants/useNhrDocumentListVariant' 4 export type { DocumentSearchOptions, NhrDocumentListVariant } from './variants/types' 5 export { actionsBuilder, type NhrActionsBuilder } from './business/builders/actionsBuilder' 6 export { useGetDocumentsContent } from './hooks/useGetDocumentsContent' 7

Tools used:

  • Read: /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts

Tool results:

→ result (ERROR): File does not exist. Note: your current working directory is /Users/USER/workspace/doctolib/doctolib.

Tools used:

  • Bash: git log --oneline -10 && git diff HEAD~4..HEAD --name-only

Tool results:

→ result (ok): 0df5cb0202e8 fix(FHIR-2215): pass undefined as second arg to DmpNhrAdapter constructor in tests fb2aedc3103f test(FHIR-2215): use explicit mock factories to avoid loading @doctolib/dmp module graph d8bda659144d fix(FHIR-2215): adapt actionsBuilder and PatientCard to tpf-national-health-records-ui@15 API 873048022514 refactor(FHIR-2215): merge consecutive early-return guards in useSearchDocuments f6348a068d11 test(FHIR-2215): add coverage for undefined apiErrorCode and non-Error thrown value 015a …(truncated, 889 more chars)

The commits visible are for FHIR-2215, not FHIR-2195. Let me check the actual PR #241005 changes.

Tools used:

  • Bash: git log --oneline --all | grep -i "FHIR-2195\|241005" | head -20

Tools used:

  • Bash: find /Users/USER/workspace/doctolib/worktrees/doctolib -maxdepth 1 -type d 2>/dev/null | head -20

Tool results:

→ result (ok): /Users/USER/workspace/doctolib/worktrees/doctolib /Users/USER/workspace/doctolib/worktrees/doctolib/fhir-2209_fix-patient-ins-env-transformation /Users/USER/workspace/doctolib/worktrees/doctolib/fhir-2190_improve-filter-panel-ui /Users/USER/workspace/doctolib/worktrees/doctolib/fhir-2089 /Users/USER/workspace/doctolib/worktrees/doctolib/fhir-2181 /Users/USER/workspace/doctolib/worktrees/doctolib/FHIR-2166-fix-nhr-mock-status-visibility /Users/USER/workspace/doctolib/worktrees/doctolib/FHIR-2091- …(truncated, 268 more chars)

Tool results:

→ result (ok): 6b249fe82efe FHIR-2195: Add config for more actions and update doc status

Tools used:

  • Bash: git show 6b249fe82efe --name-only

Tool results:

→ result (ok): <persisted-output> Output too large (7.4MB). Full output saved to: /Users/USER/.claude/projects/-Users-clertonra-workspace-doctolib-doctolib/17cef181-a5f1-408a-82c6-2d3be29e0e3e/tool-results/b82mjk66j.txt

Preview (first 2KB): commit 6b249fe82efec360cf5bb5a10dc6740b3e1ff166 Author: Sushan <<REDACTED>> Date: Mon Apr 27 15:08:02 2026 +0200

FHIR-2195: Add config for more actions and update doc status

.billeo-version .browserslistrc .bundle-option .byebugrc .cherry.ts .cherry/CODEOWNERS.loca …(truncated, 1717 more chars)

Tools used:

  • Bash: git show 6b249fe82efe --name-only 2>/dev/null | grep -E "packages/@doctolib|\.tsx?$" | head -40

Tool results:

→ result (ok): .cherry.ts .cherry/constants.ts .cherry/engines.ts .cherry/financial.ts .cherry/freemium.ts .cherry/frontend-isolation/create-metrics.ts .cherry/hcp-account.ts .cherry/helpers.ts .cherry/main.ts .cherry/modus.ts .cherry/online-booking.ts .cherry/online-identity.ts .cherry/packages.ts .cherry/packaging.ts .cherry/patient-account.test.ts .cherry/patient-account.ts .cherry/pcf.ts .cherry/privacy-preferences.ts .cherry/tanstack-query.ts .cherry/tests.ts .cherry/types.ts .cherry/upfront-isolation.ts

…(truncated, 1042 more chars)

Tools used:

  • Bash: git show 6b249fe82efe --name-only 2>/dev/null | grep "packages/@doctolib" | head -40

Tool results:

→ result (ok): packages/@doctolib/actions_history/CODEOWNERS.local packages/@doctolib/actions_history/babel.config.cjs packages/@doctolib/actions_history/catalog-info.yaml packages/@doctolib/actions_history/jest.config.cjs packages/@doctolib/actions_history/package.json packages/@doctolib/actions_history/src/ActionsHistoryPage/ActionsHistoryModule/ActionsHistory.scss packages/@doctolib/actions_history/src/ActionsHistoryPage/ActionsHistoryModule/ActionsHistoryModule.tsx packages/@doctolib/actions_history/src/Ac …(truncated, 2559 more chars)

Tools used:

  • Bash: git show 6b249fe82efe --name-only 2>/dev/null | grep "national-health-records\|shared_patient_file"

Tool results:

→ result (ok): packages/@doctolib/national-health-records/CODEOWNERS.local packages/@doctolib/national-health-records/babel.config.cjs packages/@doctolib/national-health-records/catalog-info.yaml packages/@doctolib/national-health-records/i18n.json packages/@doctolib/national-health-records/jest.config.cjs packages/@doctolib/national-health-records/package.json packages/@doctolib/national-health-records/src/business/adapters/DmpNhrAdapter.test.ts packages/@doctolib/national-health-records/src/business/adapters …(truncated, 17776 more chars)

Now let me read the actual source files introduced in this PR:

Tools used:

  • Read: /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts

Tool results:

→ result (ERROR): File does not exist. Note: your current working directory is /Users/USER/workspace/doctolib/doctolib.

Tools used:

  • Read: /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/hooks/useInvalidateNhrDocuments.ts

Tool results:

→ result (ERROR): File does not exist. Note: your current working directory is /Users/USER/workspace/doctolib/doctolib.

The files were added in the commit but are not in the currently checked-out branch. Let me read them directly from the commit.

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts 2>/dev/null

Tool results:

→ result (ok): import { useCallback, useMemo, useState } from 'react' import type { NhrDocument } from '@doctolib/tpf-national-health-records' import type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import i18n from 'monolith_DEPRECATED/services/i18n' import { isActive, isArchived } from '../variants/dmp/mappers/dmpDocumentHelpers' import { toNhrPatientInformation } from '../business/mappers/toNhrPatientInf …(truncated, 3236 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/hooks/useInvalidateNhrDocuments.ts 2>/dev/null

Tool results:

→ result (ok): import { useQueryClient } from '@tanstack/react-query-v5' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient'

export const useInvalidateNhrDocuments = (patient: Patient) => { const queryClient = useQueryClient() // Prefix key intentionally busts all filter variants cached for this patient return () => queryClient.invalidateQueries({ queryKey: ['dmp-documents', patient.ins] }) }

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/components/NhrDocumentActionDialog.tsx 2>/dev/null

Tool results:

→ result (ok): import { Alert } from '@doctolib/design-system/Alert' import { Dialog } from '@doctolib/design-system/Dialog' import i18n from 'monolith_DEPRECATED/services/i18n' import type { NhrActionModalConfig } from '../types/nhrDocumentActions'

type Props = { isOpen: boolean config: NhrActionModalConfig | null isLoading: boolean error: string | null onConfirm: () => void onDismiss: () => void }

export const NhrDocumentActionDialog = ({ isOpen, config, isLoading, error, onConfirm, onDismiss } …(truncated, 410 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/index.ts 2>/dev/null

Tool results:

→ result (ok): export { useNationalHealthRecords, type UseNhrOperations } from './hooks/useNationalHealthRecords' export { useDmpNhr } from './hooks/useDmpNhr' export { useNhrDocumentListVariant } from './variants/useNhrDocumentListVariant' export type { DocumentSearchOptions, NhrDocumentListVariant } from './variants/types' export { actionsBuilder, type NhrActionsBuilder } from './business/builders/actionsBuilder' export { useGetDocumentsContent } from './hooks/useGetDocumentsContent' export { useInvalidateNh …(truncated, 524 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/types/nhrDocumentActions.ts 2>/dev/null

Tool results:

→ result (ok): export type NhrActionModalConfig = { title: string body: string confirmLabel: string }

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.test.ts 2>/dev/null

Tool results:

→ result (ok): import { act, renderHook } from '@testing-library/react' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import type { NhrDocument } from '@doctolib/tpf-national-health-records' import type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui' import { useNhrDocumentStatusActions } from './useNhrDocumentStatusActions' import { useNationalHealthRecords } from './useNationalHealthRecords' import { useInvalidateNhrDocuments } from './useInvalidateNhrDo …(truncated, 7222 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/PatientCard/PatientCard.tsx 2>/dev/null

Tool results:

→ result (ok): import PatientFileIcon from 'images/icons/patient-file-icon.svg?as-react-component' import PatientAppointmentIcon from 'images/icons/patient-appointment-icon.svg?as-react-component' import { type ComponentType, lazy, useContext, useMemo, Suspense } from 'react' import classNames from 'classnames' import AccountContext from 'monolith_DEPRECATED/contexts/doctor/AccountContext' import INSiAutomaticCallContext from '@doctolib/financial_os_api/public/contexts/INSiAutomaticCallContext' import InsiIden …(truncated, 7210 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/variants/dmp/mappers/dmpDocumentHelpers.ts 2>/dev/null

Tool results:

→ result (ok): import type { NhrDocument } from '@doctolib/tpf-national-health-records' import type { NhrVisibilityEntry } from '@doctolib/tpf-national-health-records-ui' import { DOCUMENT_STATUS, DOCUMENT_VISIBILITY } from '@doctolib/dmp'

const CLASS_CODE_SYSTEM = 'dmp:classCode' const TYPE_CODE_SYSTEM = 'dmp:typeCode' const PATIENT_CODE = '90' // EX_3.1-1040: class code for patient-authored documents

// classification.codes may contain both a classCode (JDV_J06) and a typeCode (JDV_J07/LOINC). // typeCode …(truncated, 2722 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/hooks/useNationalHealthRecords.ts 2>/dev/null

Tool results:

→ result (ok): import type { NhrDocumentSearchProps, NhrDocumentSearchResult, NhrGetDocumentsContentProps, NhrDocumentContentResult, NhrDocumentMetadataUpdateProps, NhrDocumentMetadataUpdateResult, } from '@doctolib/tpf-national-health-records' import { useProductLineVariation, ProductLineKey } from '@doctolib/variation_management' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import { useDmpNhr } from './useDmpNhr'

export type UseNhrOperations = { searchDocuments: …(truncated, 870 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/hooks/useSearchDocuments.ts 2>/dev/null

Tool results:

→ result (ok): import { useQueryClient } from '@tanstack/react-query-v5' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import { isFeatureEnabled } from '@doctolib/variation_management' import i18n from 'monolith_DEPRECATED/services/i18n' import type { NhrDocumentListVariant, MapFiltersToSearchDocumentsParams, ServerFilters } from '../variants/types' import { useNationalHealthRecords } from './useNationalHealthRecords' import { generateNhrDocuments } from '../mocks/generateNhrDocum …(truncated, 2493 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/business/builders/actionsBuilder.ts 2>/dev/null

Tool results:

→ result (ok): import { createMoreActionsAction as moreActionsActionFactory, createViewDocumentAction as viewDocumentActionFactory, type ActionConfig, type DropdownActionOption, } from '@doctolib/tpf-national-health-records-ui' import type { NhrDocument } from '@doctolib/tpf-national-health-records'

export type NhrActionsBuilder = { createViewDocumentAction: (onDocumentSelected: (document: NhrDocument) => Promise<void>) => NhrActionsBuilder createMoreActionsAction: (options: DropdownActionOption[] …(truncated, 497 more chars)

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/business/mappers/toNhrPatientInformation.ts 2>/dev/null

Tool results:

→ result (ok): import type { NhrPatientInformation } from '@doctolib/tpf-national-health-records'

export function toNhrPatientInformation(ins: string): NhrPatientInformation { return { nationalHealthIdentifier: ins, } }

Now I have enough context to give a thorough review. Let me also quickly check how query keys are handled elsewhere in the package to assess the factory pattern question.

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/variants/dmp/useDmpDocumentListVariant.ts 2>/dev/null

Tool results:

→ result (ok): import { columnsFactory } from './factories/columnsFactory' import { filtersFactory } from './factories/filtersFactory' import type { NhrDocumentListVariant, DocumentSearchOptions } from '../types' import useDmpSearchDocuments from '../../hooks/useSearchDocuments' import { mapFiltersToSearchDocumentsParams } from './mappers/mapFiltersToSearchDocumentsParams'

export const useDmpDocumentListVariant = (patient: DocumentSearchOptions['patient']): NhrDocumentListVariant => { const searchDocuments …(truncated, 171 more chars)

Tools used:

  • Bash: grep -r "dmp-documents" /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/ 2>/dev/null || git show 6b249fe82efe --name-only 2>/dev/null | grep "national-health-re …(truncated, 82 more chars)

Tool results:

→ result (ok): /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/hooks/useSearchDocuments.ts: queryKey: ['dmp-documents', ins, appliedFilters],

Tools used:

  • Bash: git show 6b249fe82efe:packages/@doctolib/national-health-records/src/hooks/useGetDocumentsContent.ts 2>/dev/null

Tool results:

→ result (ok): import { useState, useCallback } from 'react' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import type { NhrDocumentContentResult } from '@doctolib/tpf-national-health-records' import type { GetDocumentsContent } from '../variants/types' import { useNationalHealthRecords } from './useNationalHealthRecords'

export const useGetDocumentsContent = ({ patient, }: { patient: Patient }): { getDocumentsContent: GetDocumentsContent; documentsContent: NhrDocumentContent …(truncated, 947 more chars)

I now have full context to deliver the review.


Architecture Review: PR #241005 (FHIR-2195)

Critical Issues (must fix)


1. useNhrDocumentStatusActions imports from monolith_DEPRECATED inside a package

File: packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts, lines 4-5 File: packages/@doctolib/national-health-records/src/components/NhrDocumentActionDialog.tsx, line 3 File: packages/@doctolib/national-health-records/src/hooks/useInvalidateNhrDocuments.ts, line 2

Both the hook and the dialog component import directly from monolith_DEPRECATED/services/i18n and monolith_DEPRECATED/types/doctor/api/Patient. This is not a new pattern in the package (existing hooks useNationalHealthRecords, useGetDocumentsContent, and useSearchDocuments all carry the same monolith_DEPRECATED coupling), but this PR adds two new hooks and a new component that repeat and deepen the problem.

The Patient type should be typed through the package's own interface or a public API boundary. The i18n singleton should be injected or the translation keys surfaced through an abstraction. As it stands the package cannot be tested, reused, or migrated independently of the monolith. This is a pre-existing architectural debt, but adding more surface area to it without comment or a migration note is a violation that should be called out.


2. useNhrDocumentStatusActions is in src/hooks/ but mixes business logic, UI state, and an API call — it belongs in src/business/

File: packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts

Per UpFront rules, src/hooks/ is reserved for two things: data hooks (repositories) and platform/UX API hooks. Shared business hooks that combine domain logic with state orchestration belong in src/business/. This hook:

  • Owns modal UI state (modalState, isLoading, error)
  • Produces domain-level options that encode availability rules (isActive, isArchived)
  • Executes an API mutation via useNationalHealthRecords
  • Runs a cache invalidation

This is a shared business hook. It should live at src/business/useNhrDocumentStatusActions.ts. The current placement signals that it is a data-fetching hook when it is not — it is a coordinating business hook.


3. useInvalidateNhrDocuments uses a bare string array query key that is inconsistent with useSearchDocuments

File: packages/@doctolib/national-health-records/src/hooks/useInvalidateNhrDocuments.ts, line 6 File: packages/@doctolib/national-health-records/src/hooks/useSearchDocuments.ts, line 45

useSearchDocuments caches with ['dmp-documents', ins, appliedFilters]. useInvalidateNhrDocuments calls invalidateQueries({ queryKey: ['dmp-documents', patient.ins] }), which works by prefix-matching and will bust all filter variants for a patient — the intent is correct and a comment acknowledges it.

The problem is architectural: the query key is a bare string literal defined in two separate files with no shared source of truth. There is no query key factory (a plain object or function exported from a dedicated file). If the key shape changes in useSearchDocuments, useInvalidateNhrDocuments silently diverges and cache invalidation stops working. A key factory is the standard pattern:

// src/data/queryKeys.ts
export const nhrQueryKeys = {
  all: (ins: string) => ['dmp-documents', ins] as const,
  list: (ins: string, filters: Record<string, unknown>) => [...nhrQueryKeys.all(ins), filters] as const,
}

Both hooks would then reference nhrQueryKeys.all(ins) and nhrQueryKeys.list(ins, filters). This is a must-fix because it is a latent runtime correctness bug.


4. NhrDocumentActionDialog has no test file

File: packages/@doctolib/national-health-records/src/components/NhrDocumentActionDialog.tsx

The package has consistent colocated test coverage for all other units (hooks tested in .test.ts files, helpers tested in .test.ts files, factories tested alongside their source). NhrDocumentActionDialog.tsx was introduced without a corresponding NhrDocumentActionDialog.test.tsx. At minimum the rendering with and without an error, and the isOpen: false short-circuit, should be covered.


Warnings (should fix)


5. src/index.ts re-exports transitive third-party types as part of the package public API

File: packages/@doctolib/national-health-records/src/index.ts, lines 12-13

export type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui'
export type { NhrDocument } from '@doctolib/tpf-national-health-records'

These types belong to upstream packages. Re-exporting them from @doctolib/national-health-records's own index couples callers to this package as a proxy for a transitive dependency, which they are not. A caller that needs NhrDocument should import it from @doctolib/tpf-national-health-records directly. The pattern is acceptable only when the package genuinely wraps or narrows the type — neither case applies here.

The motivation appears to be convenience for the PatientCard.tsx caller, but that caller already imports from @doctolib/national-health-records for other symbols and can add the direct import for types. These two re-exports should be removed from the index.


6. useNhrDocumentStatusActions uses an async arrow function that is not useCallback-wrapped, making handleConfirm referentially unstable

File: packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts, lines 66-82

handleConfirm is defined as a plain async () => {...} function inside the hook body. It is recreated on every render. This is passed down to NhrDocumentActionDialog as onConfirm and then into the Dialog component's onAccept. While it will not cause a correctness bug in this specific case (it is not used as a dependency in any useEffect or useMemo), it is inconsistent with openModal directly above it, which is correctly useCallback-wrapped. Both handleConfirm and handleDismiss should be wrapped in useCallback:

const handleConfirm = useCallback(async () => { ... }, [modalState, nhrOperations, patient.ins, invalidateNhrDocuments])
const handleDismiss = useCallback(() => { ... }, [isLoading])

7. useNhrDocumentStatusActions is exported from src/index.ts but useInvalidateNhrDocuments is also exported — the latter is an internal implementation detail

File: packages/@doctolib/national-health-records/src/index.ts, line 7

useInvalidateNhrDocuments is consumed exclusively inside useNhrDocumentStatusActions. Exporting it from the public index leaks an internal coordination hook that no external consumer should need to call directly. It should remain internal and the export removed. If a future use case requires external cache invalidation, it can be re-introduced at that point with deliberate intent.


8. isActive and isArchived are exported from src/index.ts but belong to a DMP-specific mapper path

File: packages/@doctolib/national-health-records/src/index.ts, line 9 Source: packages/@doctolib/national-health-records/src/variants/dmp/mappers/dmpDocumentHelpers.ts

These helpers are domain-internal predicates that exist to serve useNhrDocumentStatusActions and columnsFactory. Exporting them from the top-level index makes them part of the package's public API, implying external consumers should rely on them. If they need to be used inside the package (which they are, by useNhrDocumentStatusActions), the import should remain internal. If there is a genuine consumer outside the package, the export should be justified in a comment.


9. src/components/NhrDocumentActionDialog.tsx is a flat file without a Josh Comeau directory structure

File: packages/@doctolib/national-health-records/src/components/NhrDocumentActionDialog.tsx

This is a new component introduced in the P …(truncated, 2836 more chars)

Keyboard shortcuts

⌘K / Ctrl+KOpen command palette
/Focus search
g hGo to home
g pGo to projects
g sGo to sessions
j / kNext / prev row (tables)
?Show this help
EscClose dialogs

Structured queries

Mix key:value filters with free text in the palette:

type:sessionOnly session pages
project:llm-wikiFilter by project name (substring)
model:claudeFilter by model name (substring)
date:>2026-03-01Sessions after a date
date:<2026-04-01Sessions before a date
tags:rustPages mentioning a tag/topic
sort:dateSort results by date (newest first)

Example: type:session project:llm-wiki date:>2026-04 sort:date