Skip to content

Commit c7df47f

Browse files
GenerQAQclaude
andauthored
fix: use returnTo query param for correct back navigation (#424)
* fix: use returnTo query param for correct back navigation across pages When navigating from learning space to skill detail or session messages, the back button now returns to the learning space instead of the default list page. Same fix applied for messages → task navigation. Existing flows without returnTo param are unaffected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: allow sidebar navigation from child pages back to parent list When on a child page (e.g. /session/xxx/messages), clicking the parent nav item (Session) was blocked because prefix-match isActive triggered e.preventDefault(). Now only prevent navigation when already on the exact same page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: apply returnTo back navigation to OSS dashboard Same returnTo query param pattern for the OSS dashboard: - learning_spaces → agent_skills detail: back returns to learning space - learning_spaces → session messages: back returns to learning space - session task page: supports returnTo fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9878f7a commit c7df47f

9 files changed

Lines changed: 49 additions & 16 deletions

File tree

dashboard/app/project/[id]/agent-skills/[skillId]/agent-skill-detail-client.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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 () => {

dashboard/app/project/[id]/learning-spaces/[spaceId]/learning-space-detail-client.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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
>

dashboard/app/project/[id]/session/[sessionId]/messages/messages-page-client.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}}

dashboard/app/project/[id]/session/[sessionId]/task/task-page-client.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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"]) => {

dashboard/components/app-sidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

src/server/ui/app/agent_skills/[id]/page.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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")}

src/server/ui/app/learning_spaces/[id]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
>

src/server/ui/app/session/[sessionId]/messages/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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 (

src/server/ui/app/session/[sessionId]/task/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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"]) => {

0 commit comments

Comments
 (0)