@@ -1859,6 +1859,53 @@ static bool app_env_backup_restore(app_env_backup_t *backup) {
18591859 return status == 0 ;
18601860}
18611861
1862+ /* The Graph UI enters through the daemon's background coordinator rather than
1863+ * the MCP tool path. Keep that path UTF-8-safe as well. */
1864+ TEST (daemon_application_ui_index_accepts_non_ascii_directory ) {
1865+ app_env_backup_t cache_environment ;
1866+ bool cache_saved = app_env_backup_capture (& cache_environment , "CBM_CACHE_DIR" );
1867+ char root [APP_TEST_PATH_CAP ];
1868+ char cache [APP_TEST_PATH_CAP ];
1869+ (void )snprintf (root , sizeof (root ),
1870+ "%s/cbm-app-ui-index-\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E-XXXXXX" , cbm_tmpdir ());
1871+ (void )snprintf (cache , sizeof (cache ), "%s/cbm-app-ui-index-cache-XXXXXX" , cbm_tmpdir ());
1872+ bool dirs_created = cbm_mkdtemp (root ) != NULL && cbm_mkdtemp (cache ) != NULL ;
1873+ bool cache_set = cache_saved && dirs_created && cbm_setenv ("CBM_CACHE_DIR" , cache , 1 ) == 0 ;
1874+
1875+ app_fake_worker_context_t fake ;
1876+ app_fake_worker_context_init (& fake );
1877+ atomic_store (& fake .allow_completion , true);
1878+ cbm_daemon_application_worker_ops_t worker_ops = {
1879+ .context = & fake ,
1880+ .start = app_fake_worker_start ,
1881+ .poll = app_fake_worker_poll ,
1882+ .cancel = app_fake_worker_cancel ,
1883+ .log_path = app_fake_worker_log_path ,
1884+ .destroy = app_fake_worker_destroy ,
1885+ };
1886+ cbm_daemon_application_config_t config = {.worker_ops = & worker_ops };
1887+ cbm_daemon_application_t * application = cache_set ? cbm_daemon_application_new (& config ) : NULL ;
1888+ int result = application ? cbm_daemon_application_index (application , "" , root ) : -1 ;
1889+ bool stopped = application && cbm_daemon_application_shutdown (application , APP_TEST_TIMEOUT_MS );
1890+ cbm_daemon_application_free (application );
1891+ bool root_cleaned = th_rmtree (root ) == 0 ;
1892+ bool cache_cleaned = th_rmtree (cache ) == 0 ;
1893+ bool cache_restored = app_env_backup_restore (& cache_environment );
1894+
1895+ ASSERT_TRUE (cache_saved );
1896+ ASSERT_TRUE (dirs_created );
1897+ ASSERT_TRUE (cache_set );
1898+ ASSERT_NOT_NULL (application );
1899+ ASSERT_EQ (result , 0 );
1900+ ASSERT_EQ (atomic_load (& fake .starts ), 1 );
1901+ ASSERT_EQ (atomic_load (& fake .destroys ), 1 );
1902+ ASSERT_TRUE (stopped );
1903+ ASSERT_TRUE (root_cleaned );
1904+ ASSERT_TRUE (cache_cleaned );
1905+ ASSERT_TRUE (cache_restored );
1906+ PASS ();
1907+ }
1908+
18621909typedef struct {
18631910 atomic_int starts ;
18641911 atomic_int start_failures_remaining ;
@@ -5652,6 +5699,7 @@ SUITE(daemon_application) {
56525699 RUN_TEST (daemon_application_initialize_coalesces_auto_index_for_full_sessions );
56535700 RUN_TEST (daemon_application_sensitive_root_blocks_auto_index_but_preserves_controls );
56545701 RUN_TEST (daemon_application_sensitive_root_blocks_watch_but_preserves_controls );
5702+ RUN_TEST (daemon_application_ui_index_accepts_non_ascii_directory );
56555703 RUN_TEST (daemon_application_index_args_compare_repo_path_separator_equivalently );
56565704 RUN_TEST (daemon_application_programmatic_index_injects_resource_policy );
56575705 RUN_TEST (daemon_application_auto_index_honors_tracked_file_limit );
0 commit comments