From d41531526cf93a02320c01659907a64e2f44bf74 Mon Sep 17 00:00:00 2001 From: Yoan Bozhilov Date: Wed, 17 Jun 2026 10:25:21 +0300 Subject: [PATCH 1/2] feat(command): add context_chat:reindex to re-seed the crawl on demand The SchedulerJob -> StorageCrawlJob -> IndexerJob chain is seeded only by the repair step and self-removes after the initial crawl, so there is no way to re-enumerate mounts without reinstalling the app (e.g. after installing on an instance whose files predate the app, or to recover an incomplete crawl). Add an occ command that re-adds SchedulerJob (no-op if already scheduled); already-indexed files are skipped by the queue de-duplication. Refs #244 Signed-off-by: Yoan Bozhilov Assisted-by: Claude Code:claude-opus-4-8 --- appinfo/info.xml | 1 + lib/Command/Reindex.php | 51 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 lib/Command/Reindex.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 941ac62d..a1c960ab 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -50,6 +50,7 @@ Refer to the [Context Chat Backend's readme](https://github.com/nextcloud/contex OCA\ContextChat\Command\Prompt OCA\ContextChat\Command\Search OCA\ContextChat\Command\Statistics + OCA\ContextChat\Command\Reindex diff --git a/lib/Command/Reindex.php b/lib/Command/Reindex.php new file mode 100644 index 00000000..c6906a5c --- /dev/null +++ b/lib/Command/Reindex.php @@ -0,0 +1,51 @@ + StorageCrawlJob -> IndexerJob is seeded only by the repair step and + * removes itself once the initial crawl finishes. There is otherwise no way to re-enumerate + * mounts (e.g. after installing on an instance whose files predate the app, or to recover a crawl + * that did not complete) short of reinstalling the app. This command re-adds SchedulerJob so the + * full enumeration runs again; it is a no-op if one is already scheduled, and already-indexed + * files are skipped (the queue de-duplicates). + */ +class Reindex extends Command { + + public function __construct( + private IJobList $jobList, + ) { + parent::__construct(); + } + + protected function configure() { + $this->setName('context_chat:reindex') + ->setDescription('Schedule a full re-crawl of all mounts (re-seeds the indexing chain; indexed files are skipped)'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + if ($this->jobList->has(SchedulerJob::class, null)) { + $output->writeln('A full re-crawl is already scheduled; nothing to do.'); + return 0; + } + + $this->jobList->add(SchedulerJob::class); + $output->writeln('Scheduled a full re-crawl. SchedulerJob will enumerate all mounts on its next run.'); + return 0; + } +} From f2f9718523c68edec1a5e8becffa47f993de3331 Mon Sep 17 00:00:00 2001 From: Yoan Bozhilov Date: Mon, 29 Jun 2026 18:55:44 +0300 Subject: [PATCH 2/2] fix(command): apply review wording on reindex docstring and description Reword the class docstring and the command description per review feedback. Signed-off-by: Yoan Bozhilov Assisted-by: Claude Code:claude-opus-4-8 --- lib/Command/Reindex.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Command/Reindex.php b/lib/Command/Reindex.php index c6906a5c..1b816c15 100644 --- a/lib/Command/Reindex.php +++ b/lib/Command/Reindex.php @@ -16,14 +16,14 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Re-seed the one-shot crawl chain on demand. + * Re-seed the one-shot filesystem crawl/index on demand. * * SchedulerJob -> StorageCrawlJob -> IndexerJob is seeded only by the repair step and * removes itself once the initial crawl finishes. There is otherwise no way to re-enumerate * mounts (e.g. after installing on an instance whose files predate the app, or to recover a crawl * that did not complete) short of reinstalling the app. This command re-adds SchedulerJob so the * full enumeration runs again; it is a no-op if one is already scheduled, and already-indexed - * files are skipped (the queue de-duplicates). + * files are skipped. */ class Reindex extends Command { @@ -35,7 +35,7 @@ public function __construct( protected function configure() { $this->setName('context_chat:reindex') - ->setDescription('Schedule a full re-crawl of all mounts (re-seeds the indexing chain; indexed files are skipped)'); + ->setDescription('Schedule a full re-crawl of all mounts. Indexed files are not re-indexed when compared against context_chat_backend\'s vector DB.'); } protected function execute(InputInterface $input, OutputInterface $output): int {