@@ -3250,34 +3250,45 @@ function registerIpc(): void {
32503250 return await deleteWorkflowRuns ( v . root , workflowId ) ;
32513251 } ) ;
32523252
3253- // Custom templates live on the local filesystem only; remote vaults fall
3254- // back to built-in templates (renderer constants), so list returns empty and
3255- // mutations are rejected.
3253+ const requireRemoteTemplates = ( ) => {
3254+ const client = requireRemoteWorkspaceClient ( ) ;
3255+ if ( ! remoteServerCapabilities ?. supportsCustomTemplates ) {
3256+ throw new Error (
3257+ "Custom templates need a newer ZenNotes server. Update the server and reconnect." ,
3258+ ) ;
3259+ }
3260+ return client ;
3261+ } ;
3262+
32563263 handle ( IPC . VAULT_LIST_TEMPLATES , async ( ) => {
3257- if ( isRemoteWorkspaceActive ( ) ) return [ ] ;
3264+ if ( isRemoteWorkspaceActive ( ) ) {
3265+ return remoteServerCapabilities ?. supportsCustomTemplates
3266+ ? await requireRemoteWorkspaceClient ( ) . listTemplates ( )
3267+ : [ ] ;
3268+ }
32583269 const v = requireVault ( ) ;
32593270 return await listCustomTemplates ( v . root ) ;
32603271 } ) ;
32613272
32623273 handle ( IPC . VAULT_READ_TEMPLATE , async ( _e , sourcePath : string ) => {
32633274 if ( isRemoteWorkspaceActive ( ) ) {
3264- throw new Error ( "Custom templates are unavailable on remote vaults" ) ;
3275+ return await requireRemoteTemplates ( ) . readTemplate ( sourcePath ) ;
32653276 }
32663277 const v = requireVault ( ) ;
32673278 return await readCustomTemplate ( v . root , sourcePath ) ;
32683279 } ) ;
32693280
32703281 handle ( IPC . VAULT_WRITE_TEMPLATE , async ( _e , input : WriteTemplateInput ) => {
32713282 if ( isRemoteWorkspaceActive ( ) ) {
3272- throw new Error ( "Custom templates are unavailable on remote vaults" ) ;
3283+ return await requireRemoteTemplates ( ) . writeTemplate ( input ) ;
32733284 }
32743285 const v = requireVault ( ) ;
32753286 return await writeCustomTemplate ( v . root , input ) ;
32763287 } ) ;
32773288
32783289 handle ( IPC . VAULT_DELETE_TEMPLATE , async ( _e , sourcePath : string ) => {
32793290 if ( isRemoteWorkspaceActive ( ) ) {
3280- throw new Error ( "Custom templates are unavailable on remote vaults" ) ;
3291+ return await requireRemoteTemplates ( ) . deleteTemplate ( sourcePath ) ;
32813292 }
32823293 const v = requireVault ( ) ;
32833294 return await deleteCustomTemplate ( v . root , sourcePath ) ;
0 commit comments