Skip to content
Closed
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
3 changes: 3 additions & 0 deletions apps/mobile/src/features/usage/usageProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
"opencode",
"antigravity",
"pi",
"omp",
"muse",
];

Expand All @@ -25,6 +26,7 @@ export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
opencode: "OpenCode",
antigravity: "Antigravity",
pi: "Pi",
omp: "OMP",
muse: "Muse Code",
};

Expand All @@ -38,6 +40,7 @@ export function useProviderColors(): Record<UsageProviderKind, string> {
opencode: "#5b9bbd",
antigravity: "#8c7bd1",
pi: "#4d9f8a",
omp: "#c78b42",
muse: "#0866ff",
};
}
Expand Down
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@t3tools/provider-grok": "workspace:*",
"@t3tools/provider-kiro": "workspace:*",
"@t3tools/provider-muse": "workspace:*",
"@t3tools/provider-omp": "workspace:*",
"@t3tools/provider-opencode": "workspace:*",
"@t3tools/provider-pi": "workspace:*",
"@t3tools/source-control-azure-devops": "workspace:*",
Expand Down
34 changes: 29 additions & 5 deletions apps/server/src/project/AgentSessionImporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ const PI_MODEL_SELECTION = { instanceId: ProviderInstanceId.make("pi"), model: "

// Pi threads are owned by their session file path, not the session UUID.
const nativeId = ({ source }: ReturnType<typeof candidate>) =>
source.provider === "pi" ? source.filePath : source.providerSessionId;
source.provider === "pi" || source.provider === "omp"
? source.filePath
: source.providerSessionId;

function importId(source: ReturnType<typeof candidate>) {
return ThreadId.make(
Expand Down Expand Up @@ -266,11 +268,14 @@ it.effect(
);
const deleted = candidate(CODEX_MODEL_SELECTION, "deleted");
const ownedPi = candidate(PI_MODEL_SELECTION, "owned-pi", "pi");
const ompSelection = { instanceId: ProviderInstanceId.make("omp"), model: "default" };
const ownedOmp = candidate(ompSelection, "owned-omp", "omp");
const owners = [
yield* seedOwner(active),
yield* seedOwner(archived, "archived"),
yield* seedOwner(deleted, "deleted"),
yield* seedOwner(ownedPi),
yield* seedOwner(ownedOmp),
];
const before = yield* Effect.forEach(owners, (id) =>
projections.getThreadRecords(id, ["providerThreads"]),
Expand All @@ -283,18 +288,21 @@ it.effect(
const unowned = candidate(CODEX_MODEL_SELECTION, "unowned");
unowned.thread.omittedMessageCount = 1;
const unownedPi = candidate(PI_MODEL_SELECTION, "unowned-pi", "pi");
const unownedOmp = candidate(ompSelection, "unowned-omp", "omp");
const importer = yield* makeImporter([
active,
archived,
deleted,
ownedPi,
ownedOmp,
otherInstance,
unowned,
unownedPi,
unownedOmp,
]);

expect(yield* importer.run).toEqual({ importedCount: 3, skippedCount: 0 });
for (const source of [active, archived, deleted, ownedPi]) {
expect(yield* importer.run).toEqual({ importedCount: 4, skippedCount: 0 });
for (const source of [active, archived, deleted, ownedPi, ownedOmp]) {
const threadId = importId(source);
expect(yield* Effect.option(projections.getThread(threadId))).toEqual(Option.none());
expect(yield* events.read({ threadId }).pipe(Stream.runCollect)).toEqual([]);
Expand All @@ -311,8 +319,15 @@ it.effect(
"event" in stored ? [stored.event.threadId] : [],
),
),
).toEqual(new Set([importId(otherInstance), importId(unowned), importId(unownedPi)]));
for (const source of [otherInstance, unowned, unownedPi]) {
).toEqual(
new Set([
importId(otherInstance),
importId(unowned),
importId(unownedPi),
importId(unownedOmp),
]),
);
for (const source of [otherInstance, unowned, unownedPi, unownedOmp]) {
const threadId = importId(source);
const records = yield* projections.getThreadRecords(threadId, [
"messages",
Expand Down Expand Up @@ -345,6 +360,15 @@ it.effect(
runtimePayload: { importedTranscripts: [source.source] },
});
}
const publishedBeforeRepeat = [...importer.published];
const ompBeforeRepeat = yield* events
.read({ threadId: importId(unownedOmp) })
.pipe(Stream.runCollect);
expect(yield* importer.run).toEqual({ importedCount: 4, skippedCount: 0 });
expect(importer.published).toEqual(publishedBeforeRepeat);
expect(
yield* events.read({ threadId: importId(unownedOmp) }).pipe(Stream.runCollect),
).toEqual(ompBeforeRepeat);
}).pipe(Effect.scoped, Effect.provide(persistence)),
);

Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/project/AgentSessionImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ const make = Effect.gen(function* () {
const driver = ProviderDriverKind.make(thread.source);
// Pi resumes by session file path; its session UUID only names the thread.
const nativeThreadId =
thread.source === "pi" ? source.filePath : thread.providerSessionId;
thread.source === "pi" || thread.source === "omp"
? source.filePath
: thread.providerSessionId;
const persistRuntime = runtimes.upsert(
{
threadId,
Expand Down
140 changes: 140 additions & 0 deletions apps/server/src/project/AgentSessionScanner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ const layerScannerTest = (input: ScannerTestInput) =>
],
config: {},
},
[ProviderInstanceId.make("omp")]: {
driver: ProviderDriverKind.make("omp"),
enabled: false,
},
...input.providerInstances,
},
}),
Expand Down Expand Up @@ -1090,6 +1094,79 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
});

describe("recentThreads", () => {
it.effect("keeps two OMP profiles assigned to their own provider instances", () =>
Effect.gen(function* () {
const path = yield* Path.Path;
const home = yield* makeTempDir("t3code-omp-profile-home-");
const workspace = yield* makeTempDir("t3code-omp-profile-workspace-");
const nowMs = Date.parse("2026-08-24T12:00:00Z");
yield* TestClock.setTime(nowMs);
for (const profile of ["work", "personal", "default"]) {
yield* writeTranscript({
filePath: path.join(
home,
".omp",
...(profile === "default" ? [] : ["profiles", profile]),
"agent",
"sessions",
`${profile}.jsonl`,
),
contents: [
{
type: "session",
version: 3,
id: profile,
cwd: workspace,
timestamp: "2026-08-24T11:00:00Z",
},
{ type: "model_change", id: "m", parentId: null, model: "openai/gpt-4.1-mini" },
{
type: "message",
id: "u",
parentId: "m",
timestamp: "2026-08-24T11:00:00Z",
message: { role: "user", content: [{ type: "text", text: `From ${profile}` }] },
},
]
.map((record) => encodeTranscriptRecord(record))
.join("\n"),
mtimeMs: nowMs,
});
}
const environment = [
{ name: "HOME", value: home, sensitive: false },
{ name: "OMP_PROFILE", value: "personal", sensitive: false },
{ name: "PI_CODING_AGENT_SESSION_DIR", value: "", sensitive: false },
{ name: "XDG_DATA_HOME", value: "", sensitive: false },
{ name: "PI_CONFIG_DIR", value: ".omp", sensitive: false },
];
const threads = yield* runRecentThreads({
claudeHomePath: home,
codexHomePath: home,
workspaceRoot: workspace,
providerInstances: {
[ProviderInstanceId.make("omp-work")]: {
driver: ProviderDriverKind.make("omp"),
enabled: true,
environment,
config: { launchArgs: "--profile=work" },
},
[ProviderInstanceId.make("omp-personal")]: {
driver: ProviderDriverKind.make("omp"),
enabled: true,
environment,
config: {},
},
},
});
expect(
threads.map((thread) => [thread.providerInstanceId, thread.providerSessionId]).sort(),
).toEqual([
["omp-personal", "personal"],
["omp-work", "work"],
]);
}),
);
it.effect("imports recent Claude, Codex, and Pi sessions for the selected project only", () =>
Effect.gen(function* () {
const path = yield* Path.Path;
Expand Down Expand Up @@ -2262,6 +2339,69 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")(
);

describe("parseAgentSessionTranscript", () => {
it("reads OMP model changes and the active branch without modifying the native transcript", () => {
const contents = [
{
type: "session",
version: 3,
id: "omp-native",
cwd: "/project",
timestamp: "2026-11-08T12:00:00Z",
},
{
type: "model_change",
id: "m",
parentId: null,
model: "openai/gpt-4.1-mini",
runtime: { version: "18.16.0" },
},
{
type: "message",
id: "u",
parentId: "m",
message: { role: "user", content: [{ type: "text", text: "Review this" }] },
},
{
type: "message",
id: "old",
parentId: "u",
message: { role: "assistant", content: [{ type: "text", text: "Abandoned" }] },
},
{
type: "message",
id: "a",
parentId: "u",
message: {
role: "assistant",
content: [
{ type: "thinking", thinking: "private" },
{ type: "text", text: "Reviewed" },
],
},
},
{ type: "session_info", id: "n", parentId: "a", name: "OMP review" },
]
.map((entry) => JSON.stringify(entry))
.join("\n");
const input = {
contents,
source: "omp" as const,
providerInstanceId: ProviderInstanceId.make("omp"),
fallbackSessionId: "unused",
lastActiveAtMs: Date.parse("2026-11-08T12:00:00Z"),
};
const first = AgentSessionScanner.parseAgentSessionTranscript(input);
expect(first).toMatchObject({
source: "omp",
providerSessionId: "omp-native",
title: "OMP review",
model: "openai/gpt-4.1-mini",
});
expect(first?.messages.map((message) => message.text)).toEqual(["Review this", "Reviewed"]);
expect(AgentSessionScanner.parseAgentSessionTranscript(input)).toEqual(first);
expect(input.contents).toBe(contents);
});

it.each([false, true])(
"handles the exact record limit and an interior blank overflow=%s",
(overflow) => {
Expand Down
Loading
Loading