diff --git a/app-modules/ai-agent/src/Filament/Pages/ManageSuggestions.php b/app-modules/ai-agent/src/Filament/Pages/ManageSuggestions.php index 4353e94..deb128e 100644 --- a/app-modules/ai-agent/src/Filament/Pages/ManageSuggestions.php +++ b/app-modules/ai-agent/src/Filament/Pages/ManageSuggestions.php @@ -328,7 +328,7 @@ class ManageSuggestions extends Page implements HasTable /** * Polls a sync job's status (wire:poll.2s, see the view). On "finished", * chains a reload-index call — same two-step flow shweai_backend's admin - * JS does (POST sync-chroma → poll → POST reload-index) — and refreshes + * JS does (POST sync → poll → POST reload-index) — and refreshes * the table. On "failed", notifies and stops polling. */ public function pollSyncStatus(): void diff --git a/app-modules/ai-agent/tests/Feature/ManageSuggestionsTest.php b/app-modules/ai-agent/tests/Feature/ManageSuggestionsTest.php index e610034..46a7e45 100644 --- a/app-modules/ai-agent/tests/Feature/ManageSuggestionsTest.php +++ b/app-modules/ai-agent/tests/Feature/ManageSuggestionsTest.php @@ -122,8 +122,8 @@ test('deleteSelected bulk action calls batchDeleteSuggestions with just the sele test('sync sets job state and polling chains a reload-index call on finished', function () { Http::fake(['bnfexpress.test/*' => fn (Request $request) => match (true) { - str_contains($request->url(), '/sync-chroma/job-1') => Http::response(['status' => 'finished', 'result' => ['synced' => 3]]), - str_contains($request->url(), '/sync-chroma') => Http::response(['job_id' => 'job-1'], 202), + str_contains($request->url(), '/sync/job-1') => Http::response(['status' => 'finished', 'result' => ['synced' => 3]]), + str_contains($request->url(), '/sync') => Http::response(['job_id' => 'job-1'], 202), str_contains($request->url(), '/reload-index') => Http::response(['trie_rebuilt' => true]), default => Http::response([]), }]); @@ -144,8 +144,8 @@ test('sync sets job state and polling chains a reload-index call on finished', f test('a failed sync job notifies danger and stops polling', function () { Http::fake(['bnfexpress.test/*' => fn (Request $request) => match (true) { - str_contains($request->url(), '/sync-chroma/job-1') => Http::response(['status' => 'failed', 'result' => null]), - str_contains($request->url(), '/sync-chroma') => Http::response(['job_id' => 'job-1'], 202), + str_contains($request->url(), '/sync/job-1') => Http::response(['status' => 'failed', 'result' => null]), + str_contains($request->url(), '/sync') => Http::response(['job_id' => 'job-1'], 202), default => Http::response([]), }]); @@ -182,6 +182,6 @@ test('syncEmbedding and deleteEmbedding row actions call the right per-id endpoi $test->callTableAction('syncEmbedding', 1)->assertNotified('Embedding synced'); $test->callTableAction('deleteEmbedding', 1)->assertNotified('Embedding deleted'); - Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/sync-chroma') && $request->method() === 'POST'); - Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/chroma') && $request->method() === 'DELETE'); + Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/sync') && $request->method() === 'POST'); + Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/embedding') && $request->method() === 'DELETE'); }); diff --git a/app-modules/shared/src/Bnfexpress/BnfexpressAdminClient.php b/app-modules/shared/src/Bnfexpress/BnfexpressAdminClient.php index f7b3873..dd14f33 100644 --- a/app-modules/shared/src/Bnfexpress/BnfexpressAdminClient.php +++ b/app-modules/shared/src/Bnfexpress/BnfexpressAdminClient.php @@ -282,7 +282,7 @@ class BnfexpressAdminClient */ public function syncSuggestions(): array { - return $this->request('POST', '/admin/suggestions/sync-chroma'); + return $this->request('POST', '/admin/suggestions/sync'); } /** @@ -290,7 +290,7 @@ class BnfexpressAdminClient */ public function getSuggestionSyncStatus(string $jobId): array { - return $this->request('GET', "/admin/suggestions/sync-chroma/{$jobId}"); + return $this->request('GET', "/admin/suggestions/sync/{$jobId}"); } /** @@ -298,7 +298,7 @@ class BnfexpressAdminClient */ public function syncOneSuggestion(int|string $id): array { - return $this->request('POST', "/admin/suggestions/{$id}/sync-chroma"); + return $this->request('POST', "/admin/suggestions/{$id}/sync"); } /** @@ -314,7 +314,7 @@ class BnfexpressAdminClient */ public function deleteSuggestionEmbedding(int|string $id): array { - return $this->request('DELETE', "/admin/suggestions/{$id}/chroma"); + return $this->request('DELETE', "/admin/suggestions/{$id}/embedding"); } // --- Request plumbing ------------------------------------------------ diff --git a/app-modules/shared/tests/Unit/BnfexpressAdminClientTest.php b/app-modules/shared/tests/Unit/BnfexpressAdminClientTest.php index 9ac1ec3..af416ed 100644 --- a/app-modules/shared/tests/Unit/BnfexpressAdminClientTest.php +++ b/app-modules/shared/tests/Unit/BnfexpressAdminClientTest.php @@ -175,13 +175,13 @@ test('promoteSuggestionMisses posts miss_ids with an optional lang/intent overri && $request->body() === json_encode(['miss_ids' => [1, 2], 'lang' => 'my'])); }); -test('syncSuggestions triggers a sync-chroma job and returns the job id', function () use ($config) { +test('syncSuggestions triggers a sync job and returns the job id', function () use ($config) { Http::fake(['bnfexpress.test/*' => Http::response(['job_id' => 'abc-123'], 202)]); $result = (new BnfexpressAdminClient($config))->syncSuggestions(); expect($result)->toBe(['job_id' => 'abc-123']); - Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync-chroma' + Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync' && $request->method() === 'POST'); }); @@ -191,7 +191,7 @@ test('getSuggestionSyncStatus polls the job status endpoint', function () use ($ $result = (new BnfexpressAdminClient($config))->getSuggestionSyncStatus('abc-123'); expect($result)->toBe(['status' => 'finished', 'result' => ['synced' => 3]]); - Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync-chroma/abc-123' + Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync/abc-123' && $request->method() === 'GET'); }); @@ -201,8 +201,8 @@ test('deleteSuggestionEmbedding signs a bodyless DELETE request', function () us (new BnfexpressAdminClient($config))->deleteSuggestionEmbedding(5); Http::assertSent(function ($request) use ($config) { - return $request->url() === 'https://bnfexpress.test/admin/suggestions/5/chroma' + return $request->url() === 'https://bnfexpress.test/admin/suggestions/5/embedding' && $request->method() === 'DELETE' - && assertSignedCorrectly($request, 'DELETE', '/admin/suggestions/5/chroma', '', $config['client_secret']); + && assertSignedCorrectly($request, 'DELETE', '/admin/suggestions/5/embedding', '', $config['client_secret']); }); });