Skip to content

feat(sdk): add toast API and Yahoo dividends endpoint for addons#625

Merged
afadil merged 13 commits intoafadil:mainfrom
kwaich:feature/dividend-tracker-addon
Mar 2, 2026
Merged

feat(sdk): add toast API and Yahoo dividends endpoint for addons#625
afadil merged 13 commits intoafadil:mainfrom
kwaich:feature/dividend-tracker-addon

Conversation

@kwaich
Copy link
Contributor

@kwaich kwaich commented Feb 27, 2026

Description

Extends the addon platform with two new capabilities built to support the
Dividend Tracker addon.

Toast notifications (ToastAPI)

  • Adds ToastAPI interface to the addon SDK (host-api.ts) with success, error, warning, and info methods
  • Wired through type-bridge.ts and addons-runtime-context.ts using the host app's existing sonner instance
  • Addons can now show user-facing toast feedback without coupling to the host's toast library

Yahoo Finance dividend endpoint

  • Adds fetch_dividends on YahooProvider in the market-data crate — fetches up to 2 years of dividend events from the Yahoo Finance v8 chart API using the existing crumb/cookie session
  • Exposes YahooDividend as a public type from wealthfolio-market-data
  • New fetch_yahoo_dividends Tauri command proxies the call through Rust (avoids CORS in the webview)

Minor improvements

  • invalidateQueries / refetchQueries in the addon runtime now pass exact: false for broader cache invalidation
  • NewActivity.notes gains #[serde(alias = "comment")] for backwards-compatibility

Checklist

By submitting this PR, I agree to the CLA.

@afadil
Copy link
Owner

afadil commented Mar 1, 2026

Thanks for the contribution. Can you maintain this add-on in its own dedicated GitHub repository? I can then add it to the addons store

@kwaich
Copy link
Contributor Author

kwaich commented Mar 1, 2026

@afadil there are some changes in the app which this add-on needs which is included in this PR. should i take the add-on out and leave the app changes?

@afadil
Copy link
Owner

afadil commented Mar 1, 2026

Yes please, keep only the app changes in this pr and move the addon to a dedicated repo you own 🙏

@kwaich kwaich force-pushed the feature/dividend-tracker-addon branch from ee67f2b to 1b1561f Compare March 1, 2026 17:52
@kwaich kwaich changed the title feat(addon): add Dividend Tracker addon feat(sdk): add toast API and Yahoo dividends endpoint for addons Mar 1, 2026
@kwaich
Copy link
Contributor Author

kwaich commented Mar 1, 2026

@afadil updated, thanks 🙏

@afadil
Copy link
Owner

afadil commented Mar 1, 2026

please post here the link to the addon repo

@afadil
Copy link
Owner

afadil commented Mar 1, 2026

@codex review

@kwaich
Copy link
Contributor Author

kwaich commented Mar 1, 2026

link to add-on: https://github.com/kwaich/dividend-tracker

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b1561f924

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +230 to +233
pub async fn fetch_yahoo_dividends(
symbol: String,
) -> Result<Vec<wealthfolio_market_data::YahooDividend>, String> {
let provider = wealthfolio_market_data::YahooProvider::new()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Expose dividends endpoint through addon host API

fetch_yahoo_dividends is only introduced as a raw Tauri command, but the addon-facing API surface is not extended to call it (no corresponding method in MarketDataAPI and no bridge wiring in createSDKHostAPIBridge). As a result, addons that rely on the supported ctx.api contract cannot access this new endpoint, so the feature is effectively unreachable unless addon authors depend on internal Tauri globals.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

@kwaich kwaich Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fixed

Comment on lines +320 to +324
.and_then(|c| c.result)
.and_then(|r| r.into_iter().next())
.and_then(|r| r.events)
.and_then(|e| e.dividends)
.unwrap_or_default();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface Yahoo chart errors before defaulting to empty dividends

This logic converts any response without chart.result into Ok([]) via unwrap_or_default(), which masks upstream Yahoo failures when the payload contains chart.error with result: null (for example invalid/delisted symbols or auth-related responses). In those cases callers cannot distinguish a real “no dividends” result from a request failure, leading to silent data loss in dividend workflows.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

@kwaich kwaich Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fixed

kwaich added 13 commits March 2, 2026 15:16
Implement a new addon that identifies missing dividend activities by fetching historical data from Yahoo Finance. Features include:
- Holdings-based dividend suggestions
- Automated comparison with existing activities to avoid duplicates
- Bulk creation of missing dividend records
- Integrated history view for verified activities
…ckend

Move Yahoo Finance API calls from client-side to Rust backend to avoid
CORS restrictions. Refactor suggestions state to use an override Map
for cleaner update patterns. Add logging for symbol mapping.
…unnecessary re-renders

- Add useRef to track seen suggestion IDs
- Wrap symbolMap, yahooSymbolMap, and query configs in useMemo
- Only process new suggestions in useEffect instead of re-processing all
…on size

Suggestions previously included all current holdings regardless of whether
shares were owned at each ex-date. This adds a quantity timeline built from
BUY/SELL/SPLIT/TRANSFER_IN/TRANSFER_OUT activities so only eligible dividends
are surfaced, with amounts scaled to the actual position size at each ex-date.

Also exposes a `toast` API on the addon SDK backed by the host's sonner
instance, removing the need for addons to bundle sonner themselves.
…heck logic

Extracts isDuplicate logic to a dedicated utility file with
comprehensive unit tests. Adds test suites for HistoryTab,
DividendPage, and yahoo-dividends fetching logic using React Testing
Library and Vitest. Updates README with simplified test execution
instructions.
…stom hooks

Extracts data fetching and suggestion calculation logic from
SuggestionsTab into a set of specialized React hooks. This simplifies
the component, improves separation of concerns, and establishes a
reusable pattern for addon data management.

- Create useDividendSuggestions orchestrator hook
- Add specialized hooks for accounts, profiles, holdings, and activities
- Move DividendSuggestion interface to a shared types file
- Standardize query keys using QueryKeys from addon-sdk
…ggestions

- Add "Pay-Date" column to suggestions table for user input
- Store ex-date in activity notes when pay-date is used
- Update duplicate detection to use ex-date from notes if available
- Alias 'comment' to 'notes' in backend activity model for compatibility
…cation

- Replace native date input with DatePickerInput in SuggestionsTab for
  better pay-date selection and robust state updates.
- Remove anchors from the deduplication regex to ensure ex-date detection
  works even if the user appends notes to the comment field.
Add sorting, account filter, totals, truncation notice, and balance\nprivacy formatting; surface suggestion fetch errors and align\nqueries/pagination for dividend data.
@kwaich kwaich force-pushed the feature/dividend-tracker-addon branch from 90fb06d to 13bd49f Compare March 2, 2026 07:16
@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@afadil afadil merged commit e56fac3 into afadil:main Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants