@@ -1823,6 +1823,53 @@ static bool app_env_backup_restore(app_env_backup_t *backup) {
18231823 return status == 0 ;
18241824}
18251825
1826+ /* The Graph UI enters through the daemon's background coordinator rather than
1827+ * the MCP tool path. Keep that path UTF-8-safe as well. */
1828+ TEST (daemon_application_ui_index_accepts_non_ascii_directory ) {
1829+ app_env_backup_t cache_environment ;
1830+ bool cache_saved = app_env_backup_capture (& cache_environment , "CBM_CACHE_DIR" );
1831+ char root [APP_TEST_PATH_CAP ];
1832+ char cache [APP_TEST_PATH_CAP ];
1833+ (void )snprintf (root , sizeof (root ),
1834+ "%s/cbm-app-ui-index-\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E-XXXXXX" , cbm_tmpdir ());
1835+ (void )snprintf (cache , sizeof (cache ), "%s/cbm-app-ui-index-cache-XXXXXX" , cbm_tmpdir ());
1836+ bool dirs_created = cbm_mkdtemp (root ) != NULL && cbm_mkdtemp (cache ) != NULL ;
1837+ bool cache_set = cache_saved && dirs_created && cbm_setenv ("CBM_CACHE_DIR" , cache , 1 ) == 0 ;
1838+
1839+ app_fake_worker_context_t fake ;
1840+ app_fake_worker_context_init (& fake );
1841+ atomic_store (& fake .allow_completion , true);
1842+ cbm_daemon_application_worker_ops_t worker_ops = {
1843+ .context = & fake ,
1844+ .start = app_fake_worker_start ,
1845+ .poll = app_fake_worker_poll ,
1846+ .cancel = app_fake_worker_cancel ,
1847+ .log_path = app_fake_worker_log_path ,
1848+ .destroy = app_fake_worker_destroy ,
1849+ };
1850+ cbm_daemon_application_config_t config = {.worker_ops = & worker_ops };
1851+ cbm_daemon_application_t * application = cache_set ? cbm_daemon_application_new (& config ) : NULL ;
1852+ int result = application ? cbm_daemon_application_index (application , "" , root ) : -1 ;
1853+ bool stopped = application && cbm_daemon_application_shutdown (application , APP_TEST_TIMEOUT_MS );
1854+ cbm_daemon_application_free (application );
1855+ bool root_cleaned = th_rmtree (root ) == 0 ;
1856+ bool cache_cleaned = th_rmtree (cache ) == 0 ;
1857+ bool cache_restored = app_env_backup_restore (& cache_environment );
1858+
1859+ ASSERT_TRUE (cache_saved );
1860+ ASSERT_TRUE (dirs_created );
1861+ ASSERT_TRUE (cache_set );
1862+ ASSERT_NOT_NULL (application );
1863+ ASSERT_EQ (result , 0 );
1864+ ASSERT_EQ (atomic_load (& fake .starts ), 1 );
1865+ ASSERT_EQ (atomic_load (& fake .destroys ), 1 );
1866+ ASSERT_TRUE (stopped );
1867+ ASSERT_TRUE (root_cleaned );
1868+ ASSERT_TRUE (cache_cleaned );
1869+ ASSERT_TRUE (cache_restored );
1870+ PASS ();
1871+ }
1872+
18261873typedef struct {
18271874 atomic_int starts ;
18281875 atomic_int start_failures_remaining ;
@@ -5400,6 +5447,7 @@ SUITE(daemon_application) {
54005447 RUN_TEST (daemon_application_initialize_coalesces_auto_index_for_full_sessions );
54015448 RUN_TEST (daemon_application_sensitive_root_blocks_auto_index_but_preserves_controls );
54025449 RUN_TEST (daemon_application_sensitive_root_blocks_watch_but_preserves_controls );
5450+ RUN_TEST (daemon_application_ui_index_accepts_non_ascii_directory );
54035451 RUN_TEST (daemon_application_auto_index_honors_tracked_file_limit );
54045452 RUN_TEST (daemon_application_auto_index_file_count_handles_literal_metacharacter_path );
54055453 RUN_TEST (daemon_application_auto_index_file_count_supports_non_git_roots );
0 commit comments