Merge task: Frontend navigation should happen using router into refactor-executors
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useState, useEffect, useMemo } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
X,
|
||||
History,
|
||||
@@ -139,7 +140,9 @@ export function TaskDetailsPanel({
|
||||
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false);
|
||||
const [selectedExecutor, setSelectedExecutor] = useState<string>("claude");
|
||||
const [isStopping, setIsStopping] = useState(false);
|
||||
const [expandedOutputs, setExpandedOutputs] = useState<Set<string>>(new Set());
|
||||
const [expandedOutputs, setExpandedOutputs] = useState<Set<string>>(
|
||||
new Set()
|
||||
);
|
||||
const { config } = useConfig();
|
||||
|
||||
// Available executors
|
||||
@@ -158,10 +161,15 @@ export function TaskDetailsPanel({
|
||||
|
||||
// Group activities by execution_process_id and get the latest one for each
|
||||
const latestActivitiesByProcess = new Map<string, TaskAttemptActivity>();
|
||||
|
||||
|
||||
attemptActivities.forEach((activity) => {
|
||||
const existing = latestActivitiesByProcess.get(activity.execution_process_id);
|
||||
if (!existing || new Date(activity.created_at) > new Date(existing.created_at)) {
|
||||
const existing = latestActivitiesByProcess.get(
|
||||
activity.execution_process_id
|
||||
);
|
||||
if (
|
||||
!existing ||
|
||||
new Date(activity.created_at) > new Date(existing.created_at)
|
||||
) {
|
||||
latestActivitiesByProcess.set(activity.execution_process_id, activity);
|
||||
}
|
||||
});
|
||||
@@ -379,7 +387,7 @@ export function TaskDetailsPanel({
|
||||
};
|
||||
|
||||
const toggleOutputExpansion = (processId: string) => {
|
||||
setExpandedOutputs(prev => {
|
||||
setExpandedOutputs((prev) => {
|
||||
const newSet = new Set(prev);
|
||||
if (newSet.has(processId)) {
|
||||
newSet.delete(processId);
|
||||
@@ -608,18 +616,13 @@ export function TaskDetailsPanel({
|
||||
<Code className="h-4 w-4 mr-1" />
|
||||
Editor
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
window.open(
|
||||
`/projects/${projectId}/tasks/${task.id}/attempts/${selectedAttempt.id}/compare`,
|
||||
"_blank"
|
||||
)
|
||||
}
|
||||
>
|
||||
<FileText className="h-4 w-4 mr-1" />
|
||||
Changes
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<Link
|
||||
to={`/projects/${projectId}/tasks/${task.id}/attempts/${selectedAttempt.id}/compare`}
|
||||
>
|
||||
<FileText className="h-4 w-4 mr-1" />
|
||||
Changes
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@@ -686,11 +689,13 @@ export function TaskDetailsPanel({
|
||||
activity.execution_process_id
|
||||
] && (
|
||||
<div className="mt-2">
|
||||
<div
|
||||
<div
|
||||
className={`transition-all duration-200 ${
|
||||
expandedOutputs.has(activity.execution_process_id)
|
||||
? ''
|
||||
: 'max-h-64 overflow-hidden'
|
||||
expandedOutputs.has(
|
||||
activity.execution_process_id
|
||||
)
|
||||
? ""
|
||||
: "max-h-64 overflow-hidden"
|
||||
}`}
|
||||
>
|
||||
<ExecutionOutputViewer
|
||||
@@ -700,17 +705,24 @@ export function TaskDetailsPanel({
|
||||
]
|
||||
}
|
||||
executor={
|
||||
selectedAttempt?.executor || undefined
|
||||
selectedAttempt?.executor ||
|
||||
undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => toggleOutputExpansion(activity.execution_process_id)}
|
||||
onClick={() =>
|
||||
toggleOutputExpansion(
|
||||
activity.execution_process_id
|
||||
)
|
||||
}
|
||||
className="mt-2 p-0 h-auto text-xs text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{expandedOutputs.has(activity.execution_process_id) ? (
|
||||
{expandedOutputs.has(
|
||||
activity.execution_process_id
|
||||
) ? (
|
||||
<>
|
||||
<ChevronUp className="h-3 w-3 mr-1" />
|
||||
Show less
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
|
||||
// Define available keyboard shortcuts
|
||||
export interface KeyboardShortcut {
|
||||
@@ -16,6 +16,7 @@ export interface KeyboardShortcutContext {
|
||||
openCreateTask?: () => void;
|
||||
currentPath?: string;
|
||||
hasOpenDialog?: boolean;
|
||||
location?: ReturnType<typeof useLocation>;
|
||||
}
|
||||
|
||||
// Centralized shortcut definitions
|
||||
@@ -32,7 +33,7 @@ export const createKeyboardShortcuts = (context: KeyboardShortcutContext): Recor
|
||||
|
||||
// Otherwise, navigate back
|
||||
if (context.navigate) {
|
||||
const currentPath = context.currentPath || window.location.pathname;
|
||||
const currentPath = context.currentPath || context.location?.pathname || '/';
|
||||
|
||||
// Navigate back based on current path
|
||||
if (currentPath.includes('/attempts/') && currentPath.includes('/compare')) {
|
||||
|
||||
Reference in New Issue
Block a user