Skip to content

Commit

Permalink
feat: display status during task execution (#141)
Browse files Browse the repository at this point in the history
* feat: displaying status

* fix: update name

* fix: updated name
  • Loading branch information
lynchee-owo authored Apr 25, 2024
1 parent 3aba643 commit 00cc6a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/common/TaskStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ export default function TaskStatus() {
}

const displayedStatus: Record<CurrentTaskSlice["actionStatus"], string> = {
idle: "Idle",
"attaching-debugger": "Attaching Debugger",
"pulling-dom": "Reading Page",
"transforming-dom": "Reading Page",
"performing-query": "Running GPT",
"performing-action": "Performing Action",
waiting: "Waiting",
idle: "💤 Idle",
"attaching-debugger": "🔗 Attaching Debugger",
"pulling-dom": "🌐 Understanding Website",
"annotating-page": "🌐 Understanding Website",
"fetching-knoweldge": "🧠 Getting Instructions",
"generating-action": "🤔 Thinking and planning",
"performing-action": "🚀 Performing Action",
waiting: "⏳ Waiting",
};

return (
<Box textColor="gray.500" textAlign="center" mb={8} fontSize="sm">
<Box textColor="gray.500" textAlign="center" mt={4} mb={-4} fontSize="sm">
{displayedStatus[actionStatus]}
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion src/common/TaskUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const TaskUI = () => {
/>
)}
<Spacer />
{debugMode && <TaskStatus />}
</HStack>
{state.voiceMode && (
<Alert status="info" borderRadius="lg">
Expand All @@ -140,6 +139,7 @@ const TaskUI = () => {
)}
{debugMode && <ActionExecutor />}
<MatchedNotes />
<TaskStatus />
<TaskHistory />
</>
);
Expand Down
11 changes: 8 additions & 3 deletions src/state/currentTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export type CurrentTaskSlice = {
| "idle"
| "attaching-debugger"
| "pulling-dom"
| "transforming-dom"
| "performing-query"
| "annotating-page"
| "fetching-knoweldge"
| "generating-action"
| "performing-action"
| "waiting";
actions: {
Expand Down Expand Up @@ -168,11 +169,11 @@ export const createCurrentTaskSlice: MyStateCreator<CurrentTaskSlice> = (
return true;
};

setActionStatus("performing-query");
let query: QueryResult | null = null;

// check if the tab does not allow attaching debugger, e.g. chrome:// pages
if (activeTab.url?.startsWith("chrome")) {
setActionStatus("generating-action");
query = await determineNavigateAction(instructions);

if (wasStopped()) break;
Expand All @@ -198,13 +199,15 @@ export const createCurrentTaskSlice: MyStateCreator<CurrentTaskSlice> = (
.filter(truthyFilter);

if (isVisionModel) {
setActionStatus("fetching-knoweldge");
const url = new URL(activeTab.url ?? "");
const customKnowledgeBase = get().settings.customKnowledgeBase;
const knowledge = await fetchKnowledge(url, customKnowledgeBase);
set((state) => {
state.currentTask.knowledgeInUse = knowledge;
});

setActionStatus("annotating-page");
const [imgData, labelData] = await buildAnnotatedScreenshots(
tabId,
knowledge,
Expand All @@ -215,6 +218,7 @@ export const createCurrentTaskSlice: MyStateCreator<CurrentTaskSlice> = (
[],
);
if (wasStopped()) break;
setActionStatus("generating-action");
query = await determineNextActionWithVision(
instructions,
url,
Expand All @@ -237,6 +241,7 @@ export const createCurrentTaskSlice: MyStateCreator<CurrentTaskSlice> = (
}

if (wasStopped()) break;
setActionStatus("generating-action");
query = await determineNextAction(
instructions,
previousActions,
Expand Down

0 comments on commit 00cc6a5

Please sign in to comment.