Commit graph

82 commits

Author SHA1 Message Date
willchen96
bb5f921076 update bun lockfiles 2026-07-23 18:27:20 +08:00
Will Chen
2ec89a7c52
Merge pull request #230 from amal66/olp-pr/frontend-unit-tests
Some checks failed
CI / Backend build and tests (push) Has been cancelled
CI / Frontend build and tests (push) Has been cancelled
CI / Eval harness (push) Has been cancelled
[Testing 07] test: component and hook unit tests for the web app
2026-07-22 16:59:39 +08:00
Will Chen
7d2ba4b87f
Merge pull request #235 from amal66/olp-pr/lint-burndown
[Lint 04] fix: burn down frontend eslint errors; make CI lint blocking
2026-07-22 16:33:52 +08:00
Will Chen
73b9cd1692
Merge pull request #232 from amal66/olp-pr/ci-workflows
[CI 03] ci: build and test workflow for backend and frontend
2026-07-22 16:07:57 +08:00
Will Chen
39dc609f95
Merge pull request #234 from amal66/olp-pr/testing-docs
[Docs 02] docs: testing policy in CONTRIBUTING + PR template
2026-07-21 22:16:01 +08:00
Will Chen
948e9bdd4d
Merge pull request #237 from amal66/olp-pr/coverage-critical-libs
[Testing 09] test: unit-cover the highest-risk backend libs + raise the coverage ratchet
2026-07-21 18:16:40 +08:00
Will Chen
eda088e143
Merge pull request #238 from amal66/olp-pr/directory-fetch-storm
[Fix 01] Batch the directory modal's project fetch (N+1 getProject storm)
2026-07-21 16:51:36 +08:00
cosimoastrada
8a34a6457f
Merge pull request #228 from amal66/olp-pr/test-harness
[Testing 05] test: minimal vitest harness for backend and frontend
2026-07-21 16:21:11 +08:00
QA Runner
36cddb2566 fix: batch directory-modal project fetch instead of N+1 getProject burst
Every directory picker (AddDocumentsModal, UseWorkflowModal, the assistant
project selector) loads its "Projects" tab through useDirectoryData, which
fired one GET /projects/:id for EVERY existing project the moment the modal
opened. Each of those requests costs an auth verification against GoTrue
plus ~6 PostgREST queries, so an account with N projects produced an
~8xN-request burst on the Supabase gateway per modal open.

Under that burst the gateway genuinely falls over: measured locally against
the Supabase CLI stack, overlapping modal-open storms drove GoTrue into
Postgres connection exhaustion ("failed to connect ... context deadline
exceeded") and produced 467x 500 + 641x 504 on /auth/v1/user in a single
run — surfacing to users as failed project creates/loads, and to the e2e
suite as the intermittent Kong 502s its specs currently retry around.

Fix: GET /projects now accepts ?include=documents and returns each
project's documents from one batched query (same attach helpers as
GET /projects/:id, run once across all documents), and useDirectoryData
uses it. A modal open is now 1 API request and a fixed number of DB
queries regardless of project count. After the change the same storm
harness produced zero 5xx and zero auth failures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 22:05:48 -07:00
cosimoastrada
0843e2909a
Merge pull request #212 from jmooves/upstream-pr/chat-messages-workflow-column
fix(db): add missing chat_messages.workflow column (user prompts dropped on reload)
2026-07-21 12:49:06 +08:00
QA Runner
2053ca15c8 test: cover critical backend libs, raise coverage ratchet, add roadmap
Six new unit suites (102 tests) for the highest-risk untested libs:
userDataCleanup (destructive account/project deletes), documentVersions
(document integrity), chat/citations (legal-citation parsing), safeError
(secret redaction), llm/models (model resolution), and userLookup
(profile email sync). Coverage floors ratchet up 2/2/4/2 ->
11/10/14/10 (measured 11.18/10.98/14.43/10.91), and
docs/testing-coverage.md gives contributors a prioritized backlog for
the remaining untested libs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 11:21:35 -07:00
QA Runner
0740f656e6 fix: burn down frontend eslint errors; make CI lint blocking
Takes frontend/npm run lint from 23 errors / 40 warnings to 0 errors /
40 warnings, then removes continue-on-error from the CI lint step so it
gates merges.

Errors fixed outright:
- @typescript-eslint/no-explicit-any (5, ChatView.tsx): dropped
  redundant (msg as any) casts — Message already declares files,
  workflow, and error with the exact shapes the props expect.
- react/no-unescaped-entities (1, support/page.tsx): "We'll" ->
  "We&apos;ll".

Targeted disables (17, all react-hooks/set-state-in-effect): every site
is an intentional effect-driven state pattern — SSR/hydration mount
gates (Modal, useSelectedModel), reset-on-prop/identity-change
(CaseLawPanel x3, ChatView chat switch, CitationQuotesHeader,
ChatHistoryContext logout, useFetchDocxBytes), sync fast paths of async
fetch/check effects (CaseLawPanel, MfaLoginGate x2), DOM-measured state
(ChatView scroll button, message-visibility restore), and timed UI
latches (PreResponseWrapper, TRChatPanel, AskInputPopup auto-submit).
Rewriting any of them would change runtime behavior, so each carries a
// eslint-disable-next-line with a one-line reason instead of a fix or
a repo-wide rule change.

CI: lint step is now blocking; comments updated to say the backlog is
at zero.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 11:17:24 -07:00
QA Runner
a29e67deac test: component and hook unit tests for the web app
Ported from the amal66 fork (index: Open-Legal-Products/mike#205), adapted
to this repo's frontend/ layout and current component behavior. Adds the
jsdom + testing-library harness on top of the existing vitest setup:
vitest.config.mts (jsdom environment, @/ alias mirroring tsconfig paths,
dummy Supabase env for modules that build a client at import time) and
vitest.setup.ts (jest-dom matchers). New devDependencies: jsdom,
@testing-library/react, @testing-library/jest-dom,
@testing-library/user-event, @vitejs/plugin-react.

Ported suites (30 new tests):
- FileTypeIcon.test.tsx (11) — fileTypeKind mapping + icon rendering
- TRTable.test.tsx (1) — header/row render smoke test; the fork's ARIA
  role assertions (table/columnheader, "Tabular review" label) target
  fork-only markup — this repo's grid is div-based, so the test asserts
  rendered content instead
- button.test.tsx (4), pill-button.test.tsx (8), cite-button.test.tsx (3)
- useSmoothedReveal.test.ts (3) — passes against this repo's early-return
  snap behavior unchanged

Dropped (subjects don't exist here):
- HistoryDropdown.test.tsx — no tr-chat-panel/HistoryDropdown component
- applyAssistantStreamEvent.test.ts — no such module
- useProjectsQuery/useTabularReviewsQuery/useWorkflowsQuery tests —
  react-query is fork-only
- lib/toast.test.ts — no frontend/src/lib/toast.ts
- useAssistantChat.parsers.test.ts — the parser helpers exist inside
  useAssistantChat.ts but are not exported, and the fork's extracted
  module doesn't exist here

Verified: frontend npm test 38/38 passing (30 new + 8 pre-existing cn()
utils tests); npx tsc --noEmit clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 10:50:11 -07:00
QA Runner
c139acc3c6 test: unit tests for access, storage, userApiKeys, chat doc resolution
Ported from the amal66 fork (see index Open-Legal-Products/mike#205)
onto current main, adapted to this repo's backend/ layout
(apps/api/src/lib -> backend/src/lib), plus a v8 coverage ratchet.

Suites ported (51 new tests, verified locally):
- access.test.ts (7): owner/shared/private project access, doc access,
  review sharing, document-ID filtering. Dropped the fork's "org RBAC"
  describe block (7 cases) — org_id/org_members multi-tenancy and the
  role/canManage fields do not exist in this repo's access.ts.
- storage.test.ts (25): filename normalization/sanitization, RFC 5987
  encoding, Content-Disposition, storage key helpers. Dropped the fork's
  vi.mock of lib/env — this repo has no env module; storage reads
  process.env directly and the tested helpers are pure.
- userApiKeys.test.ts (10): normalizeApiKeyProvider + hasEnvApiKey.
  Added a beforeEach env clear so shell-exported API keys can't leak
  into assertions.
- chatTypes.test.ts (9): resolveDoc/resolveDocLabel, which live in
  lib/chat/types.ts here (the fork's lib/chatTools.ts equivalent).
  Dropped generateSpotlightNonce cases (2) — no such export here.

Suites dropped entirely (subject not present in this repo):
- upload.test.ts — tested hasMagicBytes; this repo's lib/upload.ts is
  only the multer middleware and exports no magic-byte checker.
- userSettings.test.ts — tested resolveTabularModel (fork-only keyed-
  provider fallback); this repo resolves tabular_model via
  resolveModel with a static default.

Coverage ratchet: vitest.config.mts adds v8 coverage over src/lib/**
with floors measured against this tree (2.58% stmts, 2.00% branches,
4.61% funcs, 2.58% lines -> floors 2/2/4/2). Full suite: 5 files,
63 tests passing (incl. the pre-existing 12 in downloadTokens.test.ts);
npm run test:coverage and npm run build both pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 10:49:27 -07:00
QA Runner
15b7b4c925 docs: testing policy in CONTRIBUTING + PR template with verification checklist
Adds a Testing section documenting every suite the testing PR series
introduces (unit/integration via vitest, Playwright e2e, offline evals,
gated real-Supabase stack tests), the expectation that changes carry tests
at the lowest layer that catches the regression, and a PR template (ported
from the amal66 fork, Open-Legal-Products/mike#205) whose checklist asks how
the change was verified. Intended as the capstone of the series — the
commands it documents are introduced by the sibling test PRs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 10:46:47 -07:00
QA Runner
b20109ac6c ci: build and test workflow for backend and frontend
Ported from amal66/mike#46 onto current main, extended for this tree:
backend job runs npm ci, tests (--if-present, so it is safe to merge in any
order relative to the test-harness PR) and tsc build; frontend job runs
tests, eslint as an advisory step (main currently carries 23 lint errors —
flip to blocking once burned down), and a production next build with
placeholder NEXT_PUBLIC_* env (verified locally that the build succeeds and
contacts nothing); evals job runs node evals/run.mjs when present, else
skips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 10:45:48 -07:00
QA Runner
4039b94980 test: minimal vitest harness for backend and frontend
Ported from amal66/mike#24 onto current main; lockfiles regenerated against
this tree. Adds vitest as a dev dependency with a `test` script in both
packages, excludes test files from the backend tsc build, and seeds one
suite per package (backend: downloadTokens, 12 tests; frontend: cn() utils,
8 tests). Verified locally: backend 12/12, frontend 8/8 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 10:42:28 -07:00
cosimoastrada
dafac6b0a4
Merge pull request #219 from Open-Legal-Products/quick-fixes
feat: refresh workflows and workflow editor UI
2026-07-20 03:06:16 +08:00
willchen96
fa21ac8fd7 feat: refresh workflows and workflow editor UI 2026-07-20 03:04:47 +08:00
cosimoastrada
0ed5050b21
Merge pull request #218 from Open-Legal-Products/readme-update
docs: update readme
2026-07-17 16:19:04 +08:00
willchen96
9eb63ef3fd docs: update readme 2026-07-17 16:18:29 +08:00
cosimoastrada
81590ea137
Merge pull request #216 from Open-Legal-Products/more-ui-updates
feat: refine liquid surfaces and document review panels
2026-07-17 01:25:02 +08:00
willchen96
f5abbac42c feat: refine liquid surfaces and document review panels 2026-07-17 01:22:12 +08:00
cosimoastrada
1d61634a37
Merge pull request #215 from Open-Legal-Products/library-ui-updates
feat: add library and refresh shared table UI
2026-07-16 20:09:55 +08:00
willchen96
f0b90ab3b4 feat: add library and refresh shared table UI 2026-07-16 20:07:12 +08:00
JJ
cfdcda6d2c fix(db): add missing chat_messages.workflow column
User messages are persisted with a `workflow` field
(backend/src/routes/chat.ts, projectChat.ts) and it is read back when
rendering chat history (ChatView -> UserMessage) to show which workflow a
message was sent under. But the column is never created by schema.sql or any
migration, so every user-message insert fails with PostgREST PGRST204
("Could not find the 'workflow' column of 'chat_messages'") and is dropped
silently (the insert result is not checked). The assistant insert has no
workflow column, so it succeeds — the net effect on a self-hosted install is
that reloading a thread shows the assistant reply but not the user's prompt.

Add the `workflow jsonb` column to schema.sql (fresh installs) and a
migration (existing installs), mirroring the adjacent content/files jsonb
columns.
2026-07-16 07:44:25 +10:00
cosimoastrada
e32daad5a4
Merge pull request #206 from Open-Legal-Products/workflows-ui-excel-ppt-updates
Workflows UI excel ppt updates
2026-07-08 18:30:54 +08:00
willchen96
82dcaefc43 feat: workflow, UI and document support updates 2026-07-08 18:27:28 +08:00
willchen96
a5fe6d6e04 Sync workflow, asst extra input, excel + ppt support and modal updates 2026-07-04 23:24:31 +08:00
cosimoastrada
93f921be90
Merge pull request #147 from willchen96/add-security-reporting-guidance
docs: add security reporting guidance
2026-06-27 03:01:04 +08:00
cosimoastrada
457d4a18a4
Merge pull request #183 from willchen96/mcp-connectors
refactor: add table primitive and migrations by date; feat: add mcp connectors
2026-06-15 17:45:31 +08:00
willchen96
9a1277ba99 refactor: add table primitive and migrations by date; feat: add mcp connectors 2026-06-15 17:34:58 +08:00
cosimoastrada
01dfcfe0d4
Merge pull request #180 from willchen96/ui-fixes-modals-headers
Modal, header, mobile display and workflow UI updates
2026-06-11 22:44:35 +08:00
willchen96
3132e04ac0 Modal, header, mobile display and workflow UI updates 2026-06-11 22:43:13 +08:00
cosimoastrada
8a2dc05181
Merge pull request #178 from willchen96/feat/mfa-data-deletion-and-exports
Refactor ProjectPageParts and ProjectPageHeader components
2026-06-11 22:24:20 +08:00
willchen96
1fa0554ea5 Refactor ProjectPageParts and ProjectPageHeader components for improved loading states and skeleton UI. Update Modal and PageHeader components to support loading states. Enhance RenameableTitle for better caret positioning. Adjust DisplayWorkflowModal to utilize the new Modal component structure. Update WorkflowList to include loading indicators and improve sticky header behavior. 2026-06-11 21:50:58 +08:00
cosimoastrada
a211b92f38
Merge pull request #172 from willchen96/feat/mfa-data-deletion-and-exports
feat: implement multi-factor authentication (MFA) setup and verification flow and data deletion and export
2026-06-10 20:46:45 +08:00
willchen96
444d1d38e4 feat: enhance user profile management and MFA login flow
- Refactor user profile loading and updating logic to improve state management and reduce unnecessary checks.
- Update MFA login gate to streamline verification checks and improve user experience.
- Ensure consistent handling of user ID across profile context and components.
- Improve error handling and loading states in user-related API calls.
2026-06-10 18:55:33 +08:00
willchen96
3a10943200 feat: implement multi-factor authentication (MFA) setup and verification flow
- Add SecurityPage component for managing MFA settings, including enrollment and verification.
- Create MfaLoginGate to handle MFA verification state during login.
- Develop MfaVerificationPopup for user input of verification codes.
- Implement VerifyMfaPage for the MFA verification process after login.
- Introduce reusable VerificationCodeInput component for entering verification codes.
- Integrate Supabase MFA API for managing factors and verification.
- Add loading states and error handling for a better user experience.
2026-06-10 03:48:08 +08:00
cosimoastrada
15c96b0dd4
Merge pull request #171 from willchen96/feat/courtlistener-versioning-liquid-glass
Add courtlistener intergration, liquid glass redesign, UI improvements, version control, various fixes
2026-06-09 01:48:40 +08:00
willchen96
f32a194b33 Sync CourtListener verification and document safety updates
- Refine CourtListener citation verification, bulk lookup logging, and API fallback behavior
- Persist cancelled chat stream output and render cancellation as the final assistant message
- Add document/version deletion safety fixes and shared warning/modal UI updates
- Sync document panel, case law panel, and response UI styling refinements
- Harden OSS sync script to preserve local env, dependency, and generated files
2026-06-09 01:46:58 +08:00
willchen96
44e868eb42 Add courtlistener intergration, liquid glass redesign, UI improvements, version control, various fixes 2026-06-06 15:48:47 +08:00
cosimoastrada
d39f5806e5
Merge pull request #148 from willchen96/document-ui-tabular-updates
Update document UI, tabular reviews, and storage caching
2026-05-18 00:25:08 +08:00
willchen96
4f3384334a Update document UI, tabular reviews, and storage caching 2026-05-18 00:21:40 +08:00
willchen96
f656e14ef7 docs: add security reporting guidance 2026-05-17 01:57:19 +08:00
cosimoastrada
2bbb628891
Merge pull request #146 from willchen96/require-download-signing-secret
fix: require dedicated download signing secret
2026-05-17 01:06:53 +08:00
willchen96
ea48cdedd5 fix: require dedicated download signing secret 2026-05-17 01:05:01 +08:00
cosimoastrada
2f24cae407
Merge pull request #139 from willchen96/add-contributing-guide
docs: add contributing guide
2026-05-16 01:48:03 +08:00
willchen96
b685e86028 docs: add contributing guide 2026-05-16 01:47:22 +08:00
cosimoastrada
4ba4d53c38
Merge pull request #138 from willchen96/supabase-env-cleanup
fix: enforce SUPABASE_URL and SUPABASE_SECRET_KEY presence in server-side client; remove unused supabase-server.ts file
2026-05-16 01:16:51 +08:00