Skip to content
Merged
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
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [x] Projects should be sorted by latest thread update
- [x] Submitting new messages should scroll to bottom — [#13](https://github.com/OpenKnots/okcode/issues/13)
- [ ] Thread archiving — [#10](https://github.com/OpenKnots/okcode/issues/10)
- [ ] New projects should go on top — [#11](https://github.com/OpenKnots/okcode/issues/11)
- [x] New projects should go on top — [#11](https://github.com/OpenKnots/okcode/issues/11)

## Bigger things

Expand Down
40 changes: 40 additions & 0 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,46 @@ describe("sortProjectsForSidebar", () => {
]);
});

it("sorts a newly created project (no threads) above an older project with thread activity", () => {
const sorted = sortProjectsForSidebar(
[
makeProject({
id: ProjectId.makeUnsafe("project-1"),
name: "Old active project",
createdAt: "2026-01-01T00:00:00.000Z",
updatedAt: "2026-01-01T00:00:00.000Z",
}),
makeProject({
id: ProjectId.makeUnsafe("project-2"),
name: "New project",
createdAt: "2026-03-09T10:10:00.000Z",
updatedAt: "2026-03-09T10:10:00.000Z",
}),
],
[
makeThread({
projectId: ProjectId.makeUnsafe("project-1"),
messages: [
{
id: "message-1" as never,
role: "user",
text: "recent activity",
createdAt: "2026-03-09T10:05:00.000Z",
streaming: false,
completedAt: "2026-03-09T10:05:00.000Z",
},
],
}),
],
"updated_at",
);

expect(sorted.map((project) => project.id)).toEqual([
ProjectId.makeUnsafe("project-2"),
ProjectId.makeUnsafe("project-1"),
]);
});

it("returns the project timestamp when no threads are present", () => {
const timestamp = getProjectSortTimestamp(
makeProject({ updatedAt: "2026-03-09T10:10:00.000Z" }),
Expand Down
Loading