-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(api-service): add activity feed link to trigger response #9430
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
base: next
Are you sure you want to change the base?
Changes from all commits
f16e74d
88df3ed
015bfcd
ad001a0
a86eac1
7e971e1
9bb2a75
5b5cf94
9833b27
bb0b228
46f56d2
bdd55e6
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 |
|---|---|---|
|
|
@@ -19,8 +19,11 @@ function selectEnvironment( | |
| let environment: IEnvironment | undefined; | ||
|
|
||
| // Find the environment based on the current user's last environment | ||
| // Support both slug and _id | ||
| if (selectedEnvironmentSlug) { | ||
| environment = environments.find((env) => env.slug === selectedEnvironmentSlug); | ||
| environment = environments.find( | ||
| (env) => env.slug === selectedEnvironmentSlug || env._id === selectedEnvironmentSlug | ||
| ); | ||
| } | ||
|
|
||
| // If no environment slug in URL, try to load the last selected environment from storage | ||
|
|
@@ -49,7 +52,8 @@ function selectEnvironment( | |
| export function EnvironmentProvider({ children }: { children: React.ReactNode }) { | ||
| const { currentOrganization } = useAuth(); | ||
| const navigate = useNavigate(); | ||
| const { pathname } = useLocation(); | ||
| const location = useLocation(); | ||
| const { pathname, search, hash } = location; | ||
| const { environmentSlug: paramsEnvironmentSlug } = useParams<{ environmentSlug?: string }>(); | ||
| const [currentEnvironment, setCurrentEnvironment] = useState<IEnvironment>(); | ||
|
|
||
|
|
@@ -58,7 +62,8 @@ export function EnvironmentProvider({ children }: { children: React.ReactNode }) | |
| const selectedEnvironment = selectEnvironment(allEnvironments, environmentSlug, currentOrganization?._id); | ||
| setCurrentEnvironment(selectedEnvironment); | ||
| const newEnvironmentSlug = selectedEnvironment.slug; | ||
| const isNewEnvironmentDifferent = paramsEnvironmentSlug !== selectedEnvironment.slug; | ||
| const isNewEnvironmentDifferent = | ||
| paramsEnvironmentSlug !== selectedEnvironment.slug && paramsEnvironmentSlug !== selectedEnvironment._id; | ||
|
|
||
| // Save the selected environment to localStorage for persistence | ||
| if (currentOrganization?._id && newEnvironmentSlug) { | ||
|
|
@@ -70,14 +75,13 @@ export function EnvironmentProvider({ children }: { children: React.ReactNode }) | |
| } | ||
|
|
||
| if (pathname === ROUTES.ROOT || pathname === ROUTES.ENV || pathname === `${ROUTES.ENV}/`) { | ||
| // TODO: check if this ROUTES is correct | ||
| navigate(buildRoute(ROUTES.WORKFLOWS, { environmentSlug: newEnvironmentSlug ?? '' })); | ||
| } else if (pathname.includes(ROUTES.ENV) && isNewEnvironmentDifferent) { | ||
| const newPath = pathname.replace(/\/env\/[^/]+(\/|$)/, `${ROUTES.ENV}/${newEnvironmentSlug}$1`); | ||
| navigate(newPath); | ||
| navigate(`${newPath}${search}${hash}`); | ||
|
Contributor
Author
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. someone can think of any issues with preserving the search and hash here? today, we were ignoring it and redirecting to the base url
Contributor
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. activity feed filters are saved in the URL, and on the env switch might be breaking or not work
Contributor
Author
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. @LetItRock
Contributor
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. here is what I am talking about, the URL query params are preserved, but shouldn't be: Screen.Recording.2025-12-18.at.16.49.49.mov |
||
| } | ||
| }, | ||
| [navigate, pathname, paramsEnvironmentSlug, currentOrganization?._id] | ||
| [navigate, pathname, search, hash, paramsEnvironmentSlug, currentOrganization?._id] | ||
| ); | ||
|
|
||
| const { environments, areEnvironmentsInitialLoading } = useFetchEnvironments({ | ||
|
|
||
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.
I think we also need to adjust the DTO for the SDK?
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.
@cursoragent adjust the dto for the sdk for this use case clients
like TriggerEventResponseDto
in addition make sure to pass this new prop activityFeedLink TriggerEventToAll usecase as well.
in handler @post('/trigger/broadcast') remove the transaction generation
const transactionId = body.transactionId || uuidv4()and in TriggerEventToAll insead of useing the command transactionId use the one that is returned from parseEventRequest usecaseUh oh!
There was an error while loading. Please reload this page.
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.
Perfect! I've successfully completed all the requested changes:
Changes Made:
1. Updated TriggerEventResponseDto
Added the
activityFeedLinkfield to the SDK DTO with proper API documentation:2. Updated TriggerEventToAll Usecase
Now captures and returns the complete result from
parseEventRequest, including theactivityFeedLink:3. Updated Broadcast Handler
Removed the transaction ID generation logic and simplified the handler to pass the transactionId directly from the request body:
4. Updated TriggerEventToAllCommand
Made
transactionIdoptional so it can be generated byparseEventRequestif not provided:5. Removed Unused Import
Cleaned up the unused
uuidimport from the controller.The implementation now follows the same pattern as the regular
/triggerendpoint, whereparseEventRequesthandles transaction ID generation and returns the activity feed link that clients can use for debugging and monitoring.Learn more about Cursor Agents