Skip to content

Commit f148a74

Browse files
committed
More progress
1 parent 6ff5342 commit f148a74

File tree

8 files changed

+129
-47
lines changed

8 files changed

+129
-47
lines changed

apps/roomote/Dockerfile.worker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ RUN git config --global credential.helper store
3636
RUN echo "https://oauth2:${GH_TOKEN}@github.com" > ~/.git-credentials
3737
RUN gh repo clone RooCodeInc/Roo-Code
3838
WORKDIR /roo/repos/Roo-Code
39+
RUN gh repo set-default RooCodeInc/Roo-Code
3940
RUN pnpm install
4041

4142
# Install dependencies
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE "cloud_tasks" CASCADE;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"id": "16afebd7-b27a-457e-b3d5-4de50a597c2e",
3+
"prevId": "4cae0c18-141d-40a3-acc8-38fcd7f07534",
4+
"version": "7",
5+
"dialect": "postgresql",
6+
"tables": {
7+
"public.cloud_jobs": {
8+
"name": "cloud_jobs",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "integer",
14+
"primaryKey": true,
15+
"notNull": true,
16+
"identity": {
17+
"type": "always",
18+
"name": "cloud_jobs_id_seq",
19+
"schema": "public",
20+
"increment": "1",
21+
"startWith": "1",
22+
"minValue": "1",
23+
"maxValue": "2147483647",
24+
"cache": "1",
25+
"cycle": false
26+
}
27+
},
28+
"type": {
29+
"name": "type",
30+
"type": "text",
31+
"primaryKey": false,
32+
"notNull": true
33+
},
34+
"status": {
35+
"name": "status",
36+
"type": "text",
37+
"primaryKey": false,
38+
"notNull": true,
39+
"default": "'pending'"
40+
},
41+
"payload": {
42+
"name": "payload",
43+
"type": "jsonb",
44+
"primaryKey": false,
45+
"notNull": true
46+
},
47+
"result": {
48+
"name": "result",
49+
"type": "jsonb",
50+
"primaryKey": false,
51+
"notNull": false
52+
},
53+
"error": {
54+
"name": "error",
55+
"type": "text",
56+
"primaryKey": false,
57+
"notNull": false
58+
},
59+
"slack_thread_ts": {
60+
"name": "slack_thread_ts",
61+
"type": "text",
62+
"primaryKey": false,
63+
"notNull": false
64+
},
65+
"started_at": {
66+
"name": "started_at",
67+
"type": "timestamp",
68+
"primaryKey": false,
69+
"notNull": false
70+
},
71+
"completed_at": {
72+
"name": "completed_at",
73+
"type": "timestamp",
74+
"primaryKey": false,
75+
"notNull": false
76+
},
77+
"created_at": {
78+
"name": "created_at",
79+
"type": "timestamp",
80+
"primaryKey": false,
81+
"notNull": true,
82+
"default": "now()"
83+
}
84+
},
85+
"indexes": {},
86+
"foreignKeys": {},
87+
"compositePrimaryKeys": {},
88+
"uniqueConstraints": {},
89+
"policies": {},
90+
"checkConstraints": {},
91+
"isRLSEnabled": false
92+
}
93+
},
94+
"enums": {},
95+
"schemas": {},
96+
"sequences": {},
97+
"roles": {},
98+
"policies": {},
99+
"views": {},
100+
"_meta": {
101+
"columns": {},
102+
"schemas": {},
103+
"tables": {}
104+
}
105+
}

apps/roomote/drizzle/meta/_journal.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
"when": 1750099429125,
1616
"tag": "0001_fluffy_sasquatch",
1717
"breakpoints": true
18+
},
19+
{
20+
"idx": 2,
21+
"version": "7",
22+
"when": 1750107620472,
23+
"tag": "0002_brief_sentry",
24+
"breakpoints": true
1825
}
1926
]
2027
}

apps/roomote/src/app/api/webhooks/github/route.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { type JobType, type JobPayload, githubIssueWebhookSchema, githubPullRequ
77
import { db, cloudJobs } from "@/db"
88
import { enqueue } from "@/lib"
99
import { SlackNotifier } from "@/lib/slack"
10-
import { Logger } from "@/lib/logger"
1110

1211
function verifySignature(body: string, signature: string, secret: string): boolean {
1312
const expectedSignature = createHmac("sha256", secret).update(body, "utf8").digest("hex")
@@ -17,13 +16,14 @@ function verifySignature(body: string, signature: string, secret: string): boole
1716

1817
async function handleIssueEvent(body: string) {
1918
const data = githubIssueWebhookSchema.parse(JSON.parse(body))
20-
console.log("🗄️ Issue Webhook ->", data)
2119
const { action, repository, issue } = data
2220

2321
if (action !== "opened") {
2422
return NextResponse.json({ message: "action_ignored" })
2523
}
2624

25+
console.log("🗄️ Issue Webhook ->", data)
26+
2727
const type: JobType = "github.issue.fix"
2828

2929
const payload: JobPayload<typeof type> = {
@@ -48,14 +48,15 @@ async function handleIssueEvent(body: string) {
4848

4949
async function handlePullRequestEvent(body: string) {
5050
const data = githubPullRequestWebhookSchema.parse(JSON.parse(body))
51-
console.log("🗄️ PR Webhook ->", data)
5251
const { action, pull_request, repository } = data
5352

5453
if (action !== "opened") {
5554
return NextResponse.json({ message: "action_ignored" })
5655
}
5756

58-
// Extract issue number from PR title or body (looking for "Fixes #123" pattern)
57+
console.log("🗄️ PR Webhook ->", data)
58+
59+
// Extract issue number from PR title or body (looking for "Fixes #123" pattern).
5960
const issueNumberMatch =
6061
pull_request.title.match(/(?:fixes|closes|resolves)\s+#(\d+)/i) ||
6162
(pull_request.body && pull_request.body.match(/(?:fixes|closes|resolves)\s+#(\d+)/i))
@@ -66,10 +67,10 @@ async function handlePullRequestEvent(body: string) {
6667

6768
const issueNumber = parseInt(issueNumberMatch[1]!, 10)
6869

69-
// Find the job that corresponds to this issue
70+
// Find the job that corresponds to this issue.
7071
const jobs = await db.select().from(cloudJobs).where(eq(cloudJobs.type, "github.issue.fix"))
7172

72-
// Filter jobs to find the one matching this repo and issue
73+
// Filter jobs to find the one matching this repo and issue.
7374
const job = jobs.find((j) => {
7475
const payload = j.payload as { repo: string; issue: number }
7576
return payload.repo === repository.full_name && payload.issue === issueNumber
@@ -80,9 +81,8 @@ async function handlePullRequestEvent(body: string) {
8081
return NextResponse.json({ message: "no_job_or_slack_thread_found" })
8182
}
8283

83-
// Post to Slack thread
84-
const logger = new Logger({ logDir: "/tmp/logs", filename: "webhook.log", tag: "webhook" })
85-
const slackNotifier = new SlackNotifier(logger)
84+
// Post to Slack thread.
85+
const slackNotifier = new SlackNotifier()
8686

8787
await slackNotifier.postTaskUpdated(
8888
job.slackThreadTs,

apps/roomote/src/db/schema.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { pgTable, text, timestamp, integer, jsonb } from "drizzle-orm/pg-core"
2-
import { relations } from "drizzle-orm"
32

43
import type { JobType, JobStatus, JobPayload } from "@/types"
54

@@ -20,47 +19,16 @@ export const cloudJobs = pgTable("cloud_jobs", {
2019
createdAt: timestamp("created_at").notNull().defaultNow(),
2120
})
2221

23-
export const cloudJobsRelations = relations(cloudJobs, ({ many }) => ({
24-
tasks: many(cloudTasks),
25-
}))
26-
2722
export type CloudJob = typeof cloudJobs.$inferSelect
2823

2924
export type InsertCloudJob = typeof cloudJobs.$inferInsert
3025

3126
export type UpdateCloudJob = Partial<Omit<CloudJob, "id" | "createdAt">>
3227

33-
/**
34-
* cloudTasks
35-
*/
36-
37-
export const cloudTasks = pgTable("cloud_tasks", {
38-
id: integer().primaryKey().generatedAlwaysAsIdentity(),
39-
jobId: integer("job_id")
40-
.references(() => cloudJobs.id)
41-
.notNull(),
42-
taskId: integer("task_id"),
43-
containerId: text("container_id"),
44-
createdAt: timestamp("created_at").notNull().defaultNow(),
45-
})
46-
47-
export const cloudTasksRelations = relations(cloudTasks, ({ one }) => ({
48-
job: one(cloudJobs, { fields: [cloudTasks.jobId], references: [cloudJobs.id] }),
49-
}))
50-
51-
export type CloudTask = typeof cloudTasks.$inferSelect
52-
53-
export type InsertCloudTask = typeof cloudTasks.$inferInsert
54-
55-
export type UpdateCloudTask = Partial<Omit<CloudTask, "id" | "createdAt">>
56-
5728
/**
5829
* schema
5930
*/
6031

6132
export const schema = {
6233
cloudJobs,
63-
cloudTasks,
64-
cloudJobsRelations,
65-
cloudTasksRelations,
6634
}

apps/roomote/src/lib/jobs/fixGitHubIssue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ When you're finished:
3535
- Create a git branch to store your work (git checkout -b fix-${jobPayload.issue})
3636
- Commit your changes to this branch (git commit -m "Fixes #${jobPayload.issue}")
3737
- Push your branch to the remote repository (git push --set-upstream origin fix-${jobPayload.issue})
38-
- Submit a pull request using the "gh" command line tool (gh pr create --repo RooCodeInc/Roo-Code --title "Fixes #${jobPayload.issue}\n\n[Your PR description here.]" --fill)
38+
- Submit a pull request using the "gh" command line tool (gh pr create --title "Fixes #${jobPayload.issue}\n\n[Your PR description here.]" --fill)
3939
4040
Your job isn't done until you've created a pull request. Try to solve any git issues that arise while creating your branch and submitting your pull request.
4141
`.trim()

apps/roomote/src/lib/slack.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export interface SlackResponse {
1818
}
1919

2020
export class SlackNotifier {
21-
private readonly logger: Logger
21+
private readonly logger?: Logger
2222
private readonly token: string
2323

24-
constructor(logger: Logger, token: string = process.env.SLACK_API_TOKEN!) {
24+
constructor(logger?: Logger, token: string = process.env.SLACK_API_TOKEN!) {
2525
this.logger = logger
2626
this.token = token
2727
}
@@ -37,19 +37,19 @@ export class SlackNotifier {
3737
})
3838

3939
if (!response.ok) {
40-
this.logger.error(`Slack API failed: ${response.status} ${response.statusText}`)
40+
this.logger?.error(`Slack API failed: ${response.status} ${response.statusText}`)
4141
return null
4242
}
4343

4444
const result: SlackResponse = await response.json()
4545

4646
if (!result.ok) {
47-
this.logger.error(`Slack API error: ${result.error}`)
47+
this.logger?.error(`Slack API error: ${result.error}`)
4848
}
4949

5050
return result.ts ?? null
5151
} catch (error) {
52-
this.logger.error("Failed to send Slack message:", error)
52+
this.logger?.error("Failed to send Slack message:", error)
5353
return null
5454
}
5555
}

0 commit comments

Comments
 (0)