fix: refresh session name in sidebar after rename (#9543)
Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,11 @@ const SessionRow: React.FC<SessionRowProps> = ({ session, active, status, onClic
|
||||
path: { session_id: session.id },
|
||||
body: { name: newName },
|
||||
});
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(AppEvents.SESSION_RENAMED, {
|
||||
detail: { sessionId: session.id, newName, userInitiated: true },
|
||||
})
|
||||
);
|
||||
onRenamed();
|
||||
}}
|
||||
placeholder={intl.formatMessage(i18n.untitledSession)}
|
||||
|
||||
@@ -458,11 +458,13 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
|
||||
const handleModalSave = useCallback(async (sessionId: string, newDescription: string) => {
|
||||
// Update state immediately for optimistic UI
|
||||
setSessions((prevSessions) =>
|
||||
prevSessions.map((s) => (s.id === sessionId ? { ...s, name: newDescription } : s))
|
||||
prevSessions.map((s) =>
|
||||
s.id === sessionId ? { ...s, name: newDescription, user_set_name: true } : s
|
||||
)
|
||||
);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(AppEvents.SESSION_RENAMED, {
|
||||
detail: { sessionId, newName: newDescription },
|
||||
detail: { sessionId, newName: newDescription, userInitiated: true },
|
||||
})
|
||||
);
|
||||
}, []);
|
||||
|
||||
@@ -146,11 +146,16 @@ export function useNavigationSessions() {
|
||||
};
|
||||
|
||||
const handleSessionRenamed = (event: Event) => {
|
||||
const { sessionId, newName } = (event as CustomEvent<{ sessionId: string; newName: string }>)
|
||||
.detail;
|
||||
const { sessionId, newName, userInitiated } = (
|
||||
event as CustomEvent<{ sessionId: string; newName: string; userInitiated?: boolean }>
|
||||
).detail;
|
||||
|
||||
setRecentSessions((prev) =>
|
||||
prev.map((session) => (session.id === sessionId ? { ...session, name: newName } : session))
|
||||
prev.map((session) =>
|
||||
session.id === sessionId
|
||||
? { ...session, name: newName, ...(userInitiated && { user_set_name: true }) }
|
||||
: session
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user