MCPcopy Index your code
hub / github.com/codeaashu/claude-code / ThinkbackInstaller

Function ThinkbackInstaller

src/commands/thinkback/thinkback.tsx:152–268  ·  view source on GitHub ↗
({
  onReady,
  onError
}: {
  onReady: () => void;
  onError: (message: string) => void;
})

Source from the content-addressed store, hash-verified

150 message: string;
151};
152function ThinkbackInstaller({
153 onReady,
154 onError
155}: {
156 onReady: () => void;
157 onError: (message: string) => void;
158}): React.ReactNode {
159 const [state, setState] = useState<InstallState>({
160 phase: 'checking'
161 });
162 const [progressMessage, setProgressMessage] = useState('');
163 useEffect(() => {
164 async function checkAndInstall(): Promise<void> {
165 try {
166 // Check if marketplace is installed
167 const knownMarketplaces = await loadKnownMarketplacesConfig();
168 const marketplaceName = getMarketplaceName();
169 const marketplaceRepo = getMarketplaceRepo();
170 const pluginId = getPluginId();
171 const marketplaceInstalled = marketplaceName in knownMarketplaces;
172
173 // Check if plugin is already installed first
174 const pluginAlreadyInstalled = isPluginInstalled(pluginId);
175 if (!marketplaceInstalled) {
176 // Install the marketplace
177 setState({
178 phase: 'installing-marketplace'
179 });
180 logForDebugging(`Installing marketplace ${marketplaceRepo}`);
181 await addMarketplaceSource({
182 source: 'github',
183 repo: marketplaceRepo
184 }, message => {
185 setProgressMessage(message);
186 });
187 clearAllCaches();
188 logForDebugging(`Marketplace ${marketplaceName} installed`);
189 } else if (!pluginAlreadyInstalled) {
190 // Marketplace installed but plugin not installed - refresh to get latest plugins
191 // Only refresh when needed to avoid potentially destructive git operations
192 setState({
193 phase: 'installing-marketplace'
194 });
195 setProgressMessage('Updating marketplace…');
196 logForDebugging(`Refreshing marketplace ${marketplaceName}`);
197 await refreshMarketplace(marketplaceName, message_0 => {
198 setProgressMessage(message_0);
199 });
200 clearMarketplacesCache();
201 clearAllCaches();
202 logForDebugging(`Marketplace ${marketplaceName} refreshed`);
203 }
204 if (!pluginAlreadyInstalled) {
205 // Install the plugin
206 setState({
207 phase: 'installing-plugin'
208 });
209 logForDebugging(`Installing plugin ${pluginId}`);

Callers

nothing calls this directly

Calls 1

checkAndInstallFunction · 0.85

Tested by

no test coverage detected