Skip to content

Fix/history#729

Merged
linonetwo merged 17 commits into
masterfrom
fix/history
Jun 25, 2026
Merged

Fix/history#729
linonetwo merged 17 commits into
masterfrom
fix/history

Conversation

@linonetwo

Copy link
Copy Markdown
Contributor

No description provided.

linonetwo added 10 commits June 25, 2026 20:34
Closes #728

- Remove early return when rememberLastPageVisited is false, so the section is always visible
- Add Switch component to toggle rememberLastPageVisited preference
- Replace usePromiseValue with usePreferenceObservable for reactive updates
- Only show lastUrl TextField when the toggle is enabled
Three-layer interception for tidgi:// URLs:
- will-navigate handler in setupViewEventHandlers
- window.open() handler in handleNewWindow
- protocol handler fallback in setupIpcServerRoutesHandlers
Replace always-visible TextField with a Switch to toggle
rememberLastPageVisited preference, showing the TextField only when enabled
protocol.ts is imported by both main and renderer processes, but
process.env is not available in the renderer (browser) context.

- protocol.ts now always exports 'tidgi' (renderer-safe)
- main.ts uses isTest from environment.ts for test-mode scheme
- handleNewWindow/setupViewEventHandlers check both prefix variants
- deepLink/index.ts computes test-aware scheme locally
Use isTest from environment.ts in main process files to derive the
correct scheme (tidgi-test in test mode, tidgi otherwise).

Remove protocol.ts import from renderer files (Search.tsx, EmbeddingItem.tsx)
- the renderer always uses the production scheme 'tidgi', and should not
  depend on process.env-sensitive constants.
Renderer processes now obtain the protocol scheme via IPC
(window.service.deepLink.getProtocolScheme()) instead of importing
protocol.ts directly or hardcoding 'tidgi'.

The main process DeepLinkService uses isTest from environment.ts to
return the correct scheme (tidgi or tidgi-test).
…erywhere

protocol.ts now properly computes tidgi/tidgi-test via process.env.
All main process files use the canonical TIDGI_PROTOCOL_SCHEME constant.
Renderer files get the scheme via window.service.deepLink.getProtocolScheme().
Copilot AI review requested due to automatic review settings June 25, 2026 13:30
Renderer obtains test-mode status via window.service.context.get('isTest'),
the canonical way to forward environment variables from main to renderer.
Removes the unnecessary getProtocolScheme from DeepLinkService.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves handling of TidGi deep links (especially ...://preferences/...) so they’re opened internally from wiki content/navigation flows, and updates UI wiring around “remember last page visited” and deep-link scheme resolution.

Changes:

  • Use window.service.deepLink.getProtocolScheme() in renderer UI to build deep-link URLs without importing the protocol constant directly.
  • Intercept protocol deep links in view navigation/new-window/protocol-route handling and route them to DeepLinkService.openDeepLink(...) instead of external navigation.
  • Update the workspace “Last visit state” UI to include a toggle and only show the last-URL field when enabled.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/windows/Preferences/sections/Search.tsx Uses deep-link service to obtain protocol scheme before opening preferences deep link.
src/windows/EditWorkspace/customItems/MiscItems.tsx Reworks “remember last page visited” UI to use an observable preference and adds a toggle switch.
src/windows/EditWorkspace/customItems/EmbeddingItem.tsx Uses deep-link service to obtain protocol scheme before opening preferences deep link.
src/services/view/setupViewEventHandlers.ts Handles protocol deep links during will-navigate by opening them internally.
src/services/view/setupIpcServerRoutesHandlers.ts Handles ...://preferences/... deep links at the protocol handler level (returns 204 to avoid reload).
src/services/view/handleNewWindow.ts Prevents protocol deep links from opening externally; opens them internally instead.
src/services/deepLink/interface.ts Adds getProtocolScheme() to the deep link service IPC interface.
src/services/deepLink/index.ts Implements getProtocolScheme() to support environment-dependent scheme selection.
src/constants/protocol.ts Updates module comment to reflect usage for both deep linking and wiki content serving.

Comment on lines +107 to +110
// Handle tidgi:// deep links internally (e.g. tidgi://preferences/externalAPI from within wiki pages)
if (newUrl.startsWith(`${TIDGI_PROTOCOL_SCHEME}://`)) {
logger.info('will-navigate handling tidgi:// deep link internally', { newUrl, function: 'will-navigate' });
event.preventDefault();
Comment on lines +59 to +62
// Handle tidgi:// deep links internally instead of opening in external browser
if (nextUrl.startsWith(`${TIDGI_PROTOCOL_SCHEME}://`)) {
logger.info('handleNewWindow handling tidgi:// deep link internally', { nextUrl, disposition, function: 'handleNewWindow' });
void deepLinkService.openDeepLink(nextUrl);
Comment on lines +153 to +155
// Handle tidgi:// deep links internally
logger.info('childWindow will-navigate handling tidgi:// deep link internally', { url, function: 'handleNewWindow' });
_event.preventDefault();
Comment on lines +164 to +166
// Handle tidgi://preferences/... deep links at the protocol level.
// This catches requests that bypass will-navigate (e.g. TiddlyWiki's
// internal link handling that triggers a direct protocol request).
#726 removed IS_TEST_ENV (process.env.NODE_ENV) from SchemaRenderer and
GenericSchemaRenderer to keep them renderer-safe. Restore the test-mode
behavior properly through window.service.context.get('isTest'):

- In test mode, all preference sections are rendered immediately
- In test mode, lazy-loading idle callbacks are skipped
- Falls back to incremental loading in production
New URL format: tidgi://<workspaceId>/preferences/<sectionId>
opens the edit workspace window for the given workspace.

- deepLink handler parses /preferences/ pathname for workspace-scoped links
- protocol handler catches /preferences/ pathname in addition to hostname
- EmbeddingItem now includes workspaceId in the deep link URL
externalAPI is a global PreferenceSection, not workspace-specific.
Use tidgi://preferences/externalAPI (without workspaceId) for it.
- tidgi://workspace/preferences/<section> opens settings for the active workspace.
- tidgi://<workspaceId>/preferences/<section> also works.
- EditWorkspace window now accepts preferenceGotoTab metadata and scrolls to the requested section.
- Adds unit tests for the workspace-scoped preferences deep link.
@linonetwo
linonetwo merged commit b60e0b5 into master Jun 25, 2026
2 checks passed
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