MCPcopy Index your code
hub / github.com/21st-dev/1code / getInitialWindowParams

Function getInitialWindowParams

src/renderer/contexts/WindowContext.tsx:71–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69 * These are one-time use - cleared from sessionStorage after first read.
70 */
71export function getInitialWindowParams(): { chatId?: string; subChatId?: string } {
72 // Check if already consumed
73 const consumed = sessionStorage.getItem("windowParamsConsumed")
74 if (consumed) return {}
75
76 // Try URL params first (dev mode)
77 const urlParams = new URLSearchParams(window.location.search)
78 let chatId = urlParams.get("chatId")
79 let subChatId = urlParams.get("subChatId")
80
81 // Try hash params (production file:// URLs)
82 if (!chatId && window.location.hash) {
83 const hashParams = new URLSearchParams(window.location.hash.slice(1))
84 chatId = hashParams.get("chatId")
85 subChatId = hashParams.get("subChatId")
86 }
87
88 // Mark as consumed so we don't re-apply on hot reload
89 if (chatId || subChatId) {
90 sessionStorage.setItem("windowParamsConsumed", "true")
91 }
92
93 return {
94 chatId: chatId || undefined,
95 subChatId: subChatId || undefined,
96 }
97}

Callers 1

AppContentFunction · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected