Skip to content

Commit 4b0d5df

Browse files
authored
Task update times, plus a small prompt change (meltylabs#85)
* bot changes * prompt adjustments (FileContents tag name) * undo bad bot changes * copy types to webview * bot changes * bot changes * human changes * bot changes * bot changes * bot changes
1 parent 1dda237 commit 4b0d5df

File tree

6 files changed

+53
-10
lines changed

6 files changed

+53
-10
lines changed

src/assistants/baseAssistant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export abstract class BaseAssistant {
3333
path
3434
);
3535

36-
// TODO we should use | indentation here
37-
return `<File filePath=${path}>
36+
// TODO should we use | indentation here?
37+
return `<FileContents filePath=${path}>
3838
${fileContents.endsWith("\n") ? fileContents : fileContents + "\n"}
39-
</File>`;
39+
</FileContents>`;
4040
}
4141

4242
protected encodeContext(

src/backend/prompts.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ own independent opinions and conclusions.
3131
# Files
3232
3333
The user will first give you a <CodebaseSummary>, containing a summary of some of the files in their codebase. These are NOT
34-
the full contents. Later, the user may present you with the full contents of some of those files. You can always suggest to the
35-
user that they might want to provide the contents of certain files.
34+
the full contents. Later, the user may present you with the full contents of some of those files, using the <FileContents> tag.
35+
Feel free to ask the user to provide contents of any file.
3636
3737
Rules for files:
3838
39-
1. When the discussion touches on a particular file, ask the user to provide the contents of that file.
40-
2. Before making a code change, ensure you've seen the full contents of the file. If you haven't, ask the user to provide it.
39+
1. When the discussion touches on a particular file, ask the user to provide the contents of that file using a <FileContents> tag.
40+
2. Before making a code change, ensure you've seen a <FileContents> tag for that file. If you haven't, ask the user to provide the
41+
file's contents.
4142
4243
# Responding to User Requests
4344
@@ -50,7 +51,7 @@ Rules for files:
5051
If the user asks for code changes, follow these steps:
5152
5253
1. First, consider whether you're missing any information needed to answer the user's request. Which files will you need to
53-
change? Have you been provided with their contents in <File> tags? If not, ask the user to provide those files.
54+
change? Have you been provided with their contents in <FileContents> tags? If not, ask the user to provide those files.
5455
2. Next, think through how much work it will take to implement the user's request. Is there more information you need?
5556
Is there anything you don't understand? It's always okay to ask.
5657
3. If the user's request is straightforward, unambiguous, and you can satisfy it right away, go ahead and implement it
@@ -103,7 +104,10 @@ export function messageDecoderPrompt() {
103104
// }
104105

105106
export function filesUserIntro(): string {
106-
return `These are the files I want you to work with. Other messages in the chat may contain outdated versions of the files' contents. Trust this message as the true contents of the files!`;
107+
return `These are the files I want you to work with.
108+
Other messages in the chat may contain outdated versions of the files' contents. Trust this message as the true contents of the files.
109+
Do not make changes to any files besides these.
110+
You can always ask me to provide the contents of another file.`;
107111
}
108112

109113
export function filesAsstAck(): string {

src/backend/tasks.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Coder } from "../assistants/coder";
1515
import * as config from "../util/config";
1616
import { FileManager } from "../fileManager";
1717
import { getRepoAtWorkspaceRoot } from "../util/gitUtils";
18+
import * as datastores from "./datastores";
1819

1920
/**
2021
* A Task manages the interaction between a conversation and a git repository
@@ -23,10 +24,18 @@ export class Task implements Task {
2324
conversation: Conversation;
2425
gitRepo: GitRepo | null;
2526
fileManager: FileManager | undefined;
27+
createdAt: Date;
28+
updatedAt: Date;
2629

2730
constructor(public id: string, public name: string, public branch: string) {
2831
this.conversation = conversations.create();
2932
this.gitRepo = null;
33+
this.createdAt = new Date();
34+
this.updatedAt = new Date();
35+
}
36+
37+
updateLastModified() {
38+
this.updatedAt = new Date();
3039
}
3140

3241
public setFileManager(fileManager: FileManager) {
@@ -206,6 +215,9 @@ export class Task implements Task {
206215
assistantType !== "architect"
207216
);
208217
await this.gitRepo!.repository.status();
218+
219+
this.updateLastModified();
220+
await datastores.writeTaskToDisk(this);
209221
} catch (e) {
210222
if (config.DEV_MODE) {
211223
throw e;
@@ -255,6 +267,9 @@ export class Task implements Task {
255267
newPseudoCommit
256268
);
257269

270+
this.updateLastModified();
271+
await datastores.writeTaskToDisk(this);
272+
258273
return conversations.lastJoule(this.conversation)!;
259274
}
260275
}

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export interface Task {
55
branch: string;
66
conversation: Conversation;
77
gitRepo: GitRepo | null;
8+
createdAt: Date;
9+
updatedAt: Date;
810
}
911

1012
export type GitRepo = {
@@ -107,3 +109,4 @@ export type MeltyFile = {
107109
readonly path: string;
108110
readonly contents: string;
109111
};
112+

webview-ui/src/components/Tasks.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ import {
3333
SelectValue,
3434
} from "./ui/select";
3535

36+
// Utility function to format the date
37+
function formatDate(date: Date): string {
38+
const now = new Date();
39+
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
40+
41+
if (diffInSeconds < 60) return `${diffInSeconds} seconds ago`;
42+
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)} minutes ago`;
43+
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)} hours ago`;
44+
if (diffInSeconds < 604800) return `${Math.floor(diffInSeconds / 86400)} days ago`;
45+
46+
return date.toLocaleDateString();
47+
}
48+
3649
export function Tasks() {
3750
const [tasks, setTasks] = useState<Task[]>([]);
3851
const [messageText, setMessageText] = useState("");
@@ -43,7 +56,10 @@ export function Tasks() {
4356
const fetchTasks = useCallback(async () => {
4457
const fetchedTasks = (await extensionRPC.run("listTasks")) as Task[];
4558
console.log(`[Tasks] fetched ${fetchedTasks.length} tasks`);
46-
setTasks(fetchedTasks.reverse());
59+
const sortedTasks = fetchedTasks.sort((a, b) =>
60+
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
61+
);
62+
setTasks(sortedTasks);
4763
}, [extensionRPC]);
4864

4965
const checkGitConfig = useCallback(async () => {
@@ -190,6 +206,9 @@ export function Tasks() {
190206
<CardContent>
191207
<p>{task.description}</p>
192208
<p>{task.branch}</p>
209+
<p className="text-sm text-gray-500 mt-2">
210+
Updated {formatDate(new Date(task.updatedAt))}
211+
</p>
193212
</CardContent>
194213
</Card>
195214
</Link>

webview-ui/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export interface Task {
55
branch: string;
66
conversation: Conversation;
77
gitRepo: GitRepo | null;
8+
createdAt: Date;
9+
updatedAt: Date;
810
}
911

1012
export type GitRepo = {

0 commit comments

Comments
 (0)