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
18 changes: 18 additions & 0 deletions apps/console/src/pages/system/AppManagementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
Star,
ExternalLink,
Search,
Sparkles,
} from 'lucide-react';
import { toast } from 'sonner';
import { useMetadata } from '@object-ui/app-shell';
Expand Down Expand Up @@ -241,6 +242,23 @@ export function AppManagementPage() {
>
<Pencil className="h-4 w-4" />
</Button>
{app._packageId ? (
<Button
variant="ghost"
size="icon"
title="Edit with AI"
aria-label={`Edit ${app.label || app.name} with AI`}
// ADR-0070 — open the build agent in a fresh conversation
// pre-scoped to this app's package (passed as the chat
// context.packageId the cloud seeds as the active package),
// so the AI iterates within THIS app, not the whole env.
onClick={() =>
navigate(`/ai/build?package=${encodeURIComponent(app._packageId!)}&new=1`)
}
>
<Sparkles className="h-4 w-4" />
</Button>
) : null}
<Button
variant="ghost"
size="icon"
Expand Down
13 changes: 13 additions & 0 deletions packages/app-shell/src/console/ai/AiChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ export function AiChatPage({ apiBase: apiBaseProp, defaultAgent: defaultAgentPro
// existing conversation, and the flag is stripped once the fresh id is
// mirrored into the URL.
const forceNewConversation = searchParams.get('new') !== null;
// ADR-0070 "Edit with AI": the package the user opened to edit (from the app
// list's per-app action). Forwarded to the build agent as `context.packageId`
// so its metadata reads scope to that app and edits bind to it from the first
// message (the agent seeds it as the conversation's active package).
const editPackageId = searchParams.get('package')?.trim() || undefined;
const navigate = useNavigate();
const { setContext } = useNavigationContext();

Expand Down Expand Up @@ -849,6 +854,7 @@ export function AiChatPage({ apiBase: apiBaseProp, defaultAgent: defaultAgentPro
chatApi={chatApi}
apiBase={apiBase}
conversationId={conversationId}
editPackageId={editPackageId}
initialMessages={initialMessages}
onSent={handleSent}
onShare={() => setShareOpen(true)}
Expand Down Expand Up @@ -920,6 +926,9 @@ interface ChatPaneProps {
chatApi: string | undefined;
apiBase: string;
conversationId: string | undefined;
/** ADR-0070 "Edit with AI": the package the user opened to edit (from `?package=`),
* forwarded to the build agent as `context.packageId` to scope it to that app. */
editPackageId?: string;
initialMessages: HydratedUIMessage[];
onSent: (firstUserMessage?: string) => void;
onShare: () => void;
Expand All @@ -935,6 +944,7 @@ function ChatPane({
chatApi,
apiBase,
conversationId,
editPackageId,
initialMessages,
onSent,
onShare,
Expand Down Expand Up @@ -1040,6 +1050,9 @@ function ChatPane({
// Tell the agent the environment's publish posture so its narration
// matches reality (an auto-published build is live, not "to publish").
autoPublishAiBuilds: getRuntimeConfig().features.autoPublishAiBuilds,
// ADR-0070 "Edit with AI": scope the build agent to the app the user
// opened to edit. Cloud seeds it as the conversation's active package.
...(editPackageId ? { packageId: editPackageId } : {}),
},
},
initialMessages: hydrated,
Expand Down
Loading