Skip to content

Commit 16c9121

Browse files
committed
fix: address CodeRabbit review feedback
- Ack lead messages after returning them in wait_for_team - Add shebang preservation to build step - Clamp progress bar and column widths for narrow terminals - Reset sender grouping at date boundaries in messages - Fix allTasks order to match rendered column order - Guard selectedIdx against empty task list - Fix 'waiting for tasks' condition to check totalAssigned - Exit with code 1 on TUI errors - Fix g/G keybindings to match vim convention
1 parent eaea139 commit 16c9121

8 files changed

Lines changed: 33 additions & 9 deletions

File tree

packages/agent-teams-lead/src/store.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ export class TeamStore {
281281
return this.artifacts.find((a) => a.id === artifactId);
282282
}
283283

284+
async ackMessages(readerId: string, messageIds: string[]): Promise<void> {
285+
return withFileLock(this.messagesPath(), async () => {
286+
this.messages = await this.readJson<Message[]>(this.messagesPath(), []);
287+
for (const msg of this.messages) {
288+
if (messageIds.includes(msg.id) && !msg.read_by.includes(readerId)) {
289+
msg.read_by.push(readerId);
290+
}
291+
}
292+
await this.writeJson(this.messagesPath(), this.messages);
293+
});
294+
}
295+
284296
getArtifacts(): Artifact[] {
285297
return [...this.artifacts];
286298
}

packages/agent-teams-lead/src/tools.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ export class LeadTools {
215215
unread_by: "lead",
216216
});
217217

218+
if (leadMessages.length > 0) {
219+
await this.store.ackMessages("lead", leadMessages.map((m) => m.id));
220+
}
221+
218222
return this.ok({
219223
done: true,
220224
reason:
@@ -251,6 +255,11 @@ export class LeadTools {
251255
to: "lead",
252256
unread_by: "lead",
253257
});
258+
259+
if (leadMessagesOnTimeout.length > 0) {
260+
await this.store.ackMessages("lead", leadMessagesOnTimeout.map((m) => m.id));
261+
}
262+
254263
return this.ok({
255264
done: false,
256265
timed_out: true,

packages/agent-teams-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"agent-teams-ui": "./dist/index.js"
99
},
1010
"scripts": {
11-
"build": "tsc",
11+
"build": "tsc && echo '#!/usr/bin/env node' | cat - dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",
1212
"dev": "tsx src/index.tsx",
1313
"start": "node dist/index.js"
1414
},

packages/agent-teams-ui/src/components/ChatView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ export function ChatView({ lines }: Props) {
8080
if (key.downArrow || input === "j") {
8181
setScrollOffset((o) => Math.max(0, o - 3));
8282
}
83-
if (input === "g") setScrollOffset(Math.max(0, filtered.length - viewHeight));
84-
if (input === "G") setScrollOffset(0);
83+
if (input === "g") setScrollOffset(0);
84+
if (input === "G") setScrollOffset(Math.max(0, filtered.length - viewHeight));
8585
});
8686

8787
const agentColors = new Map<string, string>();

packages/agent-teams-ui/src/components/MessagesView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function MessagesView({ messages }: Props) {
7272
const date = formatDate(msg.created_at);
7373
const showDate = date !== lastDate;
7474
lastDate = date;
75-
const showName = msg.from_name !== lastFrom;
75+
const showName = msg.from_name !== lastFrom || showDate;
7676
lastFrom = msg.from_name;
7777

7878
const target =

packages/agent-teams-ui/src/components/TasksView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ function TaskDetail({ task, nameMap }: { task: Task; nameMap: Map<string, string
8787
export function TasksView({ tasks, teammates }: Props) {
8888
const { stdout } = useStdout();
8989
const totalWidth = Math.min(stdout?.columns || 80, 120);
90-
const colWidth = Math.floor((totalWidth - COLUMNS.length - 1) / COLUMNS.length);
90+
const colWidth = Math.max(10, Math.floor((totalWidth - COLUMNS.length - 1) / COLUMNS.length));
9191
const nameMap = new Map(teammates.map((t) => [t.id, t.name]));
9292

9393
const [selectedIdx, setSelectedIdx] = useState(0);
9494
const [detailTask, setDetailTask] = useState<Task | null>(null);
9595

9696
const allTasks = [
97-
...tasks.filter((t) => t.status === "in_progress"),
9897
...tasks.filter((t) => t.status === "pending"),
98+
...tasks.filter((t) => t.status === "in_progress"),
9999
...tasks.filter((t) => t.status === "blocked"),
100100
...tasks.filter((t) => t.status === "completed"),
101101
];
@@ -109,7 +109,7 @@ export function TasksView({ tasks, teammates }: Props) {
109109
setSelectedIdx((i) => Math.max(0, i - 1));
110110
}
111111
if (key.downArrow || input === "j") {
112-
setSelectedIdx((i) => Math.min(allTasks.length - 1, i + 1));
112+
setSelectedIdx((i) => Math.min(Math.max(0, allTasks.length - 1), i + 1));
113113
}
114114
if (key.return && allTasks[selectedIdx]) {
115115
setDetailTask(allTasks[selectedIdx]);

packages/agent-teams-ui/src/components/TeamView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function TeamView({ team, tasks }: Props) {
5959
<Text color={colors.brand}>{symbols.check} all tasks done</Text>
6060
</Box>
6161
)}
62-
{!current && doneCount === 0 && (
62+
{!current && doneCount === 0 && totalAssigned === 0 && (
6363
<Box paddingLeft={3}>
6464
<Text color={colors.muted}>waiting for tasks</Text>
6565
</Box>

packages/agent-teams-ui/src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ const workspacePath = resolve(process.argv[2] || process.cwd());
88

99
const { waitUntilExit } = render(<App workspacePath={workspacePath} />);
1010

11-
waitUntilExit().catch(() => process.exit(0));
11+
waitUntilExit().catch((err) => {
12+
if (err) process.stderr.write(String(err) + "\n");
13+
process.exit(1);
14+
});

0 commit comments

Comments
 (0)