Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/merge-tests-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ jobs:
if: always()
uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1
with:
args: ${{ steps.detect-lcov.outputs.sonar_args }}
args: >-
${{ steps.detect-lcov.outputs.sonar_args }}
-Dsonar.qualitygate.wait=true
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/sonar-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:
if: always()
uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1
with:
args: ${{ steps.detect-lcov.outputs.sonar_args }}
args: >-
${{ steps.detect-lcov.outputs.sonar_args }}
-Dsonar.qualitygate.wait=true
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion app/auth/callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function AuthCallback() {
}
}

handleCallback()
void handleCallback()
}, [router])

return (
Expand Down
2 changes: 1 addition & 1 deletion db_audit_scripts/security-audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ async function securityAudit() {
}
}

securityAudit()
void securityAudit()
29 changes: 29 additions & 0 deletions docs/ai/design/feature-sonar-main-green.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
phase: design
title: Main Sonar Quality Gate Design
---

# Promise ownership and the gate boundary

```mermaid
flowchart LR
OAuth[OAuth start] --> Await[Await navigation]
Await --> Caller[Caller handles failure]
UI[UI refresh] --> Owned[Handler or Query handles errors]
Owned --> Void[Explicit background intent]
Scan[Upload analysis and both LCOV reports] --> Wait[Wait for remote quality gate]
Wait --> Result[CI succeeds or fails with the gate]
```

NavigationAdapter permits Promise<void> or void; OAuthAdapter always returns a
promise, so its start method must await navigation. Export loading, auth
callback and the audit CLI already own their catches. TanStack Query refetches
catch fetch errors when throwOnError is false (the existing default), retain
error state, and intentionally run independently of mutation success callbacks.
Explicit void records that ownership; it does not add catch-and-ignore logic,
change query defaults, or delay saves until refetch completion.

Keep canonical CommonJS entry detection and the operator-controlled argv-list
runner unless evidence identifies a real defect. Classify confirmed analyzer
errors individually, with comments documenting the trust boundary and runtime
proof; never disable a rule or change severity to satisfy the gate.
24 changes: 24 additions & 0 deletions docs/ai/implementation/feature-sonar-main-green.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
phase: implementation
title: Main Sonar Quality Gate Implementation
---

# Changes

Based on main 4c734702412c5b948fc268b37a93043d84a61378.
OAuth now awaits NavigationAdapter. Two new tests first demonstrated premature
success and lost rejection; all five adapter cases pass after the change.

Explicit void annotations preserve existing background behavior in note/tag
cache invalidations, FTS refetch, export page loading, auth callback startup
and the audit CLI. The installed QueryClient.refetchQueries uses catch(noop)
when throwOnError is absent; invalidateQueries delegates to that method.
Export/auth/audit functions already catch their own errors. The audit script
is not executed against a real database during validation.

Both Sonar scanner workflows pass sonar.qualitygate.wait=true in addition to
unchanged detected LCOV paths. This makes the job reflect the service gate
instead of only upload success. Rules, thresholds, new-code period, fixtures,
assertions, retries, timeouts and coverage inclusion remain unchanged.

False-positive review remains pending; no issue is accepted as debt or hidden.
16 changes: 16 additions & 0 deletions docs/ai/planning/feature-sonar-main-green.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
phase: planning
title: Main Sonar Quality Gate Plan
---

# Work plan

- [x] Refresh exact main SHA, quality-gate conditions and all 15 bug/security issues.
- [x] Preserve worktrees/preview and create sibling codex/sonar-main-green.
- [x] Reproduce OAuth completion/rejection loss with two failing tests; implement await.
- [x] Make existing handled background promise ownership explicit at the other 12 sites.
- [x] Add PR/main quality-gate waiting without changing criteria or coverage.
- [ ] Review two false-positive candidates with auditable evidence in owner Sonar session.
- [x] Validate 29 unit cases and 32 unchanged browser cases, types/lint/workflows.
- [ ] Publish PR, require fresh full CI, merge with exact-head guard.
- [ ] Confirm actual main Sonar gate OK, external check success, and complete tests.
18 changes: 18 additions & 0 deletions docs/ai/requirements/feature-sonar-main-green.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
phase: requirements
title: Main Sonar Quality Gate Requirements
---

# Main Sonar quality gate

Make the actual SonarCloud main quality gate green, preserving its rules,
thresholds, baseline period, source scope and coverage. The previous-version
period starts 2026-03-05. At main 4c734702412 it reports C reliability/C security,
13 floating-promise findings and two findings requiring evidence-based review.

- Propagate asynchronous OAuth navigation failure and completion to its caller.
- Keep already-handled UI refreshes asynchronous without blocking note saves.
- Review only proven false positives with retained rationale and audit history.
- Make PR/main scanner jobs wait for the remote quality-gate result.
- Merge only after fresh remaining PR checks pass; verify actual main gate OK,
not just successful report upload. Keep all 1,146 component cases.
38 changes: 38 additions & 0 deletions docs/ai/testing/feature-sonar-main-green.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
phase: testing
title: Main Sonar Quality Gate Testing
---

# Validation scope

- OAuth adapter: five cases, including two new completion/rejection regressions.
Before fix: two failed, three passed. After fix: five passed, matched scope,
complete Allure modeling, no findings.
- Adjacent unit scope: 29 cases across OAuth, note mutations and both auth
callback suites (27 baseline cases plus two new regressions).
- Browser scope: 32 unchanged cases: export selection 5, note mutations 10,
search results 17. All use synthetic mocks, without a live database audit.
- Full fresh GitHub CI must retain all 1,146 component identities and all
existing Jest cases, plus the two new OAuth regressions.
- Type-check, ESLint and actionlint for both changed workflows.
- Verify successful remote PR/main quality gates separately from scanner upload.

# Boundaries

No test assertions, retries, timeouts, fixtures or coverage are reduced.
The background-ownership annotations preserve existing catches and refetch
error state; they do not implement new swallowing of failures. Audit CLI is
reviewed statically and is not run against real data. Native full Jest totals
remain independent of the existing 60 plain-jsdom cases that do not emit Allure.

# Results

All 29 adjacent unit cases and all 32 unchanged browser cases passed. Both
Allure runs matched their expected scope, modeled every result, and reported
zero findings, retries, flaky tests, skips or runner failures. Type-check,
targeted ESLint, actionlint for both workflows, git diff --check and all seven
AI DevKit base documentation checks passed.

Evidence: sonar-main-green/unit-green/index.md and
sonar-main-green/component-green/index.md under the task evidence directory.
False-positive classification, fresh CI and the merged main gate are pending.
2 changes: 1 addition & 1 deletion ui/web/adapters/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const webOAuthAdapter: OAuthAdapter = {
// assign, not replace: this is exactly what supabase-js does when it performs the
// redirect itself (GoTrueClient calls window.location.assign), so routing through
// the adapter leaves browser history behaving as it did before.
webNavigationAdapter.navigate(authUrl)
await webNavigationAdapter.navigate(authUrl)
},
}

Expand Down
4 changes: 2 additions & 2 deletions ui/web/components/ExportSelectionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ export function ExportSelectionDialog({ open, onOpenChange, onExport }: ExportSe
setSelectAll(false)
setPage(0)
setInitialLoading(true)
loadPage(0)
void loadPage(0)
}
}, [open, loadPage])

const handleScroll = (event: React.UIEvent<HTMLDivElement>) => {
const target = event.currentTarget
const nearBottom = target.scrollTop + target.clientHeight >= target.scrollHeight - 200
if (nearBottom && hasMore && !loading) {
loadPage(page)
void loadPage(page)
}
}

Expand Down
4 changes: 2 additions & 2 deletions ui/web/components/features/notes/SearchResultsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export const SearchResultsPanel = React.forwardRef<SearchResultsPanelHandle, Sea
if (wasAIEnabled && !aiEnabled) {
controller.handleSearch(normalizedQuery)
if (normalizedQuery === searchQuery.trim()) {
ftsSearchResult?.refetch()
void ftsSearchResult?.refetch()
}
}
prevAiEnabledRef.current = aiEnabled
Expand All @@ -378,7 +378,7 @@ export const SearchResultsPanel = React.forwardRef<SearchResultsPanelHandle, Sea
controller.handleSearch(normalizedQuery)
// If query is the same, force a fresh FTS fetch
if (normalizedQuery === searchQuery.trim()) {
ftsSearchResult?.refetch()
void ftsSearchResult?.refetch()
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions ui/web/hooks/useNotesMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
const noteService = useMemo(() => new NoteService(supabase), [supabase])

return useMutation({
mutationFn: async (params: CreateNoteParams) => {

Check warning on line 84 in ui/web/hooks/useNotesMutations.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Async method 'mutationFn' has no 'await' expression.

See more on https://sonarcloud.io/project/issues?id=koreyba_EverFreeNote&issues=AaGnX_Grrbquqkct2JA2&open=AaGnX_Grrbquqkct2JA2&pullRequest=211
return noteService.createNote(params)
},

Expand Down Expand Up @@ -142,8 +142,8 @@

// Refetch on success
onSuccess: (_data, params) => {
queryClient.invalidateQueries({ queryKey: ['notes'] })
queryClient.invalidateQueries({ queryKey: ['tags', 'all-with-counts'] })
void queryClient.invalidateQueries({ queryKey: ['notes'] })
void queryClient.invalidateQueries({ queryKey: ['tags', 'all-with-counts'] })
if (!params.silent) callbacks.onSuccess?.()
},
})
Expand All @@ -155,7 +155,7 @@
const noteService = useMemo(() => new NoteService(supabase), [supabase])

return useMutation({
mutationFn: async (params: UpdateNoteParams) => {

Check warning on line 158 in ui/web/hooks/useNotesMutations.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Async method 'mutationFn' has no 'await' expression.

See more on https://sonarcloud.io/project/issues?id=koreyba_EverFreeNote&issues=AaGnX_Grrbquqkct2JA3&open=AaGnX_Grrbquqkct2JA3&pullRequest=211
return noteService.updateNote(params.id, {
...(params.title !== undefined ? { title: params.title } : {}),
...(params.description !== undefined ? { description: params.description } : {}),
Expand Down Expand Up @@ -204,8 +204,8 @@

onSuccess: (_data, params) => {
if (!params.deferCacheRefresh) {
queryClient.invalidateQueries({ queryKey: ['notes'] })
queryClient.invalidateQueries({ queryKey: ['tags', 'all-with-counts'] })
void queryClient.invalidateQueries({ queryKey: ['notes'] })
void queryClient.invalidateQueries({ queryKey: ['tags', 'all-with-counts'] })
}
if (!params.silent) callbacks.onSuccess?.()
},
Expand All @@ -223,7 +223,7 @@
const noteService = useMemo(() => new NoteService(supabase), [supabase])

return useMutation({
mutationFn: async ({ id }: DeleteNoteParams) => {

Check warning on line 226 in ui/web/hooks/useNotesMutations.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Async method 'mutationFn' has no 'await' expression.

See more on https://sonarcloud.io/project/issues?id=koreyba_EverFreeNote&issues=AaGnX_Grrbquqkct2JA4&open=AaGnX_Grrbquqkct2JA4&pullRequest=211
return noteService.deleteNote(id)
},

Expand Down Expand Up @@ -280,7 +280,7 @@
const noteService = useMemo(() => new NoteService(supabase), [supabase])

return useMutation({
mutationFn: async ({ noteId, updatedTags }: { noteId: string; updatedTags: string[] }) => {

Check warning on line 283 in ui/web/hooks/useNotesMutations.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Async method 'mutationFn' has no 'await' expression.

See more on https://sonarcloud.io/project/issues?id=koreyba_EverFreeNote&issues=AaGnX_Grrbquqkct2JA5&open=AaGnX_Grrbquqkct2JA5&pullRequest=211
return noteService.updateNote(noteId, { tags: updatedTags })
},

Expand Down Expand Up @@ -319,8 +319,8 @@
},

onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['notes'] })
queryClient.invalidateQueries({ queryKey: ['tags', 'all-with-counts'] })
void queryClient.invalidateQueries({ queryKey: ['notes'] })
void queryClient.invalidateQueries({ queryKey: ['tags', 'all-with-counts'] })
callbacks.onSuccess?.()
},
})
Expand Down
28 changes: 28 additions & 0 deletions ui/web/tests/unit/adapters/oauth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ jest.mock('@ui/shell/runtime/platform', () => ({
jest.mock('@ui/shell/runtime/oauth', () => ({ nativeOAuthAdapter: { startOAuth: jest.fn() } }))

describe('web OAuth adapter', () => {
it('waits for asynchronous navigation before reporting that OAuth started', async () => {
let finish!: () => void
const navigation = new Promise<void>(resolve => { finish = resolve })
jest.mocked(webNavigationAdapter.navigate).mockReturnValueOnce(navigation)
let settled = false
const started = webOAuthAdapter.startOAuth('https://provider.example/authorize').then(() => { settled = true })

try {
await Promise.resolve()
await Promise.resolve()
expect(settled).toBe(false)
finish()
await started
expect(settled).toBe(true)
} finally { finish() }
})

it('propagates asynchronous navigation failure to the OAuth caller', async () => {
const failure = new Error('Navigation failed')
const navigation = Promise.reject(failure)
// Observe the controlled child rejection even before the adapter is fixed;
// the public adapter promise must independently preserve that rejection.
void navigation.catch(() => undefined)
jest.mocked(webNavigationAdapter.navigate).mockReturnValueOnce(navigation)

await expect(webOAuthAdapter.startOAuth('https://provider.example/authorize')).rejects.toBe(failure)
})

it('navigates the page to the provider the same way supabase-js would', async () => {
await webOAuthAdapter.startOAuth('https://provider.example/authorize')

Expand Down
Loading