Promote staging to main: portfolio monitors, watchlist tools, and records refresh#130
Conversation
* feat(trading): refresh order records table and details Co-authored-by: Codex <codex@openai.com> * feat(records): keep order details accessible in linked log view Co-authored-by: Codex <codex@openai.com> * refactor(trading): consolidate provider order detail types Co-authored-by: Codex <codex@openai.com> --------- Co-authored-by: Codex <codex@openai.com>
* feat(tradinggoose): add watchlist block and tools Co-authored-by: Codex <codex@openai.com> * feat(tradinggoose): unify listing selector identity flows Co-authored-by: Codex <codex@openai.com> * feat(watchlist): align watchlist tools with canonical routes Co-authored-by: Codex <codex@openai.com> * feat(listing-selector): enhance disabled state logic and handle listing options error * feat(watchlist): refactor code for improved readability and consistency * fix(editor-workflow): preserve tool sub-block context Pass operation-aware context into tool sub-blocks and avoid clearing listing selectors before fetched options resolve.\n\nCo-authored-by: Codex <codex@openai.com> * fix(watchlist): reject unresolved listing options Co-authored-by: Codex <codex@openai.com> * feat(listing-selector): support provider-aware listing search Co-authored-by: Codex <codex@openai.com> * feat(trading-action): add provider parameter to TradingActionParams and update related tests * feat(watchlist): enhance listing display options and add tests for listing selector * feat(listing-selector): rename StockSelector to ListingSearchInput and update references * refactor(listing-selector): simplify dropdown and input components, remove unused props * feat(watchlist-tool): add workflow block and tools for managing watchlists and listings * feat(listing-selector): improve candidate listings handling and enhance summary row component * feat(listing-selector): refactor fetchOptions handling and improve context value management --------- Co-authored-by: Codex <codex@openai.com>
* feat(monitors): add portfolio monitor support Co-authored-by: Codex <codex@openai.com> * refactor(tradinggoose): move shared widget controls to components Co-authored-by: Codex <codex@openai.com> * feat(tradinggoose): split market and trading provider handling Co-authored-by: Codex <codex@openai.com> * refactor(monitors): normalize provider configs and sources Co-authored-by: Codex <codex@openai.com> * refactor(workflow): inline provider selector sub-blocks Co-authored-by: Codex <codex@openai.com> * feat(monitors): add source-aware monitor handling and runtime locks Co-authored-by: Codex <codex@openai.com> * feat(portfolio): enhance credential handling in portfolio identity functions * feat(monitor): remove referenceData from monitor payload functions * feat(portfolio): enhance service ID resolution and preserve runtime state in portfolio monitor updates * feat(trading): rename holdings surface to portfolio detail Co-authored-by: Codex <codex@openai.com> * fix(monitor): refine config defaults and selector layouts Co-authored-by: Codex <codex@openai.com> * fix(monitor-runtime): ignore deduped pending executions Co-authored-by: Codex <codex@openai.com> * refactor(monitor): simplify monitor card surfaces Co-authored-by: Codex <codex@openai.com> * style(card): adjust card background and shadow for improved aesthetics * feat(monitor-runtime): add updatedAt field and enhance runtime state management * feat(monitor-runtime): enhance execution ID generation and improve error handling for database connection issues * refactor(monitor): simplify MonitorKanbanSection and remove unused props refactor(config): streamline ConfigBoardSection structure and update tests feat(tests): enhance portfolio monitor runtime tests with additional error handling * feat(monitor-config): enhance PortfolioMonitorProviderConfig schema and improve runtime configuration handling * feat(monitor-execution): streamline execution handling by integrating enqueuePendingExecution and removing unused mocks * refactor(trading): remove workspace scoping from connection lookup Co-authored-by: Codex <codex@openai.com> * feat(tradinggoose): disable monitors on permanent dispatch failures Co-authored-by: Codex <codex@openai.com> * feat(monitor): refactor account resolution to include connectionOwnerUserId and streamline service ID handling * feat(monitor-execution): enhance error handling for workflow backlog and update execution logic * feat(indicator-monitor): update source identifier for monitor execution context * feat(portfolio-monitor): generalize monitor management and add portfolio monitor features * feat(monitor): remove TriggerExecutionUnavailableError mock from tests * feat(portfolio-monitor): update condition labels and enhance async handling in data processing --------- Co-authored-by: Codex <codex@openai.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
| Filename | Overview |
|---|---|
| apps/tradinggoose/background/pending-execution-drain.ts | Renamed executionType case from 'indicator_monitor' to 'monitor' with no backward-compat path for pre-existing queued rows; orphaned rows will loop through claim → fail → stale-reclaim indefinitely. |
| apps/tradinggoose/lib/execution/pending-execution.ts | Drops 'indicator_monitor' from PendingExecutionType and replaces it with 'monitor'; no migration path for existing queued rows of the old type. |
| apps/tradinggoose/app/api/monitors/route.ts | New source-aware monitor create/list route generalizing from indicator-only to portfolio+indicator; auth, workspace permission, and reconcile-notify patterns look correct. |
| apps/tradinggoose/app/api/monitors/[id]/route.ts | New GET/PATCH/DELETE route for unified monitors with proper workspace ownership checks and optimistic-concurrency on PATCH; runtimeState is preserved when the effective config doesn't change. |
| apps/tradinggoose/socket-server/trading/portfolio-monitor-runtime.ts | New portfolio monitor runtime with shared lock helper, subscription lifecycle, edge/while_true fire modes, and optimistic-concurrency DB writes; non-firing state writes are now conditional on state transitions. |
| apps/tradinggoose/lib/monitors/portfolio-conditions.ts | New portfolio condition evaluator with full metric set, operator compatibility guard, and ListingIdentity-backed position matching; crosses_above/crosses_below correctly return false when no previous snapshot exists. |
| apps/tradinggoose/background/monitor-execution.ts | New dispatch shim that routes MonitorExecutionPayload to the correct handler by source; clean registry pattern. |
| apps/tradinggoose/blocks/blocks/watchlist.ts | New Watchlist block with readLists/readListItems/addListing/removeListing operations; listing field correctly uses LISTING_IDENTITY_VALUE_TYPE and fetchOptions for removeListing is scoped to the selected watchlist. |
| apps/tradinggoose/tools/watchlist/index.ts | New watchlist tool implementations; workspaceId is injected by the tool-execution framework for GET routes, POST mutations explicitly resolve it from _context. |
| apps/tradinggoose/app/api/watchlists/route.ts | Adds checkSessionOrInternalAuth for workflow tool access, and a new watchlistId lookup path on GET to support the readListItems tool. |
| apps/tradinggoose/providers/trading/portfolio-identity.ts | Renames tokenAccountId to credentialId in PortfolioIdentity, separating the public credential identifier from the internal OAuth token store key; getPortfolioIdentityKey updated consistently. |
| apps/tradinggoose/socket-server/trading/portfolio-manager.ts | Refactored to support server-side onData/onError callbacks for monitor runtime subscriptions; now uses authorizeTradingConnectionRequest for credential resolution and adds workspace access checks. |
Sequence Diagram
sequenceDiagram
participant PM as PortfolioManager
participant PMR as PortfolioMonitorRuntime
participant DB as Database
participant PE as PendingExecution queue
participant Drain as pending-execution-drain
participant WF as Workflow execution
PMR->>DB: reconcile() SELECT active portfolio monitors
DB-->>PMR: monitor rows
PMR->>PM: subscribeData(portfolioIdentity, onData)
loop every pollIntervalSeconds
PM->>PM: poll trading provider
PM->>PMR: onData(account-snapshot)
PMR->>PMR: evaluatePortfolioFireCondition()
alt condition fires
PMR->>DB: getCurrentProviderConfig() SELECT
PMR->>PE: "enqueuePendingExecution type=monitor"
PMR->>DB: updateRuntimeState() SELECT+UPDATE
else state transition only
PMR->>DB: updateRuntimeState() SELECT+UPDATE
else no change
PMR->>PMR: update in-memory state only
end
end
Drain->>PE: claimNextPendingExecution()
PE-->>Drain: "row executionType=monitor"
Drain->>Drain: isMonitorExecutionPayload()
Drain->>WF: executePortfolioMonitorJob()
WF-->>Drain: result
Drain->>PE: completePendingExecution()
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/tradinggoose/background/pending-execution-drain.ts:62-76
**Orphaned `indicator_monitor` rows after deployment**
`PendingExecutionType` dropped `'indicator_monitor'` and the drain's switch now handles only `'monitor'`. Any pending-execution row already in the DB with `executionType = 'indicator_monitor'` will hit the `default: throw` branch, be logged as an error, but never reach `completePendingExecution`. The row stays in its claimed state, is reclaimed after the 30-minute stale-processing window (`STALE_PROCESSING_WINDOW_MS`), and then fails in the same way on every subsequent drain invocation — creating an infinite failure loop for the entire lifetime of those rows.
Given that indicator monitors fire on every market data tick, there will almost certainly be in-flight `indicator_monitor` rows queued at the moment the workers are redeployed, even in a coordinated rollout. Adding a backward-compat case that immediately completes (or marks as failed) old-type rows would prevent this.
Reviews (3): Last reviewed commit: "fix(watchlist): fetch individual watchli..." | Re-trigger Greptile
…writes (#131) * fix(monitor-runtime): refine runtime state update logic in PortfolioMonitorRuntime * fix(portfolio-monitor): remove unused previousSnapshot schema and update runtime state handling * fix(portfolio-monitor): update PortfolioMonitorProviderConfigSchema to use .strip() and .catch(undefined)
* feat(watchlist): add support for retrieving individual watchlists and update related tests * fix(tests): update dynamic internal API URL to include filter and workspaceId
Summary
Promotes the current staging branch to main with three merged feature sets:
Diff scope:
upstream/main605fd3f0toupstream/staging8a60dd62, 317 files changed.Why
This promotes staged trading workflow improvements into main so production can use the latest records UI, watchlist automation, shared listing/provider selectors, and portfolio state monitor runtime.
Affected Areas
apps/tradinggooseapps/docspackages/*changelog/*Issue Links( if any )
Refs #127
Refs #128
Refs #129
Validation
Results:
upstream/main605fd3f0andupstream/staging8a60dd62.*/migration/*files are touched.Risk / Rollout Notes
/api/monitorsroutes.Config / Data Changes
Screenshots / Video
Not captured in this PR body drafting pass.
Visible UI areas changed:
Checklist