-
Notifications
You must be signed in to change notification settings - Fork 2
Execution targets: workspace picker, chat tagging, and persistence #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import type { AdeDb } from "../state/kvDb"; | ||
| import type { AdeExecutionTargetsState } from "../../../shared/types"; | ||
| import { defaultExecutionTargetsState, normalizeExecutionTargetsState } from "../../../shared/types"; | ||
|
|
||
| function keyForProject(projectId: string): string { | ||
| return `ade_execution_targets:${projectId}`; | ||
| } | ||
|
|
||
| export function getExecutionTargetsState(db: AdeDb | null, projectId: string): AdeExecutionTargetsState { | ||
| const pid = projectId.trim(); | ||
| if (!db || !pid.length) return defaultExecutionTargetsState(); | ||
| const raw = db.getJson<unknown>(keyForProject(pid)); | ||
| return normalizeExecutionTargetsState(raw); | ||
| } | ||
|
|
||
| export function setExecutionTargetsState( | ||
| db: AdeDb | null, | ||
| projectId: string, | ||
| next: AdeExecutionTargetsState, | ||
| ): AdeExecutionTargetsState { | ||
| const pid = projectId.trim(); | ||
| if (!db || !pid.length) return defaultExecutionTargetsState(); | ||
| const normalized = normalizeExecutionTargetsState(next); | ||
| db.setJson(keyForProject(pid), normalized); | ||
|
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reject duplicate execution target ids before saving.
💡 Local fix at the persistence boundary-import type { AdeExecutionTargetsState } from "../../../shared/types";
-import { defaultExecutionTargetsState, normalizeExecutionTargetsState } from "../../../shared/types";
+import type { AdeExecutionTargetsState } from "../../../shared/types";
+import {
+ ADE_LOCAL_EXECUTION_TARGET_ID,
+ defaultExecutionTargetsState,
+ normalizeExecutionTargetsState,
+} from "../../../shared/types";
...
export function setExecutionTargetsState(
db: AdeDb | null,
projectId: string,
next: AdeExecutionTargetsState,
): AdeExecutionTargetsState {
const pid = projectId.trim();
if (!db || !pid.length) return defaultExecutionTargetsState();
const normalized = normalizeExecutionTargetsState(next);
- db.setJson(keyForProject(pid), normalized);
- return normalized;
+ const profiles = Array.from(
+ new Map(normalized.profiles.map((profile) => [profile.id, profile])).values(),
+ );
+ const safe = {
+ ...normalized,
+ profiles,
+ activeTargetId: profiles.some((profile) => profile.id === normalized.activeTargetId)
+ ? normalized.activeTargetId
+ : ADE_LOCAL_EXECUTION_TARGET_ID,
+ };
+ db.setJson(keyForProject(pid), safe);
+ return safe;
}🤖 Prompt for AI Agents |
||
| return normalized; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -860,6 +860,14 @@ if (typeof window !== "undefined" && !(window as any).ade) { | |
| onMissing: noop, | ||
| onStateEvent: noop, | ||
| }, | ||
| executionTargets: { | ||
| get: resolved({ | ||
| version: 1, | ||
| profiles: [{ id: "local", kind: "local" as const, label: "This computer" }], | ||
| activeTargetId: "local", | ||
| }), | ||
| set: async (state: any) => state, | ||
| }, | ||
|
Comment on lines
+863
to
+870
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make browser mock Line 837 currently ignores the incoming state and always returns the same static payload, so 🔧 Proposed fix import { getDefaultModelDescriptor } from "../shared/modelRegistry";
+import {
+ defaultExecutionTargetsState,
+ normalizeExecutionTargetsState,
+ type AdeExecutionTargetsState,
+} from "../shared/types/executionTargets";
@@
const DEFAULT_BROWSER_MOCK_CODEX_MODEL = getDefaultModelDescriptor("codex")?.id ?? "openai/gpt-5.4-codex";
+let mockExecutionTargetsState: AdeExecutionTargetsState = defaultExecutionTargetsState();
@@
executionTargets: {
- get: resolved({
- version: 1,
- profiles: [{ id: "local", kind: "local" as const, label: "This computer" }],
- activeTargetId: "local",
- }),
- set: resolvedArg({
- version: 1,
- profiles: [{ id: "local", kind: "local" as const, label: "This computer" }],
- activeTargetId: "local",
- }),
+ get: async () => mockExecutionTargetsState,
+ set: async (next: AdeExecutionTargetsState) => {
+ mockExecutionTargetsState = normalizeExecutionTargetsState(next);
+ return mockExecutionTargetsState;
+ },
},As per coding guidelines, "Keep IPC contracts, preload types, shared types, and renderer usage in sync whenever an interface changes." 🤖 Prompt for AI Agents |
||
| keybindings: { | ||
| get: resolved({ definitions: [], overrides: [] }), | ||
| set: resolvedArg({ definitions: [], overrides: [] }), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalize upgraded chats to the local target when rebuilding the managed session.
Pre-feature chat metadata will not have these fields, so resumed sessions can keep
managed.session.executionTargetIdunset here whilesummarizeSessionRow()later reports"local". That split state will make upgraded chats behave differently depending on which API the UI reads.💡 Suggested fix
🤖 Prompt for AI Agents