Fix/history#729
Merged
Merged
Conversation
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().
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.
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.