Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions TaxyAI-round-trip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
```
The user requests the following task:

what is the phone number of coderpush?

You have already taken the following actions:
<Thought>I need to search for the phone number of CoderPush</Thought>
<Action>setValue(208, "CoderPush phone number")</Action>

<Thought>I should click on the search button to find the phone number of CoderPush</Thought>
<Action>click(397)</Action>

<Thought>I should click on the first search result to find the phone number of CoderPush</Thought>
<Action>click(712)</Action>



Current time: 11/19/2023, 5:59:25 PM

Current page contents:
T1: <span id=$1><svg id=$2><path id=$3/></svg></span>

<html><head/><body><div role="dialog" id="2611"><div><div aria-label="Các tùy chọn khác" role="heading" id="2614">Các tùy chọn khác </div><div id="2615"><span aria-label="Đóng thông tin về kết quả này" role="button" id="2616"><svg id="2617"><path id="2618"/></svg></span></div></div><div><g-inline-toggler role="button" id="2623"><div id="2624"><span id="2625"><div id="2626"><div id="2627"><div id="2628"><div id="2629">Xem thêm </div></div>{T1(2630,2631,2632)}</div></div></span></div></g-inline-toggler><div role="list" id="2645"><div id="2646"><div aria-label="Chia sẻ" role="listitem" id="2647"><span id="2648"><div id="2649"><div id="2650"><div id="2651">{T1(2652,2653,2654)}<span id="2655">Chia sẻ </span></div></div></div></span><div id="2656"/><div id="2657"/></div></div><div id="2708"><div id="2709"><div role="listitem" id="2710"><div aria-label="Lưu" role="button" id="2711"><div id="2712"><div id="2713"><div id="2714">{T1(2715,2716,2717)}<span id="2718">Lưu </span></div></div></div></div></div></div></div><div role="listitem" id="2727"><div role="button" id="2728"><div id="2729"><div id="2730"><span id="2731">Phản hồi </span></div></div></div></div></div></div><div><div aria-label="Thông tin về kết quả này" role="heading" id="2744">Thông tin về kết quả này </div>Beta </div></div></body></html>
```

thought

```
<Thought>I should check if the phone number is displayed on the page</Thought>
<Action>click(1)</Action>
```

actions

```
{
"thought": "I should check if the phone number is displayed on the page",
"action": "click(1)",
"parsedAction": {
"name": "click",
"args": {
"elementId": 1
}
}
}
```
1 change: 1 addition & 0 deletions src/common/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const App = () => {
<OptionsDropdown />
</HStack>
</HStack>
{openAIKey ? <TaskUI /> : <SetAPIKey />}
</Box>
</ChakraProvider>
);
Expand Down
1 change: 1 addition & 0 deletions src/common/CTFlowAI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const CTFlowAI = () => {
<OptionsDropdown />
</HStack>
</HStack>
{openAIKey ? <TaskUI /> : <SetAPIKey />}
</Box>
</ChakraProvider>
);
Expand Down
79 changes: 79 additions & 0 deletions src/common/RunTaskButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Button, HStack, Icon } from '@chakra-ui/react';
import React, { useCallback } from 'react';
import { useAppState } from '../state/store';
import { BsPlayFill, BsStopFill } from 'react-icons/bs';

export default function RunTaskButton(props: { runTask: () => void }) {
const state = useAppState((state) => ({
taskState: state.currentTask.status,
instructions: state.ui.instructions,
interruptTask: state.currentTask.actions.interrupt,
}));

const [lastTriggerAITaskAt, setLastTriggerAITaskAt] =
React.useState<number>();
const onRunTask = props.runTask;

console.log('HEY FROM RUN TASK BUTTON');

if (chrome.debugger !== undefined) {
console.log('add listener to RUNT TASK BUTTON only');
chrome.runtime.onMessage.addListener(async function (
request,
sender,
sendResponse
) {
console.log(
'RUN TASK BTN:Message received from RUNT TASK BUTTON index.ts',
request
);
onRunTask();
// const [lastTriggerAITaskAt, setLastTriggerAITaskAt] = React.useState<number>();
});
}

React.useEffect(() => {
if (lastTriggerAITaskAt === undefined) {
return;
}

console.log(lastTriggerAITaskAt, 'RUN TASK BUTTON - CHANGE AND TRIGGER');
console.log('chrome.debugger', chrome.debugger);

if (chrome.debugger === undefined) {
console.log('trigger chrome runtime message');
chrome.runtime.sendMessage({
source: 'control-bar',
type: 'run-task',
});
} else if (lastTriggerAITaskAt) {
onRunTask();
}
}, [lastTriggerAITaskAt]);

let button = (
<Button
rightIcon={<Icon as={BsPlayFill} boxSize={6} />}
//onClick={props.runTask}
onClick={() => setLastTriggerAITaskAt(Date.now())}
colorScheme="green"
disabled={state.taskState === 'running' || !state.instructions}
>
Start Task
</Button>
);

if (state.taskState === 'running') {
button = (
<Button
rightIcon={<Icon as={BsStopFill} boxSize={6} />}
onClick={state.interruptTask}
colorScheme="red"
>
Stop
</Button>
);
}

return <HStack alignItems="center">{button}</HStack>;
}
18 changes: 18 additions & 0 deletions src/helpers/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,21 @@ export async function setRecordingAction(

await setDoc(doc(firestoreDB, 'recorders', id), newDoc);
}

export async function setAIRecord(
id: string,
currentHtml: string,
simplifiedHtml: string
) {
await setDoc(doc(firestoreDB, 'ai_records', id), {
currentHtml,
simplifiedHtml,
thoughts_actions: [],
current_thought: '',
current_actions: [{}],
ip: '127.0.0.1',
userId: 'test',
created_at: new Date(),
updated_at: new Date(),
});
}
1 change: 1 addition & 0 deletions src/manifest2.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"activeTab",
"storage",
"contextMenus",
"desktopCapture",
"webNavigation",
"<all_urls>"
],
Expand Down
1 change: 1 addition & 0 deletions src/manifest3.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"contextMenus",
"webNavigation",
"tabs",
"desktopCapture",
"clipboardWrite",
"debugger",
"management",
Expand Down
68 changes: 0 additions & 68 deletions src/pages/Common/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@
.px-4 {
padding: 0 1em;
}
.pl-4 {
padding-left: 1em;
}

/* Margin Utils */
.m-4 {
Expand All @@ -149,9 +146,6 @@
.mt-12 {
margin-top: 3em;
}
.ml-4 {
margin-left: 1em;
}
.mr-1 {
margin-right: 0.25em;
}
Expand All @@ -161,9 +155,6 @@
.mr-4 {
margin-right: 1em;
}
.mr-4-i {
margin-right: 1em !important;
}
.mr-5 {
margin-right: 1.5em;
}
Expand Down Expand Up @@ -219,62 +210,3 @@
.cypress-trigger:hover {
background: #e9e9e9;
}

.flex {
display: flex;
}

.justify-between {
justify-content: space-between;
}

.items-center {
align-items: center;
}

.block {
display: block;
}

.static {
position: static;
}

.fixed {
position: fixed;
}

.bottom-1 {
bottom: 1rem;
}

.right-1 {
right: 1rem;
}

.rounded-md {
border-radius: 0.375rem;
}

button.no-default {
background: transparent;
border: none;
padding: 0;
margin: 0;
cursor: pointer;
outline: none;
}

button.bg-common {
background-color: #080a0b;
}

button.px-4 {
padding-right: 1em;
padding-left: 1em;
}

button.py-2 {
padding-top: 0.5em;
padding-bottom: 0.5em;
}
Loading