File tree Expand file tree Collapse file tree
learning-spaces/[spaceId] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -264,7 +264,13 @@ export function AgentSkillDetailClient({
264264 } ;
265265
266266 const handleGoBack = ( ) => {
267- router . push ( `/project/${ encodedProjectId } /agent-skills` ) ;
267+ const params = new URLSearchParams ( window . location . search ) ;
268+ const returnTo = params . get ( "returnTo" ) ;
269+ if ( returnTo ) {
270+ router . push ( returnTo ) ;
271+ } else {
272+ router . push ( `/project/${ encodedProjectId } /agent-skills` ) ;
273+ }
268274 } ;
269275
270276 const handleDelete = async ( ) => {
Original file line number Diff line number Diff line change @@ -284,10 +284,12 @@ export function LearningSpaceDetailClient({
284284 router . push ( `/project/${ encodedProjectId } /learning-spaces` ) ;
285285 } ;
286286
287+ const returnTo = `/project/${ encodedProjectId } /learning-spaces/${ encodeId ( spaceId ) } ` ;
288+
287289 const navigateToAgentSkills = ( skill : SkillItem ) => {
288290 const encodedSkillId = encodeId ( skill . id ) ;
289291 router . push (
290- `/project/${ encodedProjectId } /agent-skills/${ encodedSkillId } `
292+ `/project/${ encodedProjectId } /agent-skills/${ encodedSkillId } ?returnTo= ${ encodeURIComponent ( returnTo ) } `
291293 ) ;
292294 } ;
293295
@@ -496,7 +498,7 @@ export function LearningSpaceDetailClient({
496498 session . session_id
497499 ) ;
498500 router . push (
499- `/project/${ encodedProjectId } /session/${ encodedSessionId } /messages`
501+ `/project/${ encodedProjectId } /session/${ encodedSessionId } /messages?returnTo= ${ encodeURIComponent ( returnTo ) } `
500502 ) ;
501503 } }
502504 >
Original file line number Diff line number Diff line change @@ -495,8 +495,14 @@ export function MessagesPageClient({
495495 } ;
496496
497497 const handleGoBack = ( ) => {
498- const encodedProjectId = encodeId ( project . id ) ;
499- router . push ( `/project/${ encodedProjectId } /session` ) ;
498+ const params = new URLSearchParams ( window . location . search ) ;
499+ const returnTo = params . get ( "returnTo" ) ;
500+ if ( returnTo ) {
501+ router . push ( returnTo ) ;
502+ } else {
503+ const encodedProjectId = encodeId ( project . id ) ;
504+ router . push ( `/project/${ encodedProjectId } /session` ) ;
505+ }
500506 } ;
501507
502508 return (
@@ -700,8 +706,9 @@ export function MessagesPageClient({
700706 if ( message . task_id ) {
701707 const encodedProjectId = encodeId ( project . id ) ;
702708 const encodedSessionId = encodeId ( sessionId ) ;
709+ const messagesReturnTo = `/project/${ encodedProjectId } /session/${ encodedSessionId } /messages` ;
703710 router . push (
704- `/project/${ encodedProjectId } /session/${ encodedSessionId } /task?taskId=${ message . task_id } `
711+ `/project/${ encodedProjectId } /session/${ encodedSessionId } /task?taskId=${ message . task_id } &returnTo= ${ encodeURIComponent ( messagesReturnTo ) } `
705712 ) ;
706713 }
707714 } }
Original file line number Diff line number Diff line change @@ -141,8 +141,14 @@ export function TaskPageClient({
141141 } ;
142142
143143 const handleGoBack = ( ) => {
144- const encodedProjectId = encodeId ( project . id ) ;
145- router . push ( `/project/${ encodedProjectId } /session` ) ;
144+ const params = new URLSearchParams ( window . location . search ) ;
145+ const returnTo = params . get ( "returnTo" ) ;
146+ if ( returnTo ) {
147+ router . push ( returnTo ) ;
148+ } else {
149+ const encodedProjectId = encodeId ( project . id ) ;
150+ router . push ( `/project/${ encodedProjectId } /session` ) ;
151+ }
146152 } ;
147153
148154 const getStatusColor = ( status : Task [ "status" ] ) => {
Original file line number Diff line number Diff line change @@ -247,8 +247,8 @@ export function AppSidebar({ navItems }: AppSidebarProps) {
247247 < Link
248248 href = { item . href ?? "" }
249249 onClick = { ( e ) => {
250- // Prevent navigation if already on this page
251- if ( isActive ) {
250+ // Prevent navigation only if already on this exact page
251+ if ( isActive && pathname === item . href ) {
252252 e . preventDefault ( ) ;
253253 return ;
254254 }
Original file line number Diff line number Diff line change @@ -89,7 +89,11 @@ export default function SkillDetailPage() {
8989 < p className = "text-sm text-muted-foreground" > { t ( "notFound" ) } </ p >
9090 < Button
9191 variant = "outline"
92- onClick = { ( ) => router . push ( "/agent_skills" ) }
92+ onClick = { ( ) => {
93+ const params = new URLSearchParams ( window . location . search ) ;
94+ const returnTo = params . get ( "returnTo" ) ;
95+ router . push ( returnTo || "/agent_skills" ) ;
96+ } }
9397 >
9498 < ArrowLeft className = "h-4 w-4 mr-2" />
9599 { t ( "backToSkills" ) }
@@ -105,7 +109,11 @@ export default function SkillDetailPage() {
105109 < div className = "flex items-center justify-between" >
106110 < Button
107111 variant = "ghost"
108- onClick = { ( ) => router . push ( "/agent_skills" ) }
112+ onClick = { ( ) => {
113+ const params = new URLSearchParams ( window . location . search ) ;
114+ const returnTo = params . get ( "returnTo" ) ;
115+ router . push ( returnTo || "/agent_skills" ) ;
116+ } }
109117 >
110118 < ArrowLeft className = "h-4 w-4 mr-2" />
111119 { t ( "backToSkills" ) }
Original file line number Diff line number Diff line change @@ -343,7 +343,7 @@ export default function LearningSpaceDetailPage() {
343343 < Button
344344 variant = "ghost"
345345 size = "sm"
346- onClick = { ( ) => router . push ( `/agent_skills/${ skill . id } ` ) }
346+ onClick = { ( ) => router . push ( `/agent_skills/${ skill . id } ?returnTo= ${ encodeURIComponent ( `/learning_spaces/ ${ id } ` ) } ` ) }
347347 >
348348 < FolderOpen className = "h-4 w-4" />
349349 { t ( "viewFiles" ) }
@@ -446,7 +446,7 @@ export default function LearningSpaceDetailPage() {
446446 size = "sm"
447447 onClick = { ( ) =>
448448 router . push (
449- `/session/${ session . session_id } /messages`
449+ `/session/${ session . session_id } /messages?returnTo= ${ encodeURIComponent ( `/learning_spaces/ ${ id } ` ) } `
450450 )
451451 }
452452 >
Original file line number Diff line number Diff line change @@ -503,7 +503,9 @@ export default function MessagesPage() {
503503 } ;
504504
505505 const handleGoBack = ( ) => {
506- router . push ( "/session" ) ;
506+ const params = new URLSearchParams ( window . location . search ) ;
507+ const returnTo = params . get ( "returnTo" ) ;
508+ router . push ( returnTo || "/session" ) ;
507509 } ;
508510
509511 return (
Original file line number Diff line number Diff line change @@ -143,7 +143,9 @@ export default function TasksPage() {
143143 } ;
144144
145145 const handleGoBack = ( ) => {
146- router . push ( "/session" ) ;
146+ const params = new URLSearchParams ( window . location . search ) ;
147+ const returnTo = params . get ( "returnTo" ) ;
148+ router . push ( returnTo || "/session" ) ;
147149 } ;
148150
149151 const getStatusColor = ( status : Task [ "status" ] ) => {
You can’t perform that action at this time.
0 commit comments