fix: title update for import definitions
This commit is contained in:
@@ -842,7 +842,7 @@ export function registerIpcHandlers(): void {
|
|||||||
return engine.getAllForProject();
|
return engine.getAllForProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
safeHandle('importDefinitions:update', async (_, id: string, updates: any) => {
|
safeHandle('importDefinitions:update', async (event, id: string, updates: any) => {
|
||||||
const { ImportDefinitionEngine } = await import('../engine/ImportDefinitionEngine');
|
const { ImportDefinitionEngine } = await import('../engine/ImportDefinitionEngine');
|
||||||
const engine = new ImportDefinitionEngine();
|
const engine = new ImportDefinitionEngine();
|
||||||
const projectEngine = getProjectEngine();
|
const projectEngine = getProjectEngine();
|
||||||
@@ -850,7 +850,12 @@ export function registerIpcHandlers(): void {
|
|||||||
if (activeProject) {
|
if (activeProject) {
|
||||||
engine.setProjectContext(activeProject.id);
|
engine.setProjectContext(activeProject.id);
|
||||||
}
|
}
|
||||||
return engine.updateDefinition(id, updates);
|
const result = await engine.updateDefinition(id, updates);
|
||||||
|
// Notify renderer of name changes for sidebar/tab updates
|
||||||
|
if (result && updates.name !== undefined) {
|
||||||
|
event.sender.send('importDefinition-name-updated', { definitionId: id, name: result.name });
|
||||||
|
}
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
safeHandle('importDefinitions:delete', async (_, id: string) => {
|
safeHandle('importDefinitions:delete', async (_, id: string) => {
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
getAll: () => ipcRenderer.invoke('importDefinitions:getAll'),
|
getAll: () => ipcRenderer.invoke('importDefinitions:getAll'),
|
||||||
update: (id: string, updates: unknown) => ipcRenderer.invoke('importDefinitions:update', id, updates),
|
update: (id: string, updates: unknown) => ipcRenderer.invoke('importDefinitions:update', id, updates),
|
||||||
delete: (id: string) => ipcRenderer.invoke('importDefinitions:delete', id),
|
delete: (id: string) => ipcRenderer.invoke('importDefinitions:delete', id),
|
||||||
|
onNameUpdated: (callback: (data: { definitionId: string; name: string }) => void) => {
|
||||||
|
const subscription = (_event: Electron.IpcRendererEvent, data: { definitionId: string; name: string }) => callback(data);
|
||||||
|
ipcRenderer.on('importDefinition-name-updated', subscription);
|
||||||
|
return () => ipcRenderer.removeListener('importDefinition-name-updated', subscription);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// AI Chat (OpenCode Zen API integration)
|
// AI Chat (OpenCode Zen API integration)
|
||||||
|
|||||||
@@ -1293,6 +1293,23 @@ const ImportList: React.FC = () => {
|
|||||||
init();
|
init();
|
||||||
}, [loadDefinitions]);
|
}, [loadDefinitions]);
|
||||||
|
|
||||||
|
// Listen for import definition name updates
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = window.electronAPI?.importDefinitions.onNameUpdated((data) => {
|
||||||
|
setDefinitions(prev =>
|
||||||
|
prev.map(def =>
|
||||||
|
def.id === data.definitionId
|
||||||
|
? { ...def, name: data.name }
|
||||||
|
: def
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub?.();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleNewDefinition = async () => {
|
const handleNewDefinition = async () => {
|
||||||
try {
|
try {
|
||||||
const def = await window.electronAPI?.importDefinitions.create();
|
const def = await window.electronAPI?.importDefinitions.create();
|
||||||
|
|||||||
@@ -204,6 +204,21 @@ export const TabBar: React.FC = () => {
|
|||||||
fetchTitles();
|
fetchTitles();
|
||||||
}, [tabs]); // Note: intentionally not including importDefTitles to avoid infinite loops
|
}, [tabs]); // Note: intentionally not including importDefTitles to avoid infinite loops
|
||||||
|
|
||||||
|
// Listen for import definition name updates
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = window.electronAPI?.importDefinitions.onNameUpdated((data) => {
|
||||||
|
setImportDefTitles(prev => {
|
||||||
|
const newTitles = new Map(prev);
|
||||||
|
newTitles.set(data.definitionId, data.name);
|
||||||
|
return newTitles;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub?.();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Check if arrows are needed based on scroll position
|
// Check if arrows are needed based on scroll position
|
||||||
const updateArrowVisibility = useCallback(() => {
|
const updateArrowVisibility = useCallback(() => {
|
||||||
const container = tabsContainerRef.current;
|
const container = tabsContainerRef.current;
|
||||||
|
|||||||
1
src/renderer/types/electron.d.ts
vendored
1
src/renderer/types/electron.d.ts
vendored
@@ -403,6 +403,7 @@ export interface ElectronAPI {
|
|||||||
getAll: () => Promise<ImportDefinitionData[]>;
|
getAll: () => Promise<ImportDefinitionData[]>;
|
||||||
update: (id: string, updates: Partial<Pick<ImportDefinitionData, 'name' | 'wxrFilePath' | 'uploadsFolderPath' | 'lastAnalysisResult'>>) => Promise<ImportDefinitionData | null>;
|
update: (id: string, updates: Partial<Pick<ImportDefinitionData, 'name' | 'wxrFilePath' | 'uploadsFolderPath' | 'lastAnalysisResult'>>) => Promise<ImportDefinitionData | null>;
|
||||||
delete: (id: string) => Promise<boolean>;
|
delete: (id: string) => Promise<boolean>;
|
||||||
|
onNameUpdated: (callback: (data: { definitionId: string; name: string }) => void) => () => void;
|
||||||
};
|
};
|
||||||
chat: {
|
chat: {
|
||||||
// API Key Management
|
// API Key Management
|
||||||
|
|||||||
Reference in New Issue
Block a user